All-in-One WP Migration - Version 6.74

Version Description

Added

  • Support for LiteSpeed web server
  • Fully localized the export, import, and restore processes

Fixed

  • Table prefix replacement on import in limited corner cases
  • URL replacement in Bitnami
Download this release

Release Info

Developer bangelov
Plugin Icon 128x128 All-in-One WP Migration
Version 6.74
Comparing to
See all releases

Code changes from version 6.73 to 6.74

Files changed (40) hide show
  1. all-in-one-wp-migration.php +1 -1
  2. constants.php +32 -32
  3. functions.php +14 -12
  4. lib/controller/class-ai1wm-export-controller.php +18 -1
  5. lib/controller/class-ai1wm-import-controller.php +18 -1
  6. lib/controller/class-ai1wm-main-controller.php +258 -116
  7. lib/controller/class-ai1wm-resolve-controller.php +0 -62
  8. lib/model/class-ai1wm-backups.php +4 -4
  9. lib/model/class-ai1wm-extensions.php +13 -13
  10. lib/model/class-ai1wm-http.php +0 -154
  11. lib/model/export/class-ai1wm-export-database.php +20 -12
  12. lib/model/export/class-ai1wm-export-enumerate.php +15 -22
  13. lib/model/export/class-ai1wm-export-resolve.php +0 -41
  14. lib/model/http/class-ai1wm-http-abstract.php +0 -54
  15. lib/model/http/class-ai1wm-http-curl.php +0 -77
  16. lib/model/http/class-ai1wm-http-stream.php +0 -110
  17. lib/model/import/class-ai1wm-import-database.php +190 -183
  18. lib/vendor/servmask/command/class-ai1wm-wp-cli-command.php +1 -3
  19. lib/vendor/servmask/database/class-ai1wm-database.php +87 -3
  20. lib/vendor/servmask/filesystem/class-ai1wm-directory.php +12 -6
  21. lib/vendor/servmask/filesystem/class-ai1wm-file-htaccess.php +27 -12
  22. lib/vendor/servmask/filesystem/class-ai1wm-file-index.php +3 -8
  23. lib/vendor/servmask/filesystem/class-ai1wm-file-webconfig.php +15 -18
  24. lib/vendor/servmask/filesystem/class-ai1wm-file.php +29 -6
  25. lib/vendor/servmask/filter/{class-ai1wm-extension-filter.php → class-ai1wm-recursive-extension-filter.php} +11 -5
  26. lib/vendor/servmask/iterator/class-ai1wm-recursive-directory-iterator.php +0 -2
  27. lib/{model/http/class-ai1wm-http-factory.php → vendor/servmask/iterator/class-ai1wm-recursive-iterator-iterator.php} +1 -9
  28. lib/view/assets/css/backups.min.css +1 -1
  29. lib/view/assets/css/backups.min.rtl.css +1 -1
  30. lib/view/assets/javascript/backups.min.js +65 -41
  31. lib/view/assets/javascript/export.min.js +35 -23
  32. lib/view/assets/javascript/feedback.min.js +4 -4
  33. lib/view/assets/javascript/import.min.js +69 -45
  34. lib/view/assets/javascript/report.min.js +2 -2
  35. lib/view/assets/javascript/updater.min.js +2 -2
  36. lib/view/backups/index.php +1 -1
  37. lib/{model/import/class-ai1wm-import-resolve.php → view/main/wordpress-htaccess-notice.php} +16 -16
  38. loader.php +9 -34
  39. readme.txt +12 -1
  40. uninstall.php +1 -3
all-in-one-wp-migration.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
6
  * Author: ServMask
7
  * Author URI: https://servmask.com/
8
- * Version: 6.73
9
  * Text Domain: all-in-one-wp-migration
10
  * Domain Path: /languages
11
  * Network: True
5
  * Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
6
  * Author: ServMask
7
  * Author URI: https://servmask.com/
8
+ * Version: 6.74
9
  * Text Domain: all-in-one-wp-migration
10
  * Domain Path: /languages
11
  * Network: True
constants.php CHANGED
@@ -31,16 +31,16 @@ define( 'AI1WM_DEBUG', false );
31
  // ==================
32
  // = Plugin Version =
33
  // ==================
34
- define( 'AI1WM_VERSION', '6.73' );
35
 
36
  // ===============
37
  // = Plugin Name =
38
  // ===============
39
  define( 'AI1WM_PLUGIN_NAME', 'all-in-one-wp-migration' );
40
 
41
- // ===================
42
- // = Directory Index =
43
- // ===================
44
  define( 'AI1WM_DIRECTORY_INDEX', 'index.php' );
45
 
46
  // ================
@@ -83,11 +83,6 @@ define( 'AI1WM_EXPORT_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'export' )
83
  // ===============
84
  define( 'AI1WM_IMPORT_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'import' );
85
 
86
- // =============
87
- // = Http Path =
88
- // =============
89
- define( 'AI1WM_HTTP_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'http' );
90
-
91
  // =============
92
  // = View Path =
93
  // =============
@@ -159,7 +154,7 @@ define( 'AI1WM_SETTINGS_NAME', 'settings.json' );
159
  define( 'AI1WM_MULTIPART_NAME', 'multipart.list' );
160
 
161
  // ========================
162
- // = Archive FileMap Name =
163
  // ========================
164
  define( 'AI1WM_FILEMAP_NAME', 'filemap.list' );
165
 
@@ -203,16 +198,6 @@ define( 'AI1WM_IMPORT_NAME', 'import.log' );
203
  // ==================
204
  define( 'AI1WM_ERROR_NAME', 'error.log' );
205
 
206
- // ==========
207
- // = URL IP =
208
- // ==========
209
- define( 'AI1WM_URL_IP', 'ai1wm_url_ip' );
210
-
211
- // ===============
212
- // = URL Adapter =
213
- // ===============
214
- define( 'AI1WM_URL_ADAPTER', 'ai1wm_url_adapter' );
215
-
216
  // ==============
217
  // = Secret Key =
218
  // ==============
@@ -228,6 +213,16 @@ define( 'AI1WM_AUTH_USER', 'ai1wm_auth_user' );
228
  // =================
229
  define( 'AI1WM_AUTH_PASSWORD', 'ai1wm_auth_password' );
230
 
 
 
 
 
 
 
 
 
 
 
231
  // ==================
232
  // = Active Plugins =
233
  // ==================
@@ -325,26 +320,31 @@ define( 'AI1WM_SITES_PATH', AI1WM_UPLOADS_PATH . DIRECTORY_SEPARATOR . 'sites' )
325
  // ================
326
  define( 'AI1WM_BACKUPS_PATH', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'ai1wm-backups' );
327
 
328
- // ======================
329
- // = Storage Index File =
330
- // ======================
331
  define( 'AI1WM_STORAGE_INDEX', AI1WM_STORAGE_PATH . DIRECTORY_SEPARATOR . 'index.php' );
332
 
333
- // ======================
334
- // = Backups Index File =
335
- // ======================
336
  define( 'AI1WM_BACKUPS_INDEX', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . 'index.php' );
337
 
338
- // =========================
339
- // = Backups Htaccess File =
340
- // =========================
341
- define( 'AI1WM_BACKUPS_HTACCESS', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . '.htaccess' );
342
-
343
  // ==========================
344
- // = Backups Webconfig File =
345
  // ==========================
 
 
 
 
 
346
  define( 'AI1WM_BACKUPS_WEBCONFIG', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . 'web.config' );
347
 
 
 
 
 
 
348
  // ================================
349
  // = WP Migration Plugin Base Dir =
350
  // ================================
31
  // ==================
32
  // = Plugin Version =
33
  // ==================
34
+ define( 'AI1WM_VERSION', '6.74' );
35
 
36
  // ===============
37
  // = Plugin Name =
38
  // ===============
39
  define( 'AI1WM_PLUGIN_NAME', 'all-in-one-wp-migration' );
40
 
41
+ // ============================
42
+ // = Directory index.php File =
43
+ // ============================
44
  define( 'AI1WM_DIRECTORY_INDEX', 'index.php' );
45
 
46
  // ================
83
  // ===============
84
  define( 'AI1WM_IMPORT_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'import' );
85
 
 
 
 
 
 
86
  // =============
87
  // = View Path =
88
  // =============
154
  define( 'AI1WM_MULTIPART_NAME', 'multipart.list' );
155
 
156
  // ========================
157
+ // = Archive Filemap Name =
158
  // ========================
159
  define( 'AI1WM_FILEMAP_NAME', 'filemap.list' );
160
 
198
  // ==================
199
  define( 'AI1WM_ERROR_NAME', 'error.log' );
200
 
 
 
 
 
 
 
 
 
 
 
201
  // ==============
202
  // = Secret Key =
203
  // ==============
213
  // =================
214
  define( 'AI1WM_AUTH_PASSWORD', 'ai1wm_auth_password' );
215
 
216
+ // ============
217
+ // = Site URL =
218
+ // ============
219
+ define( 'AI1WM_SITE_URL', 'siteurl' );
220
+
221
+ // ============
222
+ // = Home URL =
223
+ // ============
224
+ define( 'AI1WM_HOME_URL', 'home' );
225
+
226
  // ==================
227
  // = Active Plugins =
228
  // ==================
320
  // ================
321
  define( 'AI1WM_BACKUPS_PATH', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'ai1wm-backups' );
322
 
323
+ // ==========================
324
+ // = Storage index.php File =
325
+ // ==========================
326
  define( 'AI1WM_STORAGE_INDEX', AI1WM_STORAGE_PATH . DIRECTORY_SEPARATOR . 'index.php' );
327
 
328
+ // ==========================
329
+ // = Backups index.php File =
330
+ // ==========================
331
  define( 'AI1WM_BACKUPS_INDEX', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . 'index.php' );
332
 
 
 
 
 
 
333
  // ==========================
334
+ // = Backups .htaccess File =
335
  // ==========================
336
+ define( 'AI1WM_BACKUPS_HTACCESS', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . '.htaccess' );
337
+
338
+ // ===========================
339
+ // = Backups web.config File =
340
+ // ===========================
341
  define( 'AI1WM_BACKUPS_WEBCONFIG', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . 'web.config' );
342
 
343
+ // ============================
344
+ // = WordPress .htaccess File =
345
+ // ============================
346
+ define( 'AI1WM_WORDPRESS_HTACCESS', ABSPATH . DIRECTORY_SEPARATOR . '.htaccess' );
347
+
348
  // ================================
349
  // = WP Migration Plugin Base Dir =
350
  // ================================
functions.php CHANGED
@@ -31,7 +31,7 @@
31
  */
32
  function ai1wm_storage_path( $params ) {
33
  if ( empty( $params['storage'] ) ) {
34
- throw new Ai1wm_Storage_Exception( __( 'Unable to locate storage path', AI1WM_PLUGIN_NAME ) );
35
  }
36
 
37
  // Get storage path
@@ -51,12 +51,12 @@ function ai1wm_storage_path( $params ) {
51
  */
52
  function ai1wm_backup_path( $params ) {
53
  if ( empty( $params['archive'] ) ) {
54
- throw new Ai1wm_Archive_Exception( __( 'Unable to locate archive path', AI1WM_PLUGIN_NAME ) );
55
  }
56
 
57
  // Validate archive path
58
  if ( validate_file( $params['archive'] ) !== 0 ) {
59
- throw new Ai1wm_Archive_Exception( __( 'Invalid archive path', AI1WM_PLUGIN_NAME ) );
60
  }
61
 
62
  return AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . $params['archive'];
@@ -70,12 +70,12 @@ function ai1wm_backup_path( $params ) {
70
  */
71
  function ai1wm_archive_path( $params ) {
72
  if ( empty( $params['archive'] ) ) {
73
- throw new Ai1wm_Archive_Exception( __( 'Unable to locate archive path', AI1WM_PLUGIN_NAME ) );
74
  }
75
 
76
  // Validate archive path
77
  if ( validate_file( $params['archive'] ) !== 0 ) {
78
- throw new Ai1wm_Archive_Exception( __( 'Invalid archive path', AI1WM_PLUGIN_NAME ) );
79
  }
80
 
81
  // Get archive path
@@ -1061,7 +1061,7 @@ function ai1wm_urlscheme( $url, $scheme = '' ) {
1061
  function ai1wm_open( $file, $mode ) {
1062
  $file_handle = @fopen( $file, $mode );
1063
  if ( false === $file_handle ) {
1064
- throw new Ai1wm_Not_Accessible_Exception( sprintf( __( 'Unable to open %s with mode %s', AI1WM_PLUGIN_NAME ), $file, $mode ) );
1065
  }
1066
 
1067
  return $file_handle;
@@ -1080,10 +1080,12 @@ function ai1wm_write( $handle, $content ) {
1080
  $write_result = @fwrite( $handle, $content );
1081
  if ( false === $write_result ) {
1082
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1083
- throw new Ai1wm_Not_Writable_Exception( sprintf( __( 'Unable to write to: %s', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
1084
  }
1085
  } elseif ( strlen( $content ) !== $write_result ) {
1086
- throw new Ai1wm_Quota_Exceeded_Exception( __( 'Out of disk space.', AI1WM_PLUGIN_NAME ) );
 
 
1087
  }
1088
 
1089
  return $write_result;
@@ -1101,7 +1103,7 @@ function ai1wm_read( $handle, $filesize ) {
1101
  $read_result = @fread( $handle, $filesize );
1102
  if ( false === $read_result ) {
1103
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1104
- throw new Ai1wm_Not_Readable_Exception( sprintf( __( 'Unable to read file: %s', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
1105
  }
1106
  }
1107
 
@@ -1118,7 +1120,7 @@ function ai1wm_seek( $handle, $offset, $mode = SEEK_SET ) {
1118
  $seek_result = @fseek( $handle, $offset, $mode );
1119
  if ( -1 === $seek_result ) {
1120
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1121
- throw new Ai1wm_Not_Seekable_Exception( sprintf( __( 'Unable to seek to offset %d on %s', AI1WM_PLUGIN_NAME ), $offset, $meta['uri'] ) );
1122
  }
1123
  }
1124
 
@@ -1135,7 +1137,7 @@ function ai1wm_tell( $handle ) {
1135
  $tell_result = @ftell( $handle );
1136
  if ( false === $tell_result ) {
1137
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1138
- throw new Ai1wm_Not_Tellable_Exception( sprintf( __( 'Unable to get current pointer position of %s', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
1139
  }
1140
  }
1141
 
@@ -1298,7 +1300,7 @@ function ai1wm_fseek( $file_handle, Math_BigInteger $offset ) {
1298
  */
1299
  function ai1wm_verify_secret_key( $secret_key ) {
1300
  if ( $secret_key !== get_option( AI1WM_SECRET_KEY ) ) {
1301
- throw new Ai1wm_Not_Valid_Secret_Key_Exception( __( 'Unable to authenticate the secret key.', AI1WM_PLUGIN_NAME ) );
1302
  }
1303
 
1304
  return true;
31
  */
32
  function ai1wm_storage_path( $params ) {
33
  if ( empty( $params['storage'] ) ) {
34
+ 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 ) );
35
  }
36
 
37
  // Get storage path
51
  */
52
  function ai1wm_backup_path( $params ) {
53
  if ( empty( $params['archive'] ) ) {
54
+ 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 ) );
55
  }
56
 
57
  // Validate archive path
58
  if ( validate_file( $params['archive'] ) !== 0 ) {
59
+ 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 ) );
60
  }
61
 
62
  return AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . $params['archive'];
70
  */
71
  function ai1wm_archive_path( $params ) {
72
  if ( empty( $params['archive'] ) ) {
73
+ 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 ) );
74
  }
75
 
76
  // Validate archive path
77
  if ( validate_file( $params['archive'] ) !== 0 ) {
78
+ 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 ) );
79
  }
80
 
81
  // Get archive path
1061
  function ai1wm_open( $file, $mode ) {
1062
  $file_handle = @fopen( $file, $mode );
1063
  if ( false === $file_handle ) {
1064
+ 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 ) );
1065
  }
1066
 
1067
  return $file_handle;
1080
  $write_result = @fwrite( $handle, $content );
1081
  if ( false === $write_result ) {
1082
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1083
+ 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'] ) );
1084
  }
1085
  } elseif ( strlen( $content ) !== $write_result ) {
1086
+ if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1087
+ 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'] ) );
1088
+ }
1089
  }
1090
 
1091
  return $write_result;
1103
  $read_result = @fread( $handle, $filesize );
1104
  if ( false === $read_result ) {
1105
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1106
+ 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'] ) );
1107
  }
1108
  }
1109
 
1120
  $seek_result = @fseek( $handle, $offset, $mode );
1121
  if ( -1 === $seek_result ) {
1122
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1123
+ 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'] ) );
1124
  }
1125
  }
1126
 
1137
  $tell_result = @ftell( $handle );
1138
  if ( false === $tell_result ) {
1139
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1140
+ 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'] ) );
1141
  }
1142
  }
1143
 
1300
  */
1301
  function ai1wm_verify_secret_key( $secret_key ) {
1302
  if ( $secret_key !== get_option( AI1WM_SECRET_KEY ) ) {
1303
+ 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 ) );
1304
  }
1305
 
1306
  return true;
lib/controller/class-ai1wm-export-controller.php CHANGED
@@ -101,7 +101,14 @@ class Ai1wm_Export_Controller {
101
  exit;
102
  }
103
 
104
- return Ai1wm_Http::get( admin_url( 'admin-ajax.php?action=ai1wm_export' ), $params );
 
 
 
 
 
 
 
105
  }
106
  }
107
 
@@ -126,4 +133,14 @@ class Ai1wm_Export_Controller {
126
  apply_filters( 'ai1wm_export_azure_storage', Ai1wm_Template::get_content( 'export/button-azure-storage' ) ),
127
  );
128
  }
 
 
 
 
 
 
 
 
 
 
129
  }
101
  exit;
102
  }
103
 
104
+ wp_remote_post( apply_filters( 'ai1wm_http_export_url', admin_url( 'admin-ajax.php?action=ai1wm_export' ) ), array(
105
+ 'timeout' => apply_filters( 'ai1wm_http_export_timeout', 5 ),
106
+ 'blocking' => apply_filters( 'ai1wm_http_export_blocking', false ),
107
+ 'sslverify' => apply_filters( 'ai1wm_http_export_sslverify', false ),
108
+ 'headers' => apply_filters( 'ai1wm_http_export_headers', array() ),
109
+ 'body' => apply_filters( 'ai1wm_http_export_body', $params ),
110
+ ) );
111
+ exit;
112
  }
113
  }
114
 
133
  apply_filters( 'ai1wm_export_azure_storage', Ai1wm_Template::get_content( 'export/button-azure-storage' ) ),
134
  );
135
  }
136
+
137
+ public static function http_export_headers( $headers = array() ) {
138
+ if ( ( $user = get_option( AI1WM_AUTH_USER ) ) && ( $password = get_option( AI1WM_AUTH_PASSWORD ) ) ) {
139
+ if ( ( $hash = base64_encode( sprintf( '%s:%s', $user, $password ) ) ) ) {
140
+ $headers['Authorization'] = sprintf( 'Basic %s', $hash );
141
+ }
142
+ }
143
+
144
+ return $headers;
145
+ }
146
  }
lib/controller/class-ai1wm-import-controller.php CHANGED
@@ -105,7 +105,14 @@ class Ai1wm_Import_Controller {
105
  exit;
106
  }
107
 
108
- return Ai1wm_Http::get( admin_url( 'admin-ajax.php?action=ai1wm_import' ), $params );
 
 
 
 
 
 
 
109
  }
110
  }
111
 
@@ -132,6 +139,16 @@ class Ai1wm_Import_Controller {
132
  );
133
  }
134
 
 
 
 
 
 
 
 
 
 
 
135
  public static function max_chunk_size() {
136
  return min(
137
  ai1wm_parse_size( ini_get( 'post_max_size' ), AI1WM_MAX_CHUNK_SIZE ),
105
  exit;
106
  }
107
 
108
+ wp_remote_post( apply_filters( 'ai1wm_http_import_url', admin_url( 'admin-ajax.php?action=ai1wm_import' ) ), array(
109
+ 'timeout' => apply_filters( 'ai1wm_http_import_timeout', 5 ),
110
+ 'blocking' => apply_filters( 'ai1wm_http_import_blocking', false ),
111
+ 'sslverify' => apply_filters( 'ai1wm_http_import_sslverify', false ),
112
+ 'headers' => apply_filters( 'ai1wm_http_import_headers', array() ),
113
+ 'body' => apply_filters( 'ai1wm_http_import_body', $params ),
114
+ ) );
115
+ exit;
116
  }
117
  }
118
 
139
  );
140
  }
141
 
142
+ public static function http_import_headers( $headers = array() ) {
143
+ if ( ( $user = get_option( AI1WM_AUTH_USER ) ) && ( $password = get_option( AI1WM_AUTH_PASSWORD ) ) ) {
144
+ if ( ( $hash = base64_encode( sprintf( '%s:%s', $user, $password ) ) ) ) {
145
+ $headers['Authorization'] = sprintf( 'Basic %s', $hash );
146
+ }
147
+ }
148
+
149
+ return $headers;
150
+ }
151
+
152
  public static function max_chunk_size() {
153
  return min(
154
  ai1wm_parse_size( ini_get( 'post_max_size' ), AI1WM_MAX_CHUNK_SIZE ),
lib/controller/class-ai1wm-main-controller.php CHANGED
@@ -34,35 +34,41 @@ class Ai1wm_Main_Controller {
34
  register_activation_hook( AI1WM_PLUGIN_BASENAME, array( $this, 'activation_hook' ) );
35
 
36
  // Activate hooks
37
- $this->activate_actions()
38
- ->activate_filters()
39
- ->activate_textdomain();
40
  }
41
 
42
  /**
43
  * Activation hook callback
44
  *
45
- * @return Object Instance of this class
46
  */
47
  public function activation_hook() {
 
 
 
 
 
48
 
 
 
 
49
  }
50
 
51
  /**
52
  * Initializes language domain for the plugin
53
  *
54
- * @return Object Instance of this class
55
  */
56
  private function activate_textdomain() {
57
  load_plugin_textdomain( AI1WM_PLUGIN_NAME, false, false );
58
-
59
- return $this;
60
  }
61
 
62
  /**
63
  * Register listeners for actions
64
  *
65
- * @return Object Instance of this class
66
  */
67
  private function activate_actions() {
68
  // Init
@@ -71,12 +77,12 @@ class Ai1wm_Main_Controller {
71
  // Router
72
  add_action( 'admin_init', array( $this, 'router' ) );
73
 
 
 
 
74
  // Admin header
75
  add_action( 'admin_head', array( $this, 'admin_head' ) );
76
 
77
- // Create initial folders
78
- add_action( 'admin_init', array( $this, 'create_folders' ) );
79
-
80
  // All in One WP Migration
81
  add_action( 'plugins_loaded', array( $this, 'ai1wm_loaded' ), 10 );
82
 
@@ -100,23 +106,19 @@ class Ai1wm_Main_Controller {
100
 
101
  // Enqueue updater scripts and styles
102
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_updater_scripts_and_styles' ), 5 );
103
-
104
- return $this;
105
  }
106
 
107
  /**
108
  * Register listeners for filters
109
  *
110
- * @return Object Instance of this class
111
  */
112
  private function activate_filters() {
113
- // Add a links to plugin list page
114
  add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
115
 
116
  // Add custom schedules
117
  add_filter( 'cron_schedules', array( $this, 'add_cron_schedules' ), 9999 );
118
-
119
- return $this;
120
  }
121
 
122
  /**
@@ -128,12 +130,6 @@ class Ai1wm_Main_Controller {
128
  // Add export commands
129
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Init::execute', 5 );
130
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Compatibility::execute', 5 );
131
-
132
- // Resolve URL address
133
- if ( ai1wm_is_scheduled_backup() ) {
134
- add_filter( 'ai1wm_export', 'Ai1wm_Export_Resolve::execute', 5 );
135
- }
136
-
137
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Archive::execute', 10 );
138
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Config::execute', 50 );
139
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Config_File::execute', 60 );
@@ -147,12 +143,6 @@ class Ai1wm_Main_Controller {
147
  // Add import commands
148
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Upload::execute', 5 );
149
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Compatibility::execute', 10 );
150
-
151
- // Resolve URL address
152
- if ( ai1wm_is_scheduled_backup() ) {
153
- add_filter( 'ai1wm_import', 'Ai1wm_Import_Resolve::execute', 10 );
154
- }
155
-
156
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Validate::execute', 50 );
157
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Confirm::execute', 100 );
158
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Blogs::execute', 150 );
@@ -200,6 +190,12 @@ class Ai1wm_Main_Controller {
200
  // Add automatic plugins update
201
  add_action( 'wp_maybe_auto_update', 'Ai1wm_Updater_Controller::check_for_updates' );
202
 
 
 
 
 
 
 
203
  // Add chunk size limit
204
  add_filter( 'ai1wm_max_chunk_size', 'Ai1wm_Import_Controller::max_chunk_size' );
205
 
@@ -216,6 +212,155 @@ class Ai1wm_Main_Controller {
216
  add_filter( 'plugin_row_meta', 'Ai1wm_Updater_Controller::plugin_row_meta', 10, 2 );
217
  }
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  /**
220
  * Display multisite notice
221
  *
@@ -280,89 +425,25 @@ class Ai1wm_Main_Controller {
280
  }
281
 
282
  /**
283
- * Add a links to plugin list page
284
  *
285
- * @return array
286
  */
287
- public function plugin_row_meta( $links, $file ) {
288
- if ( $file == AI1WM_PLUGIN_BASENAME ) {
289
- $links[] = Ai1wm_Template::get_content( 'main/get-support' );
290
- }
291
-
292
- return $links;
293
  }
294
 
295
  /**
296
- * Create folders needed for plugin operation, if they don't exist
297
  *
298
- * @return void
299
  */
300
- public function create_folders() {
301
- // Check if storage folder is created
302
- if ( ! is_dir( AI1WM_STORAGE_PATH ) ) {
303
- if ( ! mkdir( AI1WM_STORAGE_PATH ) ) {
304
- if ( is_multisite() ) {
305
- return add_action( 'network_admin_notices', array( $this, 'storage_path_notice' ) );
306
- } else {
307
- return add_action( 'admin_notices', array( $this, 'storage_path_notice' ) );
308
- }
309
- }
310
- }
311
-
312
- // Check if index.php is created in storage folder
313
- if ( ! is_file( AI1WM_STORAGE_INDEX ) ) {
314
- if ( ! Ai1wm_File_Index::create( AI1WM_STORAGE_INDEX ) ) {
315
- if ( is_multisite() ) {
316
- return add_action( 'network_admin_notices', array( $this, 'storage_index_notice' ) );
317
- } else {
318
- return add_action( 'admin_notices', array( $this, 'storage_index_notice' ) );
319
- }
320
- }
321
- }
322
-
323
- // Check if ai1wm-backups folder is created
324
- if ( ! is_dir( AI1WM_BACKUPS_PATH ) ) {
325
- if ( ! mkdir( AI1WM_BACKUPS_PATH ) ) {
326
- if ( is_multisite() ) {
327
- return add_action( 'network_admin_notices', array( $this, 'backups_path_notice' ) );
328
- } else {
329
- return add_action( 'admin_notices', array( $this, 'backups_path_notice' ) );
330
- }
331
- }
332
- }
333
-
334
- // Check if .htaccess is created in backups folder
335
- if ( ! is_file( AI1WM_BACKUPS_HTACCESS ) ) {
336
- if ( ! Ai1wm_File_Htaccess::create( AI1WM_BACKUPS_HTACCESS ) ) {
337
- if ( is_multisite() ) {
338
- return add_action( 'network_admin_notices', array( $this, 'backups_htaccess_notice' ) );
339
- } else {
340
- return add_action( 'admin_notices', array( $this, 'backups_htaccess_notice' ) );
341
- }
342
- }
343
- }
344
-
345
- // Check if web.config is created in backups folder
346
- if ( ! is_file( AI1WM_BACKUPS_WEBCONFIG ) ) {
347
- if ( ! Ai1wm_File_Webconfig::create( AI1WM_BACKUPS_WEBCONFIG ) ) {
348
- if ( is_multisite() ) {
349
- return add_action( 'network_admin_notices', array( $this, 'backups_webconfig_notice' ) );
350
- } else {
351
- return add_action( 'admin_notices', array( $this, 'backups_webconfig_notice' ) );
352
- }
353
- }
354
  }
355
 
356
- // Check if index.php is created in backups folder
357
- if ( ! is_file( AI1WM_BACKUPS_INDEX ) ) {
358
- if ( ! Ai1wm_File_Index::create( AI1WM_BACKUPS_INDEX ) ) {
359
- if ( is_multisite() ) {
360
- return add_action( 'network_admin_notices', array( $this, 'backups_index_notice' ) );
361
- } else {
362
- return add_action( 'admin_notices', array( $this, 'backups_index_notice' ) );
363
- }
364
- }
365
- }
366
  }
367
 
368
  /**
@@ -508,6 +589,22 @@ class Ai1wm_Main_Controller {
508
  ),
509
  'secret_key' => get_option( AI1WM_SECRET_KEY ),
510
  ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  }
512
 
513
  /**
@@ -568,20 +665,47 @@ class Ai1wm_Main_Controller {
568
  'secret_key' => get_option( AI1WM_SECRET_KEY ),
569
  ),
570
  'filters' => array(
571
- 'ai1wm_archive_extension' => array( 'wpress', 'bin' ),
572
  'ai1wm_archive_size' => apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ),
573
  ),
574
  ) );
575
 
576
  wp_localize_script( 'ai1wm_import', 'ai1wm_import', array(
577
- 'ajax' => array(
578
  'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_import' ) ),
579
  ),
580
- 'status' => array(
581
  'url' => wp_make_link_relative( add_query_arg( array( 'secret_key' => get_option( AI1WM_SECRET_KEY ) ), admin_url( 'admin-ajax.php?action=ai1wm_status' ) ) ),
582
  ),
583
- 'secret_key' => get_option( AI1WM_SECRET_KEY ),
584
- 'oversize' => sprintf(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  __(
586
  'The file that you are trying to import is over the maximum upload file size limit of <strong>%s</strong>.<br />' .
587
  'You can remove this restriction by purchasing our ' .
@@ -590,12 +714,6 @@ class Ai1wm_Main_Controller {
590
  ),
591
  size_format( apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ) )
592
  ),
593
- 'invalid_extension' => __(
594
- 'The file type that you have tried to upload is not compatible with this plugin. ' .
595
- 'Please ensure that your file is a <strong>.wpress</strong> file that was created with the All-in-One WP migration plugin. ' .
596
- '<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
597
- AI1WM_PLUGIN_NAME
598
- ),
599
  ) );
600
  }
601
 
@@ -664,6 +782,27 @@ class Ai1wm_Main_Controller {
664
  ),
665
  'secret_key' => get_option( AI1WM_SECRET_KEY ),
666
  ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
  }
668
 
669
  /**
@@ -700,6 +839,11 @@ class Ai1wm_Main_Controller {
700
  'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_updater' ) ),
701
  ),
702
  ) );
 
 
 
 
 
703
  }
704
 
705
  /**
@@ -755,7 +899,6 @@ class Ai1wm_Main_Controller {
755
  add_action( 'wp_ajax_nopriv_ai1wm_export', 'Ai1wm_Export_Controller::export' );
756
  add_action( 'wp_ajax_nopriv_ai1wm_import', 'Ai1wm_Import_Controller::import' );
757
  add_action( 'wp_ajax_nopriv_ai1wm_status', 'Ai1wm_Status_Controller::status' );
758
- add_action( 'wp_ajax_nopriv_ai1wm_resolve', 'Ai1wm_Resolve_Controller::resolve' );
759
  add_action( 'wp_ajax_nopriv_ai1wm_backups', 'Ai1wm_Backups_Controller::delete' );
760
  add_action( 'wp_ajax_nopriv_ai1wm_feedback', 'Ai1wm_Feedback_Controller::feedback' );
761
  add_action( 'wp_ajax_nopriv_ai1wm_report', 'Ai1wm_Report_Controller::report' );
@@ -764,7 +907,6 @@ class Ai1wm_Main_Controller {
764
  add_action( 'wp_ajax_ai1wm_export', 'Ai1wm_Export_Controller::export' );
765
  add_action( 'wp_ajax_ai1wm_import', 'Ai1wm_Import_Controller::import' );
766
  add_action( 'wp_ajax_ai1wm_status', 'Ai1wm_Status_Controller::status' );
767
- add_action( 'wp_ajax_ai1wm_resolve', 'Ai1wm_Resolve_Controller::resolve' );
768
  add_action( 'wp_ajax_ai1wm_backups', 'Ai1wm_Backups_Controller::delete' );
769
  add_action( 'wp_ajax_ai1wm_feedback', 'Ai1wm_Feedback_Controller::feedback' );
770
  add_action( 'wp_ajax_ai1wm_report', 'Ai1wm_Report_Controller::report' );
34
  register_activation_hook( AI1WM_PLUGIN_BASENAME, array( $this, 'activation_hook' ) );
35
 
36
  // Activate hooks
37
+ $this->activate_actions();
38
+ $this->activate_filters();
39
+ $this->activate_textdomain();
40
  }
41
 
42
  /**
43
  * Activation hook callback
44
  *
45
+ * @return void
46
  */
47
  public function activation_hook() {
48
+ if ( is_dir( AI1WM_BACKUPS_PATH ) ) {
49
+ $this->create_backups_htaccess( AI1WM_BACKUPS_HTACCESS );
50
+ $this->create_backups_webconfig( AI1WM_BACKUPS_WEBCONFIG );
51
+ $this->create_backups_index( AI1WM_BACKUPS_INDEX );
52
+ }
53
 
54
+ if ( extension_loaded( 'litespeed' ) ) {
55
+ $this->create_litespeed_htaccess( AI1WM_WORDPRESS_HTACCESS );
56
+ }
57
  }
58
 
59
  /**
60
  * Initializes language domain for the plugin
61
  *
62
+ * @return void
63
  */
64
  private function activate_textdomain() {
65
  load_plugin_textdomain( AI1WM_PLUGIN_NAME, false, false );
 
 
66
  }
67
 
68
  /**
69
  * Register listeners for actions
70
  *
71
+ * @return void
72
  */
73
  private function activate_actions() {
74
  // Init
77
  // Router
78
  add_action( 'admin_init', array( $this, 'router' ) );
79
 
80
+ // Setup folders
81
+ add_action( 'admin_init', array( $this, 'setup_folders' ) );
82
+
83
  // Admin header
84
  add_action( 'admin_head', array( $this, 'admin_head' ) );
85
 
 
 
 
86
  // All in One WP Migration
87
  add_action( 'plugins_loaded', array( $this, 'ai1wm_loaded' ), 10 );
88
 
106
 
107
  // Enqueue updater scripts and styles
108
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_updater_scripts_and_styles' ), 5 );
 
 
109
  }
110
 
111
  /**
112
  * Register listeners for filters
113
  *
114
+ * @return void
115
  */
116
  private function activate_filters() {
117
+ // Add links to plugin list page
118
  add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
119
 
120
  // Add custom schedules
121
  add_filter( 'cron_schedules', array( $this, 'add_cron_schedules' ), 9999 );
 
 
122
  }
123
 
124
  /**
130
  // Add export commands
131
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Init::execute', 5 );
132
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Compatibility::execute', 5 );
 
 
 
 
 
 
133
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Archive::execute', 10 );
134
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Config::execute', 50 );
135
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Config_File::execute', 60 );
143
  // Add import commands
144
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Upload::execute', 5 );
145
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Compatibility::execute', 10 );
 
 
 
 
 
 
146
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Validate::execute', 50 );
147
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Confirm::execute', 100 );
148
  add_filter( 'ai1wm_import', 'Ai1wm_Import_Blogs::execute', 150 );
190
  // Add automatic plugins update
191
  add_action( 'wp_maybe_auto_update', 'Ai1wm_Updater_Controller::check_for_updates' );
192
 
193
+ // Add HTTP export headers
194
+ add_filter( 'ai1wm_http_export_headers', 'Ai1wm_Export_Controller::http_export_headers' );
195
+
196
+ // Add HTTP import headers
197
+ add_filter( 'ai1wm_http_import_headers', 'Ai1wm_Import_Controller::http_import_headers' );
198
+
199
  // Add chunk size limit
200
  add_filter( 'ai1wm_max_chunk_size', 'Ai1wm_Import_Controller::max_chunk_size' );
201
 
212
  add_filter( 'plugin_row_meta', 'Ai1wm_Updater_Controller::plugin_row_meta', 10, 2 );
213
  }
214
 
215
+ /**
216
+ * Create folders and files needed for plugin operation, if they don't exist
217
+ *
218
+ * @return void
219
+ */
220
+ public function setup_folders() {
221
+ // Check if storage folder is created
222
+ if ( ! is_dir( AI1WM_STORAGE_PATH ) ) {
223
+ $this->create_storage_folder( AI1WM_STORAGE_PATH );
224
+ }
225
+
226
+ // Check if backups folder is created
227
+ if ( ! is_dir( AI1WM_BACKUPS_PATH ) ) {
228
+ $this->create_backups_folder( AI1WM_BACKUPS_PATH );
229
+ }
230
+
231
+ // Check if index.php is created in storage folder
232
+ if ( ! is_file( AI1WM_STORAGE_INDEX ) ) {
233
+ $this->create_storage_index( AI1WM_STORAGE_INDEX );
234
+ }
235
+
236
+ // Check if index.php is created in backups folder
237
+ if ( ! is_file( AI1WM_BACKUPS_INDEX ) ) {
238
+ $this->create_backups_index( AI1WM_BACKUPS_INDEX );
239
+ }
240
+
241
+ // Check if .htaccess is created in backups folder
242
+ if ( ! is_file( AI1WM_BACKUPS_HTACCESS ) ) {
243
+ $this->create_backups_htaccess( AI1WM_BACKUPS_HTACCESS );
244
+ }
245
+
246
+ // Check if web.config is created in backups folder
247
+ if ( ! is_file( AI1WM_BACKUPS_WEBCONFIG ) ) {
248
+ $this->create_backups_webconfig( AI1WM_BACKUPS_WEBCONFIG );
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Create storage folder
254
+ *
255
+ * @param string Path to folder
256
+ * @return void
257
+ */
258
+ public function create_storage_folder( $path ) {
259
+ if ( ! Ai1wm_Directory::create( $path ) ) {
260
+ if ( is_multisite() ) {
261
+ return add_action( 'network_admin_notices', array( $this, 'storage_path_notice' ) );
262
+ } else {
263
+ return add_action( 'admin_notices', array( $this, 'storage_path_notice' ) );
264
+ }
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Create backups folder
270
+ *
271
+ * @param string Path to folder
272
+ * @return void
273
+ */
274
+ public function create_backups_folder( $path ) {
275
+ if ( ! Ai1wm_Directory::create( $path ) ) {
276
+ if ( is_multisite() ) {
277
+ return add_action( 'network_admin_notices', array( $this, 'backups_path_notice' ) );
278
+ } else {
279
+ return add_action( 'admin_notices', array( $this, 'backups_path_notice' ) );
280
+ }
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Create storage index.php file
286
+ *
287
+ * @param string Path to file
288
+ * @return void
289
+ */
290
+ public function create_storage_index( $path ) {
291
+ if ( ! Ai1wm_File_Index::create( $path ) ) {
292
+ if ( is_multisite() ) {
293
+ return add_action( 'network_admin_notices', array( $this, 'storage_index_notice' ) );
294
+ } else {
295
+ return add_action( 'admin_notices', array( $this, 'storage_index_notice' ) );
296
+ }
297
+ }
298
+ }
299
+
300
+ /**
301
+ * Create backups .htaccess file
302
+ *
303
+ * @param string Path to file
304
+ * @return void
305
+ */
306
+ public function create_backups_htaccess( $path ) {
307
+ if ( ! Ai1wm_File_Htaccess::create( $path ) ) {
308
+ if ( is_multisite() ) {
309
+ return add_action( 'network_admin_notices', array( $this, 'backups_htaccess_notice' ) );
310
+ } else {
311
+ return add_action( 'admin_notices', array( $this, 'backups_htaccess_notice' ) );
312
+ }
313
+ }
314
+ }
315
+
316
+ /**
317
+ * Create backups web.config file
318
+ *
319
+ * @param string Path to file
320
+ * @return void
321
+ */
322
+ public function create_backups_webconfig( $path ) {
323
+ if ( ! Ai1wm_File_Webconfig::create( $path ) ) {
324
+ if ( is_multisite() ) {
325
+ return add_action( 'network_admin_notices', array( $this, 'backups_webconfig_notice' ) );
326
+ } else {
327
+ return add_action( 'admin_notices', array( $this, 'backups_webconfig_notice' ) );
328
+ }
329
+ }
330
+ }
331
+
332
+ /**
333
+ * Create backups index.php file
334
+ *
335
+ * @param string Path to file
336
+ * @return void
337
+ */
338
+ public function create_backups_index( $path ) {
339
+ if ( ! Ai1wm_File_Index::create( $path ) ) {
340
+ if ( is_multisite() ) {
341
+ return add_action( 'network_admin_notices', array( $this, 'backups_index_notice' ) );
342
+ } else {
343
+ return add_action( 'admin_notices', array( $this, 'backups_index_notice' ) );
344
+ }
345
+ }
346
+ }
347
+
348
+ /**
349
+ * If the "noabort" environment variable has been set,
350
+ * the script will continue to run even though the connection has been broken
351
+ *
352
+ * @return void
353
+ */
354
+ public function create_litespeed_htaccess( $path ) {
355
+ if ( ! Ai1wm_File_Htaccess::litespeed( $path ) ) {
356
+ if ( is_multisite() ) {
357
+ return add_action( 'network_admin_notices', array( $this, 'wordpress_htaccess_notice' ) );
358
+ } else {
359
+ return add_action( 'admin_notices', array( $this, 'wordpress_htaccess_notice' ) );
360
+ }
361
+ }
362
+ }
363
+
364
  /**
365
  * Display multisite notice
366
  *
425
  }
426
 
427
  /**
428
+ * Display notice for .htaccess file in WordPress directory
429
  *
430
+ * @return void
431
  */
432
+ public function wordpress_htaccess_notice() {
433
+ Ai1wm_Template::render( 'main/wordpress-htaccess-notice' );
 
 
 
 
434
  }
435
 
436
  /**
437
+ * Add links to plugin list page
438
  *
439
+ * @return array
440
  */
441
+ public function plugin_row_meta( $links, $file ) {
442
+ if ( $file == AI1WM_PLUGIN_BASENAME ) {
443
+ $links[] = Ai1wm_Template::get_content( 'main/get-support' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  }
445
 
446
+ return $links;
 
 
 
 
 
 
 
 
 
447
  }
448
 
449
  /**
589
  ),
590
  'secret_key' => get_option( AI1WM_SECRET_KEY ),
591
  ) );
592
+
593
+ wp_localize_script( 'ai1wm_export', 'ai1wm_locale', array(
594
+ 'stop_exporting_your_website' => __( 'You are about to stop exporting your website, are you sure?', AI1WM_PLUGIN_NAME ),
595
+ 'preparing_to_export' => __( 'Preparing to export...', AI1WM_PLUGIN_NAME ),
596
+ 'unable_to_export' => __( 'Unable to export', AI1WM_PLUGIN_NAME ),
597
+ 'unable_to_start_the_export' => __( 'Unable to start the export. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
598
+ 'unable_to_run_the_export' => __( 'Unable to run the export. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
599
+ 'unable_to_stop_the_export' => __( 'Unable to stop the export. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
600
+ 'please_wait_stopping_the_export' => __( 'Please wait, stopping the export...', AI1WM_PLUGIN_NAME ),
601
+ 'close_export' => __( 'Close', AI1WM_PLUGIN_NAME ),
602
+ 'stop_export' => __( 'Stop export', AI1WM_PLUGIN_NAME ),
603
+ 'leave_feedback' => __( 'Leave plugin developers any feedback here', AI1WM_PLUGIN_NAME ),
604
+ 'how_may_we_help_you' => __( 'How may we help you?', AI1WM_PLUGIN_NAME ),
605
+ 'thanks_for_submitting_your_feedback' => __( 'Thanks for submitting your feedback!', AI1WM_PLUGIN_NAME ),
606
+ 'thanks_for_submitting_your_request' => __( 'Thanks for submitting your request!', AI1WM_PLUGIN_NAME ),
607
+ ) );
608
  }
609
 
610
  /**
665
  'secret_key' => get_option( AI1WM_SECRET_KEY ),
666
  ),
667
  'filters' => array(
668
+ 'ai1wm_archive_extension' => array( 'wpress' ),
669
  'ai1wm_archive_size' => apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ),
670
  ),
671
  ) );
672
 
673
  wp_localize_script( 'ai1wm_import', 'ai1wm_import', array(
674
+ 'ajax' => array(
675
  'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_import' ) ),
676
  ),
677
+ 'status' => array(
678
  'url' => wp_make_link_relative( add_query_arg( array( 'secret_key' => get_option( AI1WM_SECRET_KEY ) ), admin_url( 'admin-ajax.php?action=ai1wm_status' ) ) ),
679
  ),
680
+ 'secret_key' => get_option( AI1WM_SECRET_KEY ),
681
+ ) );
682
+
683
+ wp_localize_script( 'ai1wm_import', 'ai1wm_locale', array(
684
+ 'stop_importing_your_website' => __( 'You are about to stop importing your website, are you sure?', AI1WM_PLUGIN_NAME ),
685
+ 'preparing_to_import' => __( 'Preparing to import...', AI1WM_PLUGIN_NAME ),
686
+ 'unable_to_import' => __( 'Unable to import', AI1WM_PLUGIN_NAME ),
687
+ 'unable_to_start_the_import' => __( 'Unable to start the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
688
+ 'unable_to_confirm_the_import' => __( 'Unable to confirm the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
689
+ 'unable_to_prepare_blogs_on_import' => __( 'Unable to prepare blogs on import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
690
+ 'unable_to_stop_the_import' => __( 'Unable to stop the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
691
+ 'please_wait_stopping_the_export' => __( 'Please wait, stopping the import...', AI1WM_PLUGIN_NAME ),
692
+ 'close_import' => __( 'Close', AI1WM_PLUGIN_NAME ),
693
+ 'stop_import' => __( 'Stop import', AI1WM_PLUGIN_NAME ),
694
+ 'confirm_import' => __( 'Proceed', AI1WM_PLUGIN_NAME ),
695
+ 'continue_import' => __( 'Continue', AI1WM_PLUGIN_NAME ),
696
+ 'please_do_not_close_this_browser' => __( 'Please do not close this browser window or your import will fail', AI1WM_PLUGIN_NAME ),
697
+ 'leave_feedback' => __( 'Leave plugin developers any feedback here', AI1WM_PLUGIN_NAME ),
698
+ 'how_may_we_help_you' => __( 'How may we help you?', AI1WM_PLUGIN_NAME ),
699
+ 'thanks_for_submitting_your_feedback' => __( 'Thanks for submitting your feedback!', AI1WM_PLUGIN_NAME ),
700
+ 'thanks_for_submitting_your_request' => __( 'Thanks for submitting your request!', AI1WM_PLUGIN_NAME ),
701
+ '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 ),
702
+ 'invalid_archive_extension' => __(
703
+ 'The file type that you have tried to upload is not compatible with this plugin. ' .
704
+ 'Please ensure that your file is a <strong>.wpress</strong> file that was created with the All-in-One WP migration plugin. ' .
705
+ '<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
706
+ AI1WM_PLUGIN_NAME
707
+ ),
708
+ 'invalid_archive_size' => sprintf(
709
  __(
710
  'The file that you are trying to import is over the maximum upload file size limit of <strong>%s</strong>.<br />' .
711
  'You can remove this restriction by purchasing our ' .
714
  ),
715
  size_format( apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ) )
716
  ),
 
 
 
 
 
 
717
  ) );
718
  }
719
 
782
  ),
783
  'secret_key' => get_option( AI1WM_SECRET_KEY ),
784
  ) );
785
+
786
+ wp_localize_script( 'ai1wm_backups', 'ai1wm_locale', array(
787
+ 'stop_importing_your_website' => __( 'You are about to stop importing your website, are you sure?', AI1WM_PLUGIN_NAME ),
788
+ 'preparing_to_import' => __( 'Preparing to import...', AI1WM_PLUGIN_NAME ),
789
+ 'unable_to_import' => __( 'Unable to import', AI1WM_PLUGIN_NAME ),
790
+ 'unable_to_start_the_import' => __( 'Unable to start the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
791
+ 'unable_to_confirm_the_import' => __( 'Unable to confirm the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
792
+ 'unable_to_prepare_blogs_on_import' => __( 'Unable to prepare blogs on import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
793
+ 'unable_to_stop_the_import' => __( 'Unable to stop the import. Refresh the page and try again', AI1WM_PLUGIN_NAME ),
794
+ 'please_wait_stopping_the_export' => __( 'Please wait, stopping the import...', AI1WM_PLUGIN_NAME ),
795
+ 'close_import' => __( 'Close', AI1WM_PLUGIN_NAME ),
796
+ 'stop_import' => __( 'Stop import', AI1WM_PLUGIN_NAME ),
797
+ 'confirm_import' => __( 'Proceed', AI1WM_PLUGIN_NAME ),
798
+ 'continue_import' => __( 'Continue', AI1WM_PLUGIN_NAME ),
799
+ 'please_do_not_close_this_browser' => __( 'Please do not close this browser window or your import will fail', AI1WM_PLUGIN_NAME ),
800
+ 'leave_feedback' => __( 'Leave plugin developers any feedback here', AI1WM_PLUGIN_NAME ),
801
+ 'how_may_we_help_you' => __( 'How may we help you?', AI1WM_PLUGIN_NAME ),
802
+ 'thanks_for_submitting_your_feedback' => __( 'Thanks for submitting your feedback!', AI1WM_PLUGIN_NAME ),
803
+ 'thanks_for_submitting_your_request' => __( 'Thanks for submitting your request!', AI1WM_PLUGIN_NAME ),
804
+ 'want_to_delete_this_file' => __( 'Are you sure you want to delete this file?', AI1WM_PLUGIN_NAME ),
805
+ ) );
806
  }
807
 
808
  /**
839
  'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_updater' ) ),
840
  ),
841
  ) );
842
+
843
+ wp_localize_script( 'ai1wm_backups', 'ai1wm_locale', array(
844
+ 'check_for_updates' => __( 'Check for updates', AI1WM_PLUGIN_NAME ),
845
+ 'invalid_purchase_id' => __( 'Your purchase ID is invalid, please <a href="mailto:support@servmask.com">contact us</a>', AI1WM_PLUGIN_NAME ),
846
+ ) );
847
  }
848
 
849
  /**
899
  add_action( 'wp_ajax_nopriv_ai1wm_export', 'Ai1wm_Export_Controller::export' );
900
  add_action( 'wp_ajax_nopriv_ai1wm_import', 'Ai1wm_Import_Controller::import' );
901
  add_action( 'wp_ajax_nopriv_ai1wm_status', 'Ai1wm_Status_Controller::status' );
 
902
  add_action( 'wp_ajax_nopriv_ai1wm_backups', 'Ai1wm_Backups_Controller::delete' );
903
  add_action( 'wp_ajax_nopriv_ai1wm_feedback', 'Ai1wm_Feedback_Controller::feedback' );
904
  add_action( 'wp_ajax_nopriv_ai1wm_report', 'Ai1wm_Report_Controller::report' );
907
  add_action( 'wp_ajax_ai1wm_export', 'Ai1wm_Export_Controller::export' );
908
  add_action( 'wp_ajax_ai1wm_import', 'Ai1wm_Import_Controller::import' );
909
  add_action( 'wp_ajax_ai1wm_status', 'Ai1wm_Status_Controller::status' );
 
910
  add_action( 'wp_ajax_ai1wm_backups', 'Ai1wm_Backups_Controller::delete' );
911
  add_action( 'wp_ajax_ai1wm_feedback', 'Ai1wm_Feedback_Controller::feedback' );
912
  add_action( 'wp_ajax_ai1wm_report', 'Ai1wm_Report_Controller::report' );
lib/controller/class-ai1wm-resolve-controller.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (C) 2014-2018 ServMask Inc.
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
- * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
20
- * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
21
- * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
22
- * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
- * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
- */
25
-
26
- class Ai1wm_Resolve_Controller {
27
-
28
- public static function resolve( $params = array() ) {
29
-
30
- // Set params
31
- if ( empty( $params ) ) {
32
- $params = stripslashes_deep( $_GET );
33
- }
34
-
35
- // Set secret key
36
- $secret_key = null;
37
- if ( isset( $params['secret_key'] ) ) {
38
- $secret_key = trim( $params['secret_key'] );
39
- }
40
-
41
- try {
42
- // Ensure that unauthorized people cannot access resolve action
43
- ai1wm_verify_secret_key( $secret_key );
44
- } catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) {
45
- exit;
46
- }
47
-
48
- // Set IP address
49
- if ( isset( $params['url_ip'] ) && ( $ip = $params['url_ip'] ) ) {
50
- update_option( AI1WM_URL_IP, $ip );
51
- }
52
-
53
- // Set adapter
54
- if ( isset( $params['url_adapter'] ) && ( $adapter = $params['url_adapter'] ) ) {
55
- if ( $adapter === 'curl' ) {
56
- update_option( AI1WM_URL_ADAPTER, 'curl' );
57
- } else {
58
- update_option( AI1WM_URL_ADAPTER, 'stream' );
59
- }
60
- }
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/model/class-ai1wm-backups.php CHANGED
@@ -36,13 +36,13 @@ class Ai1wm_Backups {
36
  // Iterate over directory
37
  $iterator = new Ai1wm_Recursive_Directory_Iterator( AI1WM_BACKUPS_PATH );
38
 
 
 
 
39
  // Recursively iterate over directory
40
- $iterator = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::CHILD_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD );
41
- $iterator->setMaxDepth( 3 );
42
 
43
  // Get backup files
44
- $iterator = new Ai1wm_Extension_Filter( $iterator, array( 'wpress', 'bin' ) );
45
-
46
  foreach ( $iterator as $item ) {
47
  try {
48
  if ( ai1wm_is_filesize_supported( $item->getPathname() ) ) {
36
  // Iterate over directory
37
  $iterator = new Ai1wm_Recursive_Directory_Iterator( AI1WM_BACKUPS_PATH );
38
 
39
+ // Filter by extensions
40
+ $iterator = new Ai1wm_Recursive_Extension_Filter( $iterator, array( 'wpress' ) );
41
+
42
  // Recursively iterate over directory
43
+ $iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
 
44
 
45
  // Get backup files
 
 
46
  foreach ( $iterator as $item ) {
47
  try {
48
  if ( ai1wm_is_filesize_supported( $item->getPathname() ) ) {
lib/model/class-ai1wm-extensions.php CHANGED
@@ -40,7 +40,7 @@ class Ai1wm_Extensions {
40
  'about' => AI1WMZE_PLUGIN_ABOUT,
41
  'basename' => AI1WMZE_PLUGIN_BASENAME,
42
  'version' => AI1WMZE_VERSION,
43
- 'requires' => '1.0',
44
  'short' => AI1WMZE_PLUGIN_SHORT,
45
  );
46
  }
@@ -52,7 +52,7 @@ class Ai1wm_Extensions {
52
  'about' => AI1WMAE_PLUGIN_ABOUT,
53
  'basename' => AI1WMAE_PLUGIN_BASENAME,
54
  'version' => AI1WMAE_VERSION,
55
- 'requires' => '1.0',
56
  'short' => AI1WMAE_PLUGIN_SHORT,
57
  );
58
  }
@@ -64,7 +64,7 @@ class Ai1wm_Extensions {
64
  'about' => AI1WMBE_PLUGIN_ABOUT,
65
  'basename' => AI1WMBE_PLUGIN_BASENAME,
66
  'version' => AI1WMBE_VERSION,
67
- 'requires' => '1.10',
68
  'short' => AI1WMBE_PLUGIN_SHORT,
69
  );
70
  }
@@ -76,7 +76,7 @@ class Ai1wm_Extensions {
76
  'about' => AI1WMIE_PLUGIN_ABOUT,
77
  'basename' => AI1WMIE_PLUGIN_BASENAME,
78
  'version' => AI1WMIE_VERSION,
79
- 'requires' => '1.1',
80
  'short' => AI1WMIE_PLUGIN_SHORT,
81
  );
82
  }
@@ -88,7 +88,7 @@ class Ai1wm_Extensions {
88
  'about' => AI1WMDE_PLUGIN_ABOUT,
89
  'basename' => AI1WMDE_PLUGIN_BASENAME,
90
  'version' => AI1WMDE_VERSION,
91
- 'requires' => '3.29',
92
  'short' => AI1WMDE_PLUGIN_SHORT,
93
  );
94
  }
@@ -100,7 +100,7 @@ class Ai1wm_Extensions {
100
  'about' => AI1WMFE_PLUGIN_ABOUT,
101
  'basename' => AI1WMFE_PLUGIN_BASENAME,
102
  'version' => AI1WMFE_VERSION,
103
- 'requires' => '2.34',
104
  'short' => AI1WMFE_PLUGIN_SHORT,
105
  );
106
  }
@@ -124,7 +124,7 @@ class Ai1wm_Extensions {
124
  'about' => AI1WMGE_PLUGIN_ABOUT,
125
  'basename' => AI1WMGE_PLUGIN_BASENAME,
126
  'version' => AI1WMGE_VERSION,
127
- 'requires' => '2.31',
128
  'short' => AI1WMGE_PLUGIN_SHORT,
129
  );
130
  }
@@ -136,7 +136,7 @@ class Ai1wm_Extensions {
136
  'about' => AI1WMEE_PLUGIN_ABOUT,
137
  'basename' => AI1WMEE_PLUGIN_BASENAME,
138
  'version' => AI1WMEE_VERSION,
139
- 'requires' => '1.7',
140
  'short' => AI1WMEE_PLUGIN_SHORT,
141
  );
142
  }
@@ -148,7 +148,7 @@ class Ai1wm_Extensions {
148
  'about' => AI1WMME_PLUGIN_ABOUT,
149
  'basename' => AI1WMME_PLUGIN_BASENAME,
150
  'version' => AI1WMME_VERSION,
151
- 'requires' => '3.52',
152
  'short' => AI1WMME_PLUGIN_SHORT,
153
  );
154
  }
@@ -160,7 +160,7 @@ class Ai1wm_Extensions {
160
  'about' => AI1WMOE_PLUGIN_ABOUT,
161
  'basename' => AI1WMOE_PLUGIN_BASENAME,
162
  'version' => AI1WMOE_VERSION,
163
- 'requires' => '1.20',
164
  'short' => AI1WMOE_PLUGIN_SHORT,
165
  );
166
  }
@@ -172,7 +172,7 @@ class Ai1wm_Extensions {
172
  'about' => AI1WMSE_PLUGIN_ABOUT,
173
  'basename' => AI1WMSE_PLUGIN_BASENAME,
174
  'version' => AI1WMSE_VERSION,
175
- 'requires' => '3.23',
176
  'short' => AI1WMSE_PLUGIN_SHORT,
177
  );
178
  }
@@ -184,7 +184,7 @@ class Ai1wm_Extensions {
184
  'about' => AI1WMUE_PLUGIN_ABOUT,
185
  'basename' => AI1WMUE_PLUGIN_BASENAME,
186
  'version' => AI1WMUE_VERSION,
187
- 'requires' => '2.16',
188
  'short' => AI1WMUE_PLUGIN_SHORT,
189
  );
190
  }
@@ -196,7 +196,7 @@ class Ai1wm_Extensions {
196
  'about' => AI1WMLE_PLUGIN_ABOUT,
197
  'basename' => AI1WMLE_PLUGIN_BASENAME,
198
  'version' => AI1WMLE_VERSION,
199
- 'requires' => '2.23',
200
  'short' => AI1WMLE_PLUGIN_SHORT,
201
  );
202
  }
40
  'about' => AI1WMZE_PLUGIN_ABOUT,
41
  'basename' => AI1WMZE_PLUGIN_BASENAME,
42
  'version' => AI1WMZE_VERSION,
43
+ 'requires' => '1.1',
44
  'short' => AI1WMZE_PLUGIN_SHORT,
45
  );
46
  }
52
  'about' => AI1WMAE_PLUGIN_ABOUT,
53
  'basename' => AI1WMAE_PLUGIN_BASENAME,
54
  'version' => AI1WMAE_VERSION,
55
+ 'requires' => '1.3',
56
  'short' => AI1WMAE_PLUGIN_SHORT,
57
  );
58
  }
64
  'about' => AI1WMBE_PLUGIN_ABOUT,
65
  'basename' => AI1WMBE_PLUGIN_BASENAME,
66
  'version' => AI1WMBE_VERSION,
67
+ 'requires' => '1.13',
68
  'short' => AI1WMBE_PLUGIN_SHORT,
69
  );
70
  }
76
  'about' => AI1WMIE_PLUGIN_ABOUT,
77
  'basename' => AI1WMIE_PLUGIN_BASENAME,
78
  'version' => AI1WMIE_VERSION,
79
+ 'requires' => '1.6',
80
  'short' => AI1WMIE_PLUGIN_SHORT,
81
  );
82
  }
88
  'about' => AI1WMDE_PLUGIN_ABOUT,
89
  'basename' => AI1WMDE_PLUGIN_BASENAME,
90
  'version' => AI1WMDE_VERSION,
91
+ 'requires' => '3.32',
92
  'short' => AI1WMDE_PLUGIN_SHORT,
93
  );
94
  }
100
  'about' => AI1WMFE_PLUGIN_ABOUT,
101
  'basename' => AI1WMFE_PLUGIN_BASENAME,
102
  'version' => AI1WMFE_VERSION,
103
+ 'requires' => '2.37',
104
  'short' => AI1WMFE_PLUGIN_SHORT,
105
  );
106
  }
124
  'about' => AI1WMGE_PLUGIN_ABOUT,
125
  'basename' => AI1WMGE_PLUGIN_BASENAME,
126
  'version' => AI1WMGE_VERSION,
127
+ 'requires' => '2.36',
128
  'short' => AI1WMGE_PLUGIN_SHORT,
129
  );
130
  }
136
  'about' => AI1WMEE_PLUGIN_ABOUT,
137
  'basename' => AI1WMEE_PLUGIN_BASENAME,
138
  'version' => AI1WMEE_VERSION,
139
+ 'requires' => '1.10',
140
  'short' => AI1WMEE_PLUGIN_SHORT,
141
  );
142
  }
148
  'about' => AI1WMME_PLUGIN_ABOUT,
149
  'basename' => AI1WMME_PLUGIN_BASENAME,
150
  'version' => AI1WMME_VERSION,
151
+ 'requires' => '3.56',
152
  'short' => AI1WMME_PLUGIN_SHORT,
153
  );
154
  }
160
  'about' => AI1WMOE_PLUGIN_ABOUT,
161
  'basename' => AI1WMOE_PLUGIN_BASENAME,
162
  'version' => AI1WMOE_VERSION,
163
+ 'requires' => '1.23',
164
  'short' => AI1WMOE_PLUGIN_SHORT,
165
  );
166
  }
172
  'about' => AI1WMSE_PLUGIN_ABOUT,
173
  'basename' => AI1WMSE_PLUGIN_BASENAME,
174
  'version' => AI1WMSE_VERSION,
175
+ 'requires' => '3.27',
176
  'short' => AI1WMSE_PLUGIN_SHORT,
177
  );
178
  }
184
  'about' => AI1WMUE_PLUGIN_ABOUT,
185
  'basename' => AI1WMUE_PLUGIN_BASENAME,
186
  'version' => AI1WMUE_VERSION,
187
+ 'requires' => '2.18',
188
  'short' => AI1WMUE_PLUGIN_SHORT,
189
  );
190
  }
196
  'about' => AI1WMLE_PLUGIN_ABOUT,
197
  'basename' => AI1WMLE_PLUGIN_BASENAME,
198
  'version' => AI1WMLE_VERSION,
199
+ 'requires' => '2.27',
200
  'short' => AI1WMLE_PLUGIN_SHORT,
201
  );
202
  }
lib/model/class-ai1wm-http.php DELETED
@@ -1,154 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (C) 2014-2018 ServMask Inc.
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
- * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
20
- * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
21
- * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
22
- * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
- * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
- */
25
-
26
- class Ai1wm_Http {
27
-
28
- public static function get( $url, $params = array(), Ai1wm_Http_Abstract $http = null ) {
29
-
30
- // Get IP address
31
- $ip = get_option( AI1WM_URL_IP );
32
-
33
- // Get adapter
34
- $adapter = get_option( AI1WM_URL_ADAPTER );
35
-
36
- // Get host
37
- $host = parse_url( $url, PHP_URL_HOST );
38
-
39
- // Get port
40
- $port = parse_url( $url, PHP_URL_PORT );
41
-
42
- // Set HTTP client
43
- if ( empty( $http ) ) {
44
- $http = Ai1wm_Http_Factory::create( $adapter );
45
- }
46
-
47
- // Set HTTP host
48
- if ( empty( $port ) ) {
49
- $http->set_header( 'Host', $host );
50
- } else {
51
- $http->set_header( 'Host', "{$host}:{$port}" );
52
- }
53
-
54
- // Set HTTP authorization
55
- if ( ( $user = get_option( AI1WM_AUTH_USER ) ) && ( $password = get_option( AI1WM_AUTH_PASSWORD ) ) ) {
56
- if ( ( $hash = base64_encode( "{$user}:{$password}" ) ) ) {
57
- $http->set_header( 'Authorization', "Basic {$hash}" );
58
- }
59
- }
60
-
61
- $blocking = false;
62
-
63
- // Run non-blocking HTTP request
64
- $http->get( add_query_arg( ai1wm_urlencode( $params ), str_replace( "//{$host}", "//{$ip}", $url ) ), $blocking );
65
- }
66
-
67
- public static function resolve( $url, $params = array(), Ai1wm_Http_Abstract $http = null ) {
68
-
69
- // Reset IP address and adapter
70
- delete_option( AI1WM_URL_IP );
71
- delete_option( AI1WM_URL_ADAPTER );
72
-
73
- // Set secret
74
- $secret_key = get_option( AI1WM_SECRET_KEY );
75
-
76
- // Set host
77
- $host = parse_url( $url, PHP_URL_HOST );
78
-
79
- // Get port
80
- $port = parse_url( $url, PHP_URL_PORT );
81
-
82
- // Set server IP address
83
- if ( ! empty( $_SERVER['SERVER_ADDR'] ) ) {
84
- $server = $_SERVER['SERVER_ADDR'];
85
- } elseif ( ! empty( $_SERVER['LOCAL_ADDR'] ) ) {
86
- $server = $_SERVER['LOCAL_ADDR'];
87
- } else {
88
- $server = '127.0.0.1';
89
- }
90
-
91
- // Set local IP address
92
- $local = gethostbyname( $host );
93
-
94
- // HTTP resolve
95
- foreach ( array( 'stream', 'curl' ) as $adapter ) {
96
- foreach ( array( $server, $local, $host ) as $ip ) {
97
-
98
- // Add IPv6 support
99
- if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) {
100
- $ip = "[$ip]";
101
- }
102
-
103
- // Set HTTP params
104
- $params = array_merge( $params, array(
105
- 'secret_key' => $secret_key,
106
- 'url_ip' => $ip,
107
- 'url_adapter' => $adapter,
108
- ) );
109
-
110
- // Set HTTP client
111
- if ( empty( $http ) ) {
112
- $http = Ai1wm_Http_Factory::create( $adapter );
113
- }
114
-
115
- // Set HTTP host
116
- if ( empty( $port ) ) {
117
- $http->set_header( 'Host', $host );
118
- } else {
119
- $http->set_header( 'Host', "{$host}:{$port}" );
120
- }
121
-
122
- // Set HTTP authorization
123
- if ( ( $user = get_option( AI1WM_AUTH_USER ) ) && ( $password = get_option( AI1WM_AUTH_PASSWORD ) ) ) {
124
- if ( ( $hash = base64_encode( "{$user}:{$password}" ) ) ) {
125
- $http->set_header( 'Authorization', "Basic {$hash}" );
126
- }
127
- }
128
-
129
- $blocking = true;
130
-
131
- // Run blocking HTTP request
132
- $http->get( add_query_arg( ai1wm_urlencode( $params ), str_replace( "//{$host}", "//{$ip}", $url ) ), $blocking );
133
-
134
- // Flush WP cache
135
- ai1wm_cache_flush();
136
-
137
- // Is valid adapter?
138
- if ( get_option( AI1WM_URL_IP ) && get_option( AI1WM_URL_ADAPTER ) ) {
139
- return;
140
- }
141
-
142
- // Reset HTTP client
143
- $http = null;
144
- }
145
- }
146
-
147
- // No connection
148
- throw new Ai1wm_Http_Exception( __(
149
- 'There was a problem while reaching your server.<br />' .
150
- 'Contact <a href="mailto:support@servmask.com">support@servmask.com</a> for assistance.',
151
- AI1WM_PLUGIN_NAME
152
- ) );
153
- }
154
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/model/export/class-ai1wm-export-database.php CHANGED
@@ -67,24 +67,24 @@ class Ai1wm_Export_Database {
67
  $mysql = new Ai1wm_Database_Mysqli( $wpdb );
68
  }
69
 
70
- // Spam comments
71
  if ( isset( $params['options']['no_spam_comments'] ) ) {
72
  $mysql->set_table_where_clauses( ai1wm_table_prefix() . 'comments', array( "`comment_approved` != 'spam'" ) )
73
  ->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' ) ) );
74
  }
75
 
76
- // Post revisions
77
  if ( isset( $params['options']['no_revisions'] ) ) {
78
  $mysql->set_table_where_clauses( ai1wm_table_prefix() . 'posts', array( "`post_type` != 'revision'" ) );
79
  }
80
 
81
- $old_table_prefixes = array();
82
- $new_table_prefixes = array();
83
 
84
  // Set table prefixes
85
  if ( ai1wm_table_prefix() ) {
86
- $old_table_prefixes[] = ai1wm_table_prefix();
87
- $new_table_prefixes[] = ai1wm_servmask_prefix();
88
  } else {
89
  // Set table prefixes based on table name
90
  foreach ( $mysql->get_tables() as $table_name ) {
@@ -92,10 +92,16 @@ class Ai1wm_Export_Database {
92
  $new_table_prefixes[] = ai1wm_servmask_prefix() . $table_name;
93
  }
94
 
95
- // Set table prefixes based on user meta
96
- foreach ( array( 'capabilities', 'user_level', 'user_roles', 'dashboard_quick_press_last_post_id', 'user-settings', 'user-settings-time' ) as $user_meta ) {
97
- $old_table_prefixes[] = $user_meta;
98
- $new_table_prefixes[] = ai1wm_servmask_prefix() . $user_meta;
 
 
 
 
 
 
99
  }
100
  }
101
 
@@ -114,11 +120,13 @@ class Ai1wm_Export_Database {
114
  // Set database options
115
  $mysql->set_old_table_prefixes( $old_table_prefixes )
116
  ->set_new_table_prefixes( $new_table_prefixes )
 
 
117
  ->set_include_table_prefixes( $include_table_prefixes )
118
  ->set_exclude_table_prefixes( $exclude_table_prefixes );
119
 
120
- // Exclude table options
121
- $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 ) ) );
122
 
123
  // Replace table prefix on columns
124
  $mysql->set_table_prefix_columns( ai1wm_table_prefix() . 'options', array( 'option_name' ) )
67
  $mysql = new Ai1wm_Database_Mysqli( $wpdb );
68
  }
69
 
70
+ // Exclude spam comments
71
  if ( isset( $params['options']['no_spam_comments'] ) ) {
72
  $mysql->set_table_where_clauses( ai1wm_table_prefix() . 'comments', array( "`comment_approved` != 'spam'" ) )
73
  ->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' ) ) );
74
  }
75
 
76
+ // Exclude post revisions
77
  if ( isset( $params['options']['no_revisions'] ) ) {
78
  $mysql->set_table_where_clauses( ai1wm_table_prefix() . 'posts', array( "`post_type` != 'revision'" ) );
79
  }
80
 
81
+ $old_table_prefixes = $old_column_prefixes = array();
82
+ $new_table_prefixes = $new_column_prefixes = array();
83
 
84
  // Set table prefixes
85
  if ( ai1wm_table_prefix() ) {
86
+ $old_table_prefixes[] = $old_column_prefixes[] = ai1wm_table_prefix();
87
+ $new_table_prefixes[] = $new_column_prefixes[] = ai1wm_servmask_prefix();
88
  } else {
89
  // Set table prefixes based on table name
90
  foreach ( $mysql->get_tables() as $table_name ) {
92
  $new_table_prefixes[] = ai1wm_servmask_prefix() . $table_name;
93
  }
94
 
95
+ // Set table prefixes based on column name
96
+ foreach ( array( 'user_roles' ) as $option_name ) {
97
+ $old_column_prefixes[] = $option_name;
98
+ $new_column_prefixes[] = ai1wm_servmask_prefix() . $option_name;
99
+ }
100
+
101
+ // Set table prefixes based on column name
102
+ foreach ( array( 'capabilities', 'user_level', 'dashboard_quick_press_last_post_id', 'user-settings', 'user-settings-time' ) as $meta_key ) {
103
+ $old_column_prefixes[] = $meta_key;
104
+ $new_column_prefixes[] = ai1wm_servmask_prefix() . $meta_key;
105
  }
106
  }
107
 
120
  // Set database options
121
  $mysql->set_old_table_prefixes( $old_table_prefixes )
122
  ->set_new_table_prefixes( $new_table_prefixes )
123
+ ->set_old_column_prefixes( $old_column_prefixes )
124
+ ->set_new_column_prefixes( $new_column_prefixes )
125
  ->set_include_table_prefixes( $include_table_prefixes )
126
  ->set_exclude_table_prefixes( $exclude_table_prefixes );
127
 
128
+ // Exclude site options
129
+ $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 ) ) );
130
 
131
  // Replace table prefix on columns
132
  $mysql->set_table_prefix_columns( ai1wm_table_prefix() . 'options', array( 'option_name' ) )
lib/model/export/class-ai1wm-export-enumerate.php CHANGED
@@ -105,35 +105,28 @@ class Ai1wm_Export_Enumerate {
105
  // Create map file
106
  $filemap = ai1wm_open( ai1wm_filemap_path( $params ), 'w' );
107
 
108
- try {
 
109
 
110
- // Iterate over content directory
111
- $iterator = new Ai1wm_Recursive_Directory_Iterator( WP_CONTENT_DIR );
112
 
113
- // Exclude new line file names
114
- $iterator = new Ai1wm_Recursive_Newline_Filter( $iterator );
115
 
116
- // Exclude uploads, plugins or themes
117
- $iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_content_from_export', $exclude_filters ) );
118
 
119
- // Recursively iterate over content directory
120
- $iterator = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
 
 
 
121
 
122
- // Write path line
123
- foreach ( $iterator as $item ) {
124
- if ( $item->isFile() ) {
125
- if ( ai1wm_write( $filemap, $iterator->getSubPathName() . PHP_EOL ) ) {
126
- $total_files_count++;
127
-
128
- // Add current file size
129
- $total_files_size += $iterator->getSize();
130
- }
131
  }
132
  }
133
- } catch ( Ai1wm_Quota_Exceeded_Exception $e ) {
134
- throw new Exception( 'Out of disk space.' );
135
- } catch ( Exception $e ) {
136
- // Skip bad file permissions
137
  }
138
 
139
  // Set progress
105
  // Create map file
106
  $filemap = ai1wm_open( ai1wm_filemap_path( $params ), 'w' );
107
 
108
+ // Iterate over content directory
109
+ $iterator = new Ai1wm_Recursive_Directory_Iterator( WP_CONTENT_DIR );
110
 
111
+ // Exclude new line file names
112
+ $iterator = new Ai1wm_Recursive_Newline_Filter( $iterator );
113
 
114
+ // Exclude uploads, plugins or themes
115
+ $iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_content_from_export', $exclude_filters ) );
116
 
117
+ // Recursively iterate over content directory
118
+ $iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
119
 
120
+ // Write path line
121
+ foreach ( $iterator as $item ) {
122
+ if ( $item->isFile() ) {
123
+ if ( ai1wm_write( $filemap, $iterator->getSubPathName() . PHP_EOL ) ) {
124
+ $total_files_count++;
125
 
126
+ // Add current file size
127
+ $total_files_size += $iterator->getSize();
 
 
 
 
 
 
 
128
  }
129
  }
 
 
 
 
130
  }
131
 
132
  // Set progress
lib/model/export/class-ai1wm-export-resolve.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (C) 2014-2018 ServMask Inc.
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
- * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
20
- * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
21
- * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
22
- * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
- * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
- */
25
-
26
- class Ai1wm_Export_Resolve {
27
-
28
- public static function execute( $params ) {
29
-
30
- // Set progress
31
- Ai1wm_Status::info( __( 'Resolving URL address...', AI1WM_PLUGIN_NAME ) );
32
-
33
- // HTTP resolve
34
- Ai1wm_Http::resolve( admin_url( 'admin-ajax.php?action=ai1wm_resolve' ) );
35
-
36
- // Set progress
37
- Ai1wm_Status::info( __( 'Done resolving URL address.', AI1WM_PLUGIN_NAME ) );
38
-
39
- return $params;
40
- }
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/model/http/class-ai1wm-http-abstract.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (C) 2014-2018 ServMask Inc.
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
- * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
20
- * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
21
- * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
22
- * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
- * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
- */
25
-
26
- abstract class Ai1wm_Http_Abstract {
27
-
28
- protected $headers = array(
29
- 'Accept' => '*/*',
30
- 'Accept-Encoding' => '*',
31
- 'Accept-Charset' => '*',
32
- 'Accept-Language' => '*',
33
- 'User-Agent' => 'Mozilla/5.0',
34
- );
35
-
36
- public function __construct() {
37
- // Set user agent
38
- if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
39
- $this->headers['User-Agent'] = $_SERVER['HTTP_USER_AGENT'];
40
- }
41
- }
42
-
43
- public function set_header( $key, $value ) {
44
- $this->headers[ $key ] = $value;
45
-
46
- return $this;
47
- }
48
-
49
- public function get_header( $key ) {
50
- return $this->headers[ $key ];
51
- }
52
-
53
- abstract public function get( $url, $blocking = false );
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/model/http/class-ai1wm-http-curl.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (C) 2014-2018 ServMask Inc.
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
- * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
20
- * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
21
- * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
22
- * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
- * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
- */
25
-
26
- class Ai1wm_Http_Curl extends Ai1wm_Http_Abstract {
27
-
28
- public function get( $url, $blocking = false ) {
29
-
30
- $headers = array();
31
-
32
- // Set headers
33
- foreach ( $this->headers as $key => $value ) {
34
- $headers[] = "{$key}: {$value}";
35
- }
36
-
37
- // Set scheme
38
- $scheme = parse_url( $url, PHP_URL_SCHEME );
39
-
40
- // Set host
41
- $host = parse_url( $url, PHP_URL_HOST );
42
-
43
- // Set port
44
- $port = parse_url( $url, PHP_URL_PORT );
45
-
46
- // Set cURL client
47
- $handle = curl_init();
48
-
49
- // Set cURL options
50
- curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 5 );
51
- curl_setopt( $handle, CURLOPT_TIMEOUT, 5 );
52
- curl_setopt( $handle, CURLOPT_URL, $url );
53
- curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
54
- curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
55
- curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, false );
56
- curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false );
57
- curl_setopt( $handle, CURLOPT_HEADER, false );
58
- curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers );
59
-
60
- // Send data to server
61
- if ( ! curl_exec( $handle ) ) {
62
- if ( $scheme === 'https' ) {
63
- if ( empty( $port ) ) {
64
- curl_setopt( $handle, CURLOPT_URL, str_replace( "https://{$host}", "http://{$host}:443", $url ) );
65
- } else {
66
- curl_setopt( $handle, CURLOPT_URL, str_replace( "https://{$host}:{$port}", "http://{$host}:{$port}", $url ) );
67
- }
68
-
69
- // Re-send data to server
70
- curl_exec( $handle );
71
- }
72
- }
73
-
74
- // Close cURL handle
75
- curl_close( $handle );
76
- }
77
- }