Version Description
- Added export to File, Dropbox, Amazon S3, Google Drive
- Added import from File, Dropbox, Amazon S3, Google Drive
- Implemented our own archiving format that reduces export and import by a factor of 10
- One-click export with the new simplified export page
- Improved upload functionality with auto-recognizing chunk size on import
- New Backups page for storing all WordPress site exports
- Easy restore WordPress site from Backups page
- Monitoring availability of the disk space on the server
- Both export and import happen in time chunks of 3 seconds
- Plugin works behind HTTP basic authentication
Download this release
Release Info
Developer | bangelov |
Plugin | ![]() |
Version | 3.0.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.5 to 3.0.1
- all-in-one-wp-migration.php +10 -1
- constants.php +105 -63
- lib/controller/class-ai1wm-backup-controller.php +62 -0
- lib/controller/class-ai1wm-export-controller.php +88 -67
- lib/controller/class-ai1wm-feedback-controller.php +2 -2
- lib/controller/class-ai1wm-import-controller.php +94 -142
- lib/controller/class-ai1wm-main-controller.php +497 -123
- lib/controller/class-ai1wm-message-controller.php +2 -3
- lib/controller/class-ai1wm-report-controller.php +2 -3
- lib/exception/class-ai1wm-backup-exception.php +28 -0
- lib/exception/class-ai1wm-export-exception.php +2 -2
- lib/exception/class-ai1wm-import-exception.php +54 -2
- lib/exception/class-ai1wm-not-accessible-exception.php +28 -0
- lib/exception/class-ai1wm-not-found-exception.php +27 -0
- lib/exception/class-ai1wm-not-readable-exception.php +28 -0
- lib/exception/class-ai1wm-not-writable-exception.php +28 -0
- lib/exception/class-ai1wm-storage-exception.php +28 -0
- lib/model/class-ai1wm-backup.php +121 -0
- lib/model/class-ai1wm-error.php +4 -4
- lib/model/class-ai1wm-export-abstract.php +393 -0
- lib/model/class-ai1wm-export-file.php +63 -0
- lib/model/class-ai1wm-export.php +0 -152
- lib/model/class-ai1wm-feedback.php +9 -10
- lib/model/class-ai1wm-import-abstract.php +446 -0
- lib/model/{service/class-ai1wm-service-sites.php → class-ai1wm-import-file.php} +42 -62
- lib/model/class-ai1wm-import.php +0 -204
- lib/model/class-ai1wm-log.php +135 -0
- lib/model/class-ai1wm-logger.php +5 -7
- lib/model/class-ai1wm-maintenance.php +10 -11
- lib/model/class-ai1wm-message.php +18 -17
- lib/model/class-ai1wm-report.php +8 -9
- lib/model/class-ai1wm-status.php +144 -0
- lib/model/class-ai1wm-storage.php +157 -0
- lib/model/class-ai1wm-template.php +15 -7
- lib/model/service/class-ai1wm-service-database.php +138 -34
- lib/model/service/class-ai1wm-service-interface.php +3 -2
- lib/model/service/class-ai1wm-service-package.php +85 -21
- lib/vendor/bandar/bandar/lib/Bandar.php +170 -164
- lib/vendor/bandar/bandar/lib/Exceptions/TemplateDoesNotExistException.php +1 -1
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpFactory.php +19 -19
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpInterface.php +238 -255
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpPDO.php +723 -730
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpSQL.php +672 -677
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlFileAdapter.php +22 -22
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlQueryAdapter.php +74 -61
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlUtility.php +47 -47
- lib/vendor/servmask/archiver/class-ai1wm-archiver.php +235 -0
- lib/vendor/servmask/archiver/class-ai1wm-compressor.php +113 -0
- lib/vendor/servmask/archiver/class-ai1wm-extractor.php +304 -0
- lib/{model/service/class-ai1wm-service-plugins.php → vendor/servmask/cron/class-ai1wm-cron.php} +32 -51
- lib/{model/service/class-ai1wm-service-media.php → vendor/servmask/filesystem/class-ai1wm-file.php} +30 -34
- lib/vendor/servmask/filter/class-ai1wm-recursive-exclude-filter.php +42 -0
- lib/{model/service/class-ai1wm-service-themes.php → vendor/servmask/iterator/class-ai1wm-recursive-directory-iterator.php} +17 -35
- lib/vendor/storage-factory/storage-factory/LICENSE +0 -20
- lib/vendor/storage-factory/storage-factory/lib/StorageAbstract.php +0 -70
- lib/vendor/storage-factory/storage-factory/lib/StorageArea.php +0 -130
- lib/vendor/storage-factory/storage-factory/lib/StorageDirectory.php +0 -100
- lib/vendor/storage-factory/storage-factory/lib/StorageFile.php +0 -100
- lib/vendor/storage-factory/storage-factory/lib/StorageUtility.php +0 -162
- lib/vendor/zip-factory/zip-factory/LICENSE +0 -20
- lib/vendor/zip-factory/zip-factory/lib/ArchiverInterface.php +0 -118
- lib/vendor/zip-factory/zip-factory/lib/ArchiverPclZip.php +0 -218
- lib/vendor/zip-factory/zip-factory/lib/ArchiverZipArchive.php +0 -223
- lib/vendor/zip-factory/zip-factory/lib/ZipFactory.php +0 -70
- lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/gnu-lgpl.txt +0 -504
- lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/pclzip.lib.php +0 -5690
- lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/readme.txt +0 -421
- lib/view/assets/css/backup.min.css +1 -0
- lib/view/assets/css/export.min.css +1 -1
- lib/view/assets/css/import.min.css +1 -1
- lib/view/assets/font/servmask.eot +0 -0
- lib/view/assets/font/servmask.svg +6 -0
- lib/view/assets/font/servmask.ttf +0 -0
- lib/view/assets/font/servmask.woff +0 -0
- lib/view/assets/img/logo.svg +69 -0
- lib/view/assets/javascript/backup.min.js +1 -0
- lib/view/assets/javascript/export.min.js +1 -1
- lib/view/assets/javascript/import.min.js +1 -1
- lib/view/backup/index.php +140 -0
- lib/view/common/export-modal.php +14 -0
- lib/view/common/leave-feedback.php +47 -0
- lib/view/common/maintenance-mode.php +11 -0
- lib/view/common/report-problem.php +26 -0
- lib/view/common/share-buttons.php +50 -0
- lib/view/export/button-dropbox.php +1 -0
- lib/view/export/button-file.php +1 -0
- lib/view/export/button-ftp.php +1 -0
- lib/view/export/button-gdrive.php +1 -0
- lib/view/export/button-s3.php +1 -0
- lib/view/export/export-buttons.php +36 -0
- lib/view/export/find-replace.php +22 -0
- lib/view/export/help-section.php +23 -0
- lib/view/export/index.php +21 -282
- lib/view/import/button-dropbox.php +1 -0
- lib/view/import/button-file.php +1 -0
- lib/view/import/button-ftp.php +1 -0
- lib/view/import/button-gdrive.php +1 -0
- lib/view/import/button-s3.php +1 -0
- lib/view/import/import-buttons.php +63 -0
- lib/view/import/index.php +12 -198
- loader.php +99 -27
- readme.txt +57 -54
- uninstall.php +6 -5
all-in-one-wp-migration.php
CHANGED
@@ -5,7 +5,10 @@
|
|
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:
|
|
|
|
|
|
|
9 |
*
|
10 |
* Copyright (C) 2014 ServMask Inc.
|
11 |
*
|
@@ -41,6 +44,12 @@ define( 'AI1WM_PATH', dirname( __FILE__ ) );
|
|
41 |
// Plugin Url
|
42 |
define( 'AI1WM_URL', plugins_url( '', __FILE__ ) );
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
// include constants
|
45 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'constants.php';
|
46 |
|
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: 3.0.1
|
9 |
+
* Text Domain: all-in-one-wp-migration
|
10 |
+
* Domain Path: /languages
|
11 |
+
* Network: True
|
12 |
*
|
13 |
* Copyright (C) 2014 ServMask Inc.
|
14 |
*
|
44 |
// Plugin Url
|
45 |
define( 'AI1WM_URL', plugins_url( '', __FILE__ ) );
|
46 |
|
47 |
+
// Plugin Storage Url
|
48 |
+
define( 'AI1WM_STORAGE_URL', plugins_url( 'storage', __FILE__ ) );
|
49 |
+
|
50 |
+
// Plugin Backups Url
|
51 |
+
define( 'AI1WM_BACKUPS_URL', plugins_url( 'backups', __FILE__ ) );
|
52 |
+
|
53 |
// include constants
|
54 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'constants.php';
|
55 |
|
constants.php
CHANGED
@@ -23,26 +23,53 @@
|
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
// ==================
|
27 |
// = Plugin Version =
|
28 |
// ==================
|
29 |
-
define( 'AI1WM_VERSION', '
|
30 |
|
31 |
// ===============
|
32 |
// = Plugin Name =
|
33 |
// ===============
|
34 |
define( 'AI1WM_PLUGIN_NAME', 'all-in-one-wp-migration' );
|
35 |
|
36 |
-
//
|
37 |
-
// =
|
38 |
-
//
|
39 |
-
define( '
|
40 |
|
41 |
-
//
|
42 |
// = Storage Path =
|
43 |
-
//
|
44 |
define( 'AI1WM_STORAGE_PATH', AI1WM_PATH . DIRECTORY_SEPARATOR . 'storage' );
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
// ============
|
47 |
// = Lib Path =
|
48 |
// ============
|
@@ -58,15 +85,20 @@ define( 'AI1WM_CONTROLLER_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'control
|
|
58 |
// ==============
|
59 |
define( 'AI1WM_MODEL_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'model' );
|
60 |
|
61 |
-
//
|
62 |
// = Service Path =
|
63 |
-
//
|
64 |
define( 'AI1WM_SERVICE_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'service' );
|
65 |
|
66 |
// =============
|
67 |
// = View Path =
|
68 |
// =============
|
69 |
-
define( '
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
// ==================
|
72 |
// = Exception Path =
|
@@ -78,95 +110,105 @@ define( 'AI1WM_EXCEPTION_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'exceptio
|
|
78 |
// ===============
|
79 |
define( 'AI1WM_VENDOR_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'vendor' );
|
80 |
|
81 |
-
//
|
82 |
// = ServMask Feedback Url =
|
83 |
-
//
|
84 |
define( 'AI1WM_FEEDBACK_URL', 'https://servmask.com/ai1wm/feedback/create' );
|
85 |
|
86 |
-
//
|
87 |
// = ServMask Report Url =
|
88 |
-
//
|
89 |
define( 'AI1WM_REPORT_URL', 'https://servmask.com/ai1wm/report/create' );
|
90 |
|
91 |
-
//
|
|
|
|
|
|
|
|
|
|
|
92 |
// = ServMask Table Prefix =
|
93 |
-
//
|
94 |
define( 'AI1WM_TABLE_PREFIX', 'SERVMASK_PREFIX_' );
|
95 |
|
96 |
-
//
|
97 |
// = Archive Database Name =
|
98 |
-
//
|
99 |
define( 'AI1WM_DATABASE_NAME', 'database.sql' );
|
100 |
|
101 |
-
//
|
102 |
-
// = Archive Media Name =
|
103 |
-
// ==============
|
104 |
-
define( 'AI1WM_MEDIA_NAME', 'media' );
|
105 |
-
|
106 |
-
// ==============
|
107 |
-
// = Archive Sites Name =
|
108 |
-
// ==============
|
109 |
-
define( 'AI1WM_SITES_NAME', 'sites' );
|
110 |
-
|
111 |
-
// ==============
|
112 |
-
// = Archive Blogs Name =
|
113 |
-
// ==============
|
114 |
-
define( 'AI1WM_BLOGS_NAME', 'blogs.dir' );
|
115 |
-
|
116 |
-
// ==============
|
117 |
-
// = Archive Themes Name =
|
118 |
-
// ==============
|
119 |
-
define( 'AI1WM_THEMES_NAME', 'themes' );
|
120 |
-
|
121 |
-
// ==============
|
122 |
-
// = Archive Plugins Name =
|
123 |
-
// ==============
|
124 |
-
define( 'AI1WM_PLUGINS_NAME', 'plugins' );
|
125 |
-
|
126 |
-
// ==============
|
127 |
// = Archive Package Name =
|
128 |
-
//
|
129 |
define( 'AI1WM_PACKAGE_NAME', 'package.json' );
|
130 |
|
131 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
// = Export Options Key =
|
133 |
-
//
|
134 |
define( 'AI1WM_EXPORT_OPTIONS', 'ai1wm_export_options' );
|
135 |
|
136 |
-
//
|
137 |
// = Error Handler Key =
|
138 |
-
//
|
139 |
define( 'AI1WM_ERROR_HANDLER', 'ai1wm_error_handler' );
|
140 |
|
141 |
-
//
|
142 |
// = Exception Handler Key =
|
143 |
-
//
|
144 |
define( 'AI1WM_EXCEPTION_HANDLER', 'ai1wm_exception_handler' );
|
145 |
|
146 |
-
//
|
147 |
// = Maintenance Mode Key =
|
148 |
-
//
|
149 |
define( 'AI1WM_MAINTENANCE_MODE', 'ai1wm_maintenance_mode' );
|
150 |
|
151 |
// ==============
|
152 |
-
// =
|
153 |
// ==============
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
define( 'AI1WM_MESSAGES', 'ai1wm_messages' );
|
155 |
|
156 |
-
//
|
|
|
|
|
|
|
|
|
|
|
157 |
// = Max File Size =
|
158 |
-
//
|
159 |
-
define( 'AI1WM_MAX_FILE_SIZE',
|
160 |
|
161 |
-
//
|
162 |
// = Max Chunk Size =
|
163 |
-
//
|
164 |
-
define( 'AI1WM_MAX_CHUNK_SIZE',
|
165 |
|
166 |
-
//
|
167 |
// = Max Chunk Retries =
|
168 |
-
//
|
169 |
-
define( 'AI1WM_MAX_CHUNK_RETRIES',
|
170 |
|
171 |
// ===========================
|
172 |
// = WP_CONTENT_DIR Constant =
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
25 |
|
26 |
+
$local = array(
|
27 |
+
'ИЛИЕВ™',
|
28 |
+
'dev.servmask.com',
|
29 |
+
'Borislav-MacBook-Pro.local',
|
30 |
+
);
|
31 |
+
|
32 |
+
if ( function_exists( 'gethostname' ) && in_array( gethostname(), $local ) ) {
|
33 |
+
define( 'AI1WM_DEBUG', true );
|
34 |
+
} else {
|
35 |
+
define( 'AI1WM_DEBUG', false );
|
36 |
+
}
|
37 |
+
|
38 |
// ==================
|
39 |
// = Plugin Version =
|
40 |
// ==================
|
41 |
+
define( 'AI1WM_VERSION', '3.0.1' );
|
42 |
|
43 |
// ===============
|
44 |
// = Plugin Name =
|
45 |
// ===============
|
46 |
define( 'AI1WM_PLUGIN_NAME', 'all-in-one-wp-migration' );
|
47 |
|
48 |
+
// =================
|
49 |
+
// = Directory Index =
|
50 |
+
// =================
|
51 |
+
define( 'AI1WM_DIRECTORY_INDEX', 'index.php' );
|
52 |
|
53 |
+
// ================
|
54 |
// = Storage Path =
|
55 |
+
// ================
|
56 |
define( 'AI1WM_STORAGE_PATH', AI1WM_PATH . DIRECTORY_SEPARATOR . 'storage' );
|
57 |
|
58 |
+
// ==================
|
59 |
+
// = Error Log Path =
|
60 |
+
// ==================
|
61 |
+
define( 'AI1WM_LOG_FILE', AI1WM_STORAGE_PATH . DIRECTORY_SEPARATOR . 'error.log' );
|
62 |
+
|
63 |
+
// ===============
|
64 |
+
// = Status Path =
|
65 |
+
// ===============
|
66 |
+
define( 'AI1WM_STATUS_FILE', AI1WM_STORAGE_PATH . DIRECTORY_SEPARATOR . 'status.php' );
|
67 |
+
|
68 |
+
// ================
|
69 |
+
// = Backups Path =
|
70 |
+
// ================
|
71 |
+
define( 'AI1WM_BACKUPS_PATH', AI1WM_PATH . DIRECTORY_SEPARATOR . 'backups' );
|
72 |
+
|
73 |
// ============
|
74 |
// = Lib Path =
|
75 |
// ============
|
85 |
// ==============
|
86 |
define( 'AI1WM_MODEL_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'model' );
|
87 |
|
88 |
+
// ================
|
89 |
// = Service Path =
|
90 |
+
// ================
|
91 |
define( 'AI1WM_SERVICE_PATH', AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'service' );
|
92 |
|
93 |
// =============
|
94 |
// = View Path =
|
95 |
// =============
|
96 |
+
define( 'AI1WM_TEMPLATES_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'view' );
|
97 |
+
|
98 |
+
// ===================
|
99 |
+
// = Set Bandar Path =
|
100 |
+
// ===================
|
101 |
+
define( 'BANDAR_TEMPLATES_PATH', AI1WM_TEMPLATES_PATH );
|
102 |
|
103 |
// ==================
|
104 |
// = Exception Path =
|
110 |
// ===============
|
111 |
define( 'AI1WM_VENDOR_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'vendor' );
|
112 |
|
113 |
+
// =========================
|
114 |
// = ServMask Feedback Url =
|
115 |
+
// =========================
|
116 |
define( 'AI1WM_FEEDBACK_URL', 'https://servmask.com/ai1wm/feedback/create' );
|
117 |
|
118 |
+
// =======================
|
119 |
// = ServMask Report Url =
|
120 |
+
// =======================
|
121 |
define( 'AI1WM_REPORT_URL', 'https://servmask.com/ai1wm/report/create' );
|
122 |
|
123 |
+
// ==============================
|
124 |
+
// = ServMask Archive Tools Url =
|
125 |
+
// ==============================
|
126 |
+
define( 'AI1WM_ARCHIVE_TOOLS_URL', 'https://servmask.com/archive/tools' );
|
127 |
+
|
128 |
+
// =========================
|
129 |
// = ServMask Table Prefix =
|
130 |
+
// =========================
|
131 |
define( 'AI1WM_TABLE_PREFIX', 'SERVMASK_PREFIX_' );
|
132 |
|
133 |
+
// =========================
|
134 |
// = Archive Database Name =
|
135 |
+
// =========================
|
136 |
define( 'AI1WM_DATABASE_NAME', 'database.sql' );
|
137 |
|
138 |
+
// ========================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
// = Archive Package Name =
|
140 |
+
// ========================
|
141 |
define( 'AI1WM_PACKAGE_NAME', 'package.json' );
|
142 |
|
143 |
+
// ========================
|
144 |
+
// = Archive Status Name =
|
145 |
+
// ========================
|
146 |
+
define( 'AI1WM_STATUS_NAME', 'status.php' );
|
147 |
+
|
148 |
+
// ========================
|
149 |
+
// = Archive FileMap Name =
|
150 |
+
// ========================
|
151 |
+
define( 'AI1WM_FILEMAP_NAME', 'filemap.list' );
|
152 |
+
|
153 |
+
// ======================
|
154 |
// = Export Options Key =
|
155 |
+
// ======================
|
156 |
define( 'AI1WM_EXPORT_OPTIONS', 'ai1wm_export_options' );
|
157 |
|
158 |
+
// =====================
|
159 |
// = Error Handler Key =
|
160 |
+
// =====================
|
161 |
define( 'AI1WM_ERROR_HANDLER', 'ai1wm_error_handler' );
|
162 |
|
163 |
+
// =========================
|
164 |
// = Exception Handler Key =
|
165 |
+
// =========================
|
166 |
define( 'AI1WM_EXCEPTION_HANDLER', 'ai1wm_exception_handler' );
|
167 |
|
168 |
+
// ========================
|
169 |
// = Maintenance Mode Key =
|
170 |
+
// ========================
|
171 |
define( 'AI1WM_MAINTENANCE_MODE', 'ai1wm_maintenance_mode' );
|
172 |
|
173 |
// ==============
|
174 |
+
// = Secret Key =
|
175 |
// ==============
|
176 |
+
define( 'AI1WM_SECRET_KEY', 'ai1wm_secret_key' );
|
177 |
+
|
178 |
+
// =============
|
179 |
+
// = Auth User =
|
180 |
+
// =============
|
181 |
+
define( 'AI1WM_AUTH_USER', 'ai1wm_auth_user' );
|
182 |
+
|
183 |
+
// =================
|
184 |
+
// = Auth Password =
|
185 |
+
// =================
|
186 |
+
define( 'AI1WM_AUTH_PASSWORD', 'ai1wm_auth_password' );
|
187 |
+
|
188 |
+
// ================
|
189 |
+
// = Messages Key =
|
190 |
+
// ================
|
191 |
define( 'AI1WM_MESSAGES', 'ai1wm_messages' );
|
192 |
|
193 |
+
// =================
|
194 |
+
// = Support Email =
|
195 |
+
// =================
|
196 |
+
define( 'AI1WM_SUPPORT_EMAIL', 'support@servmask.com' );
|
197 |
+
|
198 |
+
// =================
|
199 |
// = Max File Size =
|
200 |
+
// =================
|
201 |
+
define( 'AI1WM_MAX_FILE_SIZE', 536870912 );
|
202 |
|
203 |
+
// ==================
|
204 |
// = Max Chunk Size =
|
205 |
+
// ==================
|
206 |
+
define( 'AI1WM_MAX_CHUNK_SIZE', 5242880 );
|
207 |
|
208 |
+
// =====================
|
209 |
// = Max Chunk Retries =
|
210 |
+
// =====================
|
211 |
+
define( 'AI1WM_MAX_CHUNK_RETRIES', 10 );
|
212 |
|
213 |
// ===========================
|
214 |
// = WP_CONTENT_DIR Constant =
|
lib/controller/class-ai1wm-backup-controller.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (C) 2014 ServMask Inc.
|
5 |
+
*
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, either version 3 of the License, or
|
9 |
+
* (at your option) any later version.
|
10 |
+
*
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* You should have received a copy of the GNU General Public License
|
17 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
+
*
|
19 |
+
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
20 |
+
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
21 |
+
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
22 |
+
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
23 |
+
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
+
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
+
*/
|
26 |
+
class Ai1wm_Backup_Controller {
|
27 |
+
|
28 |
+
public static function index() {
|
29 |
+
$model = new Ai1wm_Backup;
|
30 |
+
|
31 |
+
Ai1wm_Template::render(
|
32 |
+
'backup/index',
|
33 |
+
array(
|
34 |
+
'backups' => $model->get_files(),
|
35 |
+
'free_space' => $model->get_free_space(),
|
36 |
+
'total_space' => $model->get_total_space(),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
public static function delete() {
|
42 |
+
$response = array( 'errors' => array() );
|
43 |
+
|
44 |
+
// Set file
|
45 |
+
$file = null;
|
46 |
+
if ( isset( $_POST['file'] ) ) {
|
47 |
+
$file = trim( $_POST['file'] );
|
48 |
+
}
|
49 |
+
|
50 |
+
$model = new Ai1wm_Backup;
|
51 |
+
|
52 |
+
try {
|
53 |
+
// Delete file
|
54 |
+
$model->delete_file( $file );
|
55 |
+
} catch ( Exception $e ) {
|
56 |
+
$response['errors'][] = $e->getMessage();
|
57 |
+
}
|
58 |
+
|
59 |
+
echo json_encode( $response );
|
60 |
+
exit;
|
61 |
+
}
|
62 |
+
}
|
lib/controller/class-ai1wm-export-controller.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (C) 2014 ServMask Inc.
|
4 |
*
|
@@ -22,90 +23,110 @@
|
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
|
|
25 |
|
26 |
-
class Ai1wm_Export_Controller
|
27 |
-
{
|
28 |
public static function index() {
|
29 |
-
|
30 |
-
|
31 |
-
} catch ( Exception $e ) {
|
32 |
-
$is_accessible = false;
|
33 |
-
}
|
34 |
-
|
35 |
-
// Messages
|
36 |
-
$model = new Ai1wm_Message;
|
37 |
-
$messages = $model->get_messages();
|
38 |
|
39 |
Ai1wm_Template::render(
|
40 |
'export/index',
|
41 |
array(
|
42 |
-
'messages'
|
43 |
-
'is_accessible' => $is_accessible,
|
44 |
)
|
45 |
);
|
46 |
}
|
47 |
|
48 |
-
public static function export() {
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
if ( isset( $_POST['options'] ) && ( $options = $_POST['options'] ) ) {
|
55 |
-
|
56 |
-
// Log options
|
57 |
-
Ai1wm_Logger::debug( AI1WM_EXPORT_OPTIONS, $options );
|
58 |
-
|
59 |
-
// Export site
|
60 |
-
$model = new Ai1wm_Export( $options );
|
61 |
-
$file = $model->export();
|
62 |
-
|
63 |
-
// Send the file to the user
|
64 |
-
header( 'Content-Description: File Transfer' );
|
65 |
-
header( 'Content-Type: application/octet-stream' );
|
66 |
-
header( 'Content-Disposition: attachment; filename=' . self::filename() );
|
67 |
-
header( 'Content-Transfer-Encoding: binary' );
|
68 |
-
header( 'Expires: 0' );
|
69 |
-
header( 'Cache-Control: must-revalidate' );
|
70 |
-
header( 'Pragma: public' );
|
71 |
-
header( 'Content-Length: ' . $file->getSize() );
|
72 |
-
|
73 |
-
// Clear output buffering and read file content
|
74 |
-
while ( @ob_end_clean() );
|
75 |
-
|
76 |
-
// Load file content
|
77 |
-
$handle = fopen( $file->getName(), 'rb' );
|
78 |
-
while ( ! feof( $handle ) ) {
|
79 |
-
echo fread( $handle, 8192 );
|
80 |
}
|
81 |
-
fclose( $handle );
|
82 |
|
83 |
-
//
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
}
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
102 |
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (C) 2014 ServMask Inc.
|
5 |
*
|
23 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
*/
|
26 |
+
class Ai1wm_Export_Controller {
|
27 |
|
|
|
|
|
28 |
public static function index() {
|
29 |
+
// Get message model
|
30 |
+
$model = new Ai1wm_Message;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
Ai1wm_Template::render(
|
33 |
'export/index',
|
34 |
array(
|
35 |
+
'messages' => $model->get_messages(),
|
|
|
36 |
)
|
37 |
);
|
38 |
}
|
39 |
|
40 |
+
public static function export( array $args = array() ) {
|
41 |
+
try {
|
42 |
+
|
43 |
+
// Set arguments
|
44 |
+
if ( empty( $args ) ) {
|
45 |
+
$args = $_REQUEST;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
|
|
47 |
|
48 |
+
// Set storage path
|
49 |
+
if ( empty( $args['storage'] ) ) {
|
50 |
+
$args['storage'] = uniqid();
|
51 |
+
}
|
|
|
52 |
|
53 |
+
// Set secret key
|
54 |
+
$secret_key = null;
|
55 |
+
if ( isset( $args['secret_key'] ) ) {
|
56 |
+
$secret_key = $args['secret_key'];
|
57 |
+
}
|
58 |
|
59 |
+
// Verify secret key by using the value in the database, not in cache
|
60 |
+
if ( $secret_key !== get_site_option( AI1WM_SECRET_KEY, false, false ) ) {
|
61 |
+
throw new Ai1wm_Export_Exception(
|
62 |
+
sprintf(
|
63 |
+
__( 'Unable to authenticate your request with secret_key = %s', AI1WM_PLUGIN_NAME ),
|
64 |
+
$secret_key
|
65 |
+
)
|
66 |
+
);
|
67 |
+
}
|
68 |
|
69 |
+
// Set provider
|
70 |
+
$provider = null;
|
71 |
+
if ( isset( $args['provider'] ) ) {
|
72 |
+
$provider = $args['provider'];
|
73 |
+
}
|
74 |
|
75 |
+
$class = "Ai1wm_Export_$provider";
|
76 |
+
if ( ! class_exists( $class ) ) {
|
77 |
+
throw new Ai1wm_Export_Exception(
|
78 |
+
sprintf(
|
79 |
+
__( 'Unknown provider: <strong>"%s"</strong>', AI1WM_PLUGIN_NAME ),
|
80 |
+
$class
|
81 |
+
)
|
82 |
+
);
|
83 |
+
}
|
84 |
|
85 |
+
// Set method
|
86 |
+
$method = null;
|
87 |
+
if ( isset( $args['method'] ) ) {
|
88 |
+
$method = $args['method'];
|
89 |
+
}
|
90 |
+
|
91 |
+
// Initialize provider
|
92 |
+
$provider = new $class( $args );
|
93 |
+
if ( ! method_exists( $provider, $method ) ) {
|
94 |
+
throw new Ai1wm_Export_Exception(
|
95 |
+
sprintf(
|
96 |
+
__( 'Unknown method: <strong>"%s"</strong>', AI1WM_PLUGIN_NAME ),
|
97 |
+
$method
|
98 |
+
)
|
99 |
+
);
|
100 |
+
}
|
101 |
|
102 |
+
// Invoke method
|
103 |
+
echo json_encode( $provider->$method() );
|
104 |
+
exit;
|
105 |
+
} catch ( Exception $e ) {
|
106 |
+
// Log the error
|
107 |
+
Ai1wm_Log::error( 'Exception while exporting: ' . $e->getMessage() );
|
108 |
+
|
109 |
+
// Set the status to failed
|
110 |
+
Ai1wm_Status::set(
|
111 |
+
array(
|
112 |
+
'type' => 'error',
|
113 |
+
'title' => __( 'Unable to export', AI1WM_PLUGIN_NAME ),
|
114 |
+
'message' => $e->getMessage(),
|
115 |
+
)
|
116 |
+
);
|
117 |
+
|
118 |
+
// End the process
|
119 |
+
wp_die( 'Exception while exporting: ' . $e->getMessage() );
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
public static function buttons() {
|
124 |
+
return array(
|
125 |
+
apply_filters( 'ai1wm_export_file', Ai1wm_Template::get_content( 'export/button-file' ) ),
|
126 |
+
apply_filters( 'ai1wm_export_dropbox', Ai1wm_Template::get_content( 'export/button-dropbox' ) ),
|
127 |
+
apply_filters( 'ai1wm_export_gdrive', Ai1wm_Template::get_content( 'export/button-gdrive' ) ),
|
128 |
+
apply_filters( 'ai1wm_export_s3', Ai1wm_Template::get_content( 'export/button-s3' ) ),
|
129 |
+
apply_filters( 'ai1wm_export_ftp', Ai1wm_Template::get_content( 'export/button-ftp' ) ),
|
130 |
+
);
|
131 |
}
|
132 |
}
|
lib/controller/class-ai1wm-feedback-controller.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (C) 2014 ServMask Inc.
|
4 |
*
|
@@ -22,9 +23,8 @@
|
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
|
|
25 |
|
26 |
-
class Ai1wm_Feedback_Controller
|
27 |
-
{
|
28 |
public static function leave_feedback() {
|
29 |
// Set Type
|
30 |
$type = null;
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (C) 2014 ServMask Inc.
|
5 |
*
|
23 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
*/
|
26 |
+
class Ai1wm_Feedback_Controller {
|
27 |
|
|
|
|
|
28 |
public static function leave_feedback() {
|
29 |
// Set Type
|
30 |
$type = null;
|
lib/controller/class-ai1wm-import-controller.php
CHANGED
@@ -22,173 +22,125 @@
|
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
|
|
25 |
|
26 |
-
class Ai1wm_Import_Controller
|
27 |
-
{
|
28 |
public static function index() {
|
29 |
-
|
30 |
-
$is_accessible = StorageArea::getInstance()->getRootPath();
|
31 |
-
} catch ( Exception $e ) {
|
32 |
-
$is_accessible = false;
|
33 |
-
}
|
34 |
-
|
35 |
-
Ai1wm_Template::render(
|
36 |
-
'import/index',
|
37 |
-
array(
|
38 |
-
'is_accessible' => $is_accessible,
|
39 |
-
'max_file_size' => apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ),
|
40 |
-
)
|
41 |
-
);
|
42 |
}
|
43 |
|
44 |
-
public static function import() {
|
45 |
-
|
46 |
-
|
47 |
-
// Set default handlers
|
48 |
-
set_error_handler( array( 'Ai1wm_Error', 'error_handler' ) );
|
49 |
-
set_exception_handler( array( 'Ai1wm_Error', 'exception_handler' ) );
|
50 |
-
|
51 |
-
// Verify capabilities
|
52 |
-
if ( ! current_user_can( 'import' ) ) {
|
53 |
-
wp_die( 'Unable to process the request.' );
|
54 |
-
}
|
55 |
-
|
56 |
-
$messages = array();
|
57 |
|
58 |
-
|
59 |
-
$
|
60 |
-
|
61 |
-
|
62 |
-
'import' => array(
|
63 |
-
'file' => null,
|
64 |
-
'force' => null,
|
65 |
-
),
|
66 |
-
);
|
67 |
|
68 |
-
//
|
69 |
-
if (
|
70 |
-
$
|
71 |
}
|
72 |
|
73 |
-
//
|
74 |
-
|
75 |
-
|
|
|
76 |
}
|
77 |
|
78 |
-
//
|
79 |
-
if (
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
|
83 |
-
//
|
84 |
-
|
85 |
-
|
|
|
86 |
}
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$messages[] = array(
|
96 |
-
'type' => 'success',
|
97 |
-
'text' => sprintf(
|
98 |
-
_(
|
99 |
-
'Your data has been imported successfuly!<br />' .
|
100 |
-
'You need to perform two more steps:<br />' .
|
101 |
-
'<strong>1. You must save your permalinks structure twice. <a class="ai1wm-no-underline" href="%s#submit" target="_blank">Permalinks Settings</a></strong> (opens a new window)<br />' .
|
102 |
-
'<strong>2. <a class="ai1wm-no-underline" href="https://wordpress.org/support/view/plugin-reviews/all-in-one-wp-migration?rate=5#postform" target="_blank">Review the plugin</a>.</strong> (opens a new window)'
|
103 |
-
),
|
104 |
-
admin_url( 'options-permalink.php' )
|
105 |
-
),
|
106 |
-
);
|
107 |
-
|
108 |
-
// Flush storage
|
109 |
-
StorageArea::getInstance()->flush();
|
110 |
-
}
|
111 |
-
}
|
112 |
-
} catch ( Exception $e ) {
|
113 |
-
$messages[] = array(
|
114 |
-
'type' => 'error',
|
115 |
-
'text' => $e->getMessage(),
|
116 |
);
|
117 |
}
|
118 |
-
}
|
119 |
-
|
120 |
-
// Regenerate permalinks
|
121 |
-
$wp_rewrite->flush_rules( true );
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
// Partial upload file
|
132 |
-
$partial_file = $storage->makeFile( $options['import']['file'] );
|
133 |
-
|
134 |
-
// Upload file
|
135 |
-
if ( isset( $_FILES['upload-file'] ) ) {
|
136 |
-
|
137 |
-
// Has any upload error?
|
138 |
-
if ( empty( $_FILES['upload-file']['error'] ) ) {
|
139 |
-
|
140 |
-
// Flush storage
|
141 |
-
if ( $options['chunk'] === 0 ) {
|
142 |
-
$storage->flush();
|
143 |
-
}
|
144 |
-
|
145 |
-
// Open partial file
|
146 |
-
$out = fopen( $partial_file->getName(), $options['chunk'] == 0 ? 'wb' : 'ab' );
|
147 |
-
if ( $out ) {
|
148 |
-
// Read binary input stream and append it to temp file
|
149 |
-
$in = fopen( $_FILES['upload-file']['tmp_name'], 'rb' );
|
150 |
-
if ( $in ) {
|
151 |
-
while ( $buff = fread( $in, 4096 ) ) {
|
152 |
-
fwrite( $out, $buff );
|
153 |
-
}
|
154 |
-
}
|
155 |
-
|
156 |
-
fclose( $in );
|
157 |
-
fclose( $out );
|
158 |
-
|
159 |
-
// Remove temporary uploaded file
|
160 |
-
unlink( $_FILES['upload-file']['tmp_name'] );
|
161 |
-
} else {
|
162 |
-
throw new Ai1wm_Import_Exception(
|
163 |
-
sprintf(
|
164 |
-
_(
|
165 |
-
'Site could not be imported!<br />' .
|
166 |
-
'Please make sure that storage directory <strong>%s</strong> has read and write permissions.'
|
167 |
-
),
|
168 |
-
AI1WM_STORAGE_PATH
|
169 |
-
)
|
170 |
-
);
|
171 |
-
|
172 |
-
// Flush storage
|
173 |
-
$storage->flush();
|
174 |
-
}
|
175 |
-
} else {
|
176 |
throw new Ai1wm_Import_Exception(
|
177 |
sprintf(
|
178 |
-
|
179 |
-
|
180 |
-
'Please contact ServMask Support and report the following error code: %d'
|
181 |
-
),
|
182 |
-
$_FILES['upload-file']['error']
|
183 |
)
|
184 |
);
|
185 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
}
|
|
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
}
|
192 |
-
|
|
|
193 |
}
|
194 |
}
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
25 |
+
class Ai1wm_Import_Controller {
|
26 |
|
|
|
|
|
27 |
public static function index() {
|
28 |
+
Ai1wm_Template::render( 'import/index' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
+
public static function import( array $args = array() ) {
|
32 |
+
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
// Set arguments
|
35 |
+
if ( empty( $args ) ) {
|
36 |
+
$args = $_REQUEST;
|
37 |
+
}
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
// Set storage path
|
40 |
+
if ( empty( $args['storage'] ) ) {
|
41 |
+
$args['storage'] = uniqid();
|
42 |
}
|
43 |
|
44 |
+
// Set secret key
|
45 |
+
$secret_key = null;
|
46 |
+
if ( isset( $args['secret_key'] ) ) {
|
47 |
+
$secret_key = $args['secret_key'];
|
48 |
}
|
49 |
|
50 |
+
// Verify secret key by using the value in the database, not in cache
|
51 |
+
if ( $secret_key !== get_site_option( AI1WM_SECRET_KEY, false, false ) ) {
|
52 |
+
throw new Ai1wm_Import_Exception(
|
53 |
+
sprintf(
|
54 |
+
__( 'Unable to authenticate your request with secret_key = <strong>"%s"</strong>', AI1WM_PLUGIN_NAME ),
|
55 |
+
$secret_key
|
56 |
+
)
|
57 |
+
);
|
58 |
}
|
59 |
|
60 |
+
// Set provider
|
61 |
+
$provider = null;
|
62 |
+
if ( isset( $args['provider'] ) ) {
|
63 |
+
$provider = $args['provider'];
|
64 |
}
|
65 |
|
66 |
+
$class = "Ai1wm_Import_$provider";
|
67 |
+
if ( ! class_exists( $class ) ) {
|
68 |
+
throw new Ai1wm_Import_Exception(
|
69 |
+
sprintf(
|
70 |
+
__( 'Unknown provider: <strong>"%s"</strong>', AI1WM_PLUGIN_NAME ),
|
71 |
+
$class
|
72 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
);
|
74 |
}
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
// Set method
|
77 |
+
$method = null;
|
78 |
+
if ( isset( $args['method'] ) ) {
|
79 |
+
$method = $args['method'];
|
80 |
+
}
|
81 |
|
82 |
+
// Initialize provider
|
83 |
+
$provider = new $class( $args );
|
84 |
+
if ( ! method_exists( $provider, $method ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
throw new Ai1wm_Import_Exception(
|
86 |
sprintf(
|
87 |
+
__( 'Unknown method: <strong>"%s"</strong>', AI1WM_PLUGIN_NAME ),
|
88 |
+
$method
|
|
|
|
|
|
|
89 |
)
|
90 |
);
|
91 |
}
|
92 |
+
|
93 |
+
// Invoke method
|
94 |
+
echo json_encode( $provider->$method() );
|
95 |
+
exit;
|
96 |
+
} catch ( Exception $e ) {
|
97 |
+
// Log the error
|
98 |
+
Ai1wm_Log::error( 'Exception while importing: ' . $e->getMessage() );
|
99 |
+
|
100 |
+
// Set the status to failed
|
101 |
+
Ai1wm_Status::set(
|
102 |
+
array(
|
103 |
+
'type' => 'error',
|
104 |
+
'title' => __( 'Unable to import', AI1WM_PLUGIN_NAME ),
|
105 |
+
'message' => $e->getMessage(),
|
106 |
+
)
|
107 |
+
);
|
108 |
+
|
109 |
+
// End the process
|
110 |
+
wp_die( 'Exception while importing: ' . $e->getMessage() );
|
111 |
}
|
112 |
+
}
|
113 |
|
114 |
+
public static function buttons() {
|
115 |
+
return array(
|
116 |
+
apply_filters( 'ai1wm_import_file', Ai1wm_Template::get_content( 'import/button-file' ) ),
|
117 |
+
apply_filters( 'ai1wm_import_dropbox', Ai1wm_Template::get_content( 'import/button-dropbox' ) ),
|
118 |
+
apply_filters( 'ai1wm_import_gdrive', Ai1wm_Template::get_content( 'import/button-gdrive' ) ),
|
119 |
+
apply_filters( 'ai1wm_import_s3', Ai1wm_Template::get_content( 'import/button-s3' ) ),
|
120 |
+
apply_filters( 'ai1wm_import_ftp', Ai1wm_Template::get_content( 'import/button-ftp' ) ),
|
121 |
+
);
|
122 |
+
}
|
123 |
+
|
124 |
+
public static function max_chunk_size() {
|
125 |
+
return min(
|
126 |
+
self::parse_size( ini_get( 'post_max_size' ) ),
|
127 |
+
self::parse_size( ini_get( 'upload_max_filesize' ) ),
|
128 |
+
self::parse_size( AI1WM_MAX_CHUNK_SIZE )
|
129 |
+
);
|
130 |
+
}
|
131 |
+
|
132 |
+
protected static function parse_size( $size ) {
|
133 |
+
$suffixes = array(
|
134 |
+
'' => 1,
|
135 |
+
'k' => 1000,
|
136 |
+
'm' => 1000000,
|
137 |
+
'g' => 1000000000,
|
138 |
+
);
|
139 |
+
|
140 |
+
if ( preg_match( '/([0-9]+)\s*(k|m|g)?(b?(ytes?)?)/i', $size, $match ) ) {
|
141 |
+
return $match[1] * $suffixes[strtolower( $match[2] )];
|
142 |
}
|
143 |
+
|
144 |
+
return AI1WM_MAX_CHUNK_SIZE;
|
145 |
}
|
146 |
}
|
lib/controller/class-ai1wm-main-controller.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (C) 2014 ServMask Inc.
|
4 |
*
|
@@ -22,105 +23,358 @@
|
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
|
|
25 |
|
26 |
-
class Ai1wm_Main_Controller
|
27 |
-
{
|
28 |
/**
|
29 |
* Main Application Controller
|
30 |
*
|
31 |
* @return Ai1wm_Main_Controller
|
32 |
*/
|
33 |
public function __construct() {
|
|
|
|
|
|
|
34 |
register_activation_hook(
|
35 |
-
|
36 |
-
DIRECTORY_SEPARATOR .
|
37 |
-
AI1WM_PLUGIN_NAME .
|
38 |
-
'.php',
|
39 |
array( $this, 'activation_hook' )
|
40 |
);
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
* Activation hook callback
|
|
|
48 |
* @return Object Instance of this class
|
49 |
*/
|
50 |
public function activation_hook() {
|
51 |
-
//
|
52 |
-
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
* Initializes language domain for the plugin
|
|
|
57 |
* @return Object Instance of this class
|
58 |
*/
|
59 |
-
private function
|
|
|
|
|
60 |
return $this;
|
61 |
}
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
/**
|
64 |
* Register listeners for actions
|
|
|
65 |
* @return Object Instance of this class
|
66 |
*/
|
67 |
private function activate_actions() {
|
68 |
if ( is_multisite() ) {
|
69 |
-
|
|
|
|
|
|
|
|
|
70 |
} else {
|
71 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
72 |
}
|
73 |
-
|
74 |
add_action( 'admin_init', array( $this, 'router' ) );
|
75 |
-
add_action( '
|
76 |
-
add_action( '
|
77 |
-
add_action( '
|
78 |
-
add_action( '
|
79 |
-
add_action( 'wp_ajax_disable_maintenance', 'Ai1wm_Maintenance::disable' );
|
80 |
-
add_action( 'get_header', 'Ai1wm_Maintenance::display' );
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
// Add a links to plugin list page
|
83 |
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
return $this;
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
* @return void
|
91 |
*/
|
92 |
-
public
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
if ( $file == AI1WM_PLUGIN_BASENAME ) {
|
94 |
-
$links[] =
|
95 |
}
|
96 |
|
97 |
return $links;
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
-
*
|
102 |
-
*
|
|
|
103 |
*/
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
|
108 |
/**
|
109 |
* Register plugin menus
|
|
|
|
|
110 |
*/
|
111 |
public function admin_menu() {
|
112 |
// top level WP Migration menu
|
113 |
add_menu_page(
|
114 |
-
'
|
115 |
-
'
|
116 |
'export',
|
117 |
'site-migration-export',
|
118 |
'Ai1wm_Export_Controller::index',
|
119 |
'',
|
120 |
-
76
|
121 |
);
|
122 |
-
|
123 |
-
// sublevel Import menu
|
124 |
$export_page_hook_suffix = add_submenu_page(
|
125 |
'site-migration-export',
|
126 |
'Export',
|
@@ -133,7 +387,6 @@ class Ai1wm_Main_Controller
|
|
133 |
'admin_print_scripts-' . $export_page_hook_suffix,
|
134 |
array( $this, 'register_export_scripts_and_styles' )
|
135 |
);
|
136 |
-
|
137 |
// sublevel Import menu
|
138 |
$import_page_hook_suffix = add_submenu_page(
|
139 |
'site-migration-export',
|
@@ -147,48 +400,105 @@ class Ai1wm_Main_Controller
|
|
147 |
'admin_print_scripts-' . $import_page_hook_suffix,
|
148 |
array( $this, 'register_import_scripts_and_styles' )
|
149 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
|
152 |
/**
|
153 |
* Outputs menu icon between head tags
|
|
|
|
|
154 |
*/
|
155 |
public function admin_head() {
|
156 |
global $wp_version;
|
157 |
-
$url = AI1WM_URL . '/lib/view/assets';
|
158 |
?>
|
159 |
<style type="text/css" media="all">
|
160 |
@font-face {
|
161 |
font-family: 'servmask';
|
162 |
-
src:url('<?php echo esc_url(
|
163 |
-
src:url('<?php echo esc_url(
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
font-weight: normal;
|
168 |
font-style: normal;
|
169 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
<?php if ( version_compare( $wp_version, '3.8', '<' ) ) : ?>
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
188 |
<?php else : ?>
|
189 |
.toplevel_page_site-migration-export > div.wp-menu-image:before {
|
190 |
-
|
191 |
-
|
|
|
|
|
192 |
speak: none !important;
|
193 |
font-style: normal !important;
|
194 |
font-weight: normal !important;
|
@@ -199,54 +509,117 @@ class Ai1wm_Main_Controller
|
|
199 |
-webkit-font-smoothing: antialiased !important;
|
200 |
-moz-osx-font-smoothing: grayscale !important;
|
201 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
<?php endif; ?>
|
203 |
</style>
|
204 |
-
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
* Register scripts and styles for Export Controller
|
|
|
|
|
209 |
*/
|
210 |
public function register_export_scripts_and_styles() {
|
|
|
|
|
|
|
|
|
|
|
211 |
wp_enqueue_script(
|
212 |
'ai1wm-js-export',
|
213 |
Ai1wm_Template::asset_link( 'javascript/export.min.js' ),
|
214 |
-
array( '
|
215 |
);
|
216 |
wp_enqueue_style(
|
217 |
'ai1wm-css-export',
|
218 |
Ai1wm_Template::asset_link( 'css/export.min.css' )
|
219 |
);
|
220 |
-
|
221 |
'ajax' => array(
|
222 |
-
'url' => admin_url( 'admin-ajax.php'
|
223 |
),
|
224 |
-
);
|
225 |
-
wp_localize_script( 'ai1wm-js-export', '
|
226 |
-
$report_init = array(
|
227 |
'ajax' => array(
|
228 |
-
'url' => admin_url( 'admin-ajax.php'
|
229 |
),
|
230 |
-
);
|
231 |
-
wp_localize_script( 'ai1wm-js-export', '
|
232 |
-
$message_init = array(
|
233 |
'ajax' => array(
|
234 |
-
'url' => admin_url( 'admin-ajax.php'
|
235 |
),
|
236 |
-
);
|
237 |
-
wp_localize_script( 'ai1wm-js-export', '
|
238 |
-
$maintenance_init = array(
|
239 |
'ajax' => array(
|
240 |
-
'url' => admin_url( 'admin-ajax.php'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
);
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
}
|
245 |
|
246 |
/**
|
247 |
* Register scripts and styles for Import Controller
|
|
|
|
|
248 |
*/
|
249 |
public function register_import_scripts_and_styles() {
|
|
|
|
|
|
|
|
|
|
|
250 |
wp_enqueue_script(
|
251 |
'ai1wm-js-import',
|
252 |
Ai1wm_Template::asset_link( 'javascript/import.min.js' ),
|
@@ -256,77 +629,78 @@ class Ai1wm_Main_Controller
|
|
256 |
'ai1wm-css-import',
|
257 |
Ai1wm_Template::asset_link( 'css/import.min.css' )
|
258 |
);
|
259 |
-
|
260 |
'runtimes' => 'html5,silverlight,flash,html4',
|
261 |
-
'browse_button' => 'ai1wm-
|
262 |
'container' => 'ai1wm-plupload-upload-ui',
|
263 |
'drop_element' => 'ai1wm-drag-drop-area',
|
264 |
'file_data_name' => 'upload-file',
|
265 |
-
'max_file_size' => apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ),
|
266 |
'chunk_size' => apply_filters( 'ai1wm_max_chunk_size', AI1WM_MAX_CHUNK_SIZE ),
|
267 |
'max_retries' => apply_filters( 'ai1wm_max_chunk_retries', AI1WM_MAX_CHUNK_RETRIES ),
|
268 |
-
'url' => admin_url( 'admin-ajax.php' ),
|
269 |
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
270 |
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
271 |
'multiple_queues' => false,
|
|
|
272 |
'urlstream_upload' => true,
|
273 |
'unique_names' => true,
|
274 |
'multipart' => true,
|
275 |
'multipart_params' => array(
|
276 |
-
'
|
|
|
|
|
277 |
),
|
278 |
'filters' => array(
|
279 |
-
|
280 |
-
|
281 |
-
'extensions' => 'zip',
|
282 |
-
),
|
283 |
),
|
284 |
-
);
|
285 |
-
wp_localize_script( 'ai1wm-js-import', '
|
286 |
-
$feedback_init = array(
|
287 |
'ajax' => array(
|
288 |
-
'url' => admin_url( 'admin-ajax.php'
|
289 |
),
|
290 |
-
);
|
291 |
-
wp_localize_script( 'ai1wm-js-import', '
|
292 |
-
$report_init = array(
|
293 |
'ajax' => array(
|
294 |
-
'url' => admin_url( 'admin-ajax.php'
|
295 |
),
|
296 |
-
);
|
297 |
-
wp_localize_script( 'ai1wm-js-import', '
|
298 |
-
$maintenance_init = array(
|
299 |
'ajax' => array(
|
300 |
-
'url' => admin_url( 'admin-ajax.php'
|
301 |
),
|
302 |
-
);
|
303 |
-
wp_localize_script( 'ai1wm-js-import', '
|
304 |
-
$import_init = array(
|
305 |
'ajax' => array(
|
306 |
-
'url' => admin_url( 'admin-ajax.php'
|
307 |
),
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (C) 2014 ServMask Inc.
|
5 |
*
|
23 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
*/
|
26 |
+
class Ai1wm_Main_Controller {
|
27 |
|
|
|
|
|
28 |
/**
|
29 |
* Main Application Controller
|
30 |
*
|
31 |
* @return Ai1wm_Main_Controller
|
32 |
*/
|
33 |
public function __construct() {
|
34 |
+
// Start by setting error and exception handlers
|
35 |
+
@set_error_handler( 'Ai1wm_Log::error_handler' );
|
36 |
+
|
37 |
register_activation_hook(
|
38 |
+
AI1WM_PLUGIN_BASENAME,
|
|
|
|
|
|
|
39 |
array( $this, 'activation_hook' )
|
40 |
);
|
41 |
+
|
42 |
+
// Activate hooks
|
43 |
+
$this->activate_actions()
|
44 |
+
->activate_filters()
|
45 |
+
->activate_textdomain();
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
* Activation hook callback
|
50 |
+
*
|
51 |
* @return Object Instance of this class
|
52 |
*/
|
53 |
public function activation_hook() {
|
54 |
+
// Generate secret key
|
55 |
+
$this->generate_secret_key();
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
* Initializes language domain for the plugin
|
60 |
+
*
|
61 |
* @return Object Instance of this class
|
62 |
*/
|
63 |
+
private function activate_textdomain() {
|
64 |
+
load_plugin_textdomain( AI1WM_PLUGIN_NAME, false, dirname( plugin_basename( __FILE__ ) ) );
|
65 |
+
|
66 |
return $this;
|
67 |
}
|
68 |
|
69 |
+
/**
|
70 |
+
* Generate plugin secret key
|
71 |
+
*
|
72 |
+
* @return boolean
|
73 |
+
*/
|
74 |
+
private function generate_secret_key() {
|
75 |
+
return update_site_option( AI1WM_SECRET_KEY, wp_generate_password( 12, false ) );
|
76 |
+
}
|
77 |
+
|
78 |
/**
|
79 |
* Register listeners for actions
|
80 |
+
*
|
81 |
* @return Object Instance of this class
|
82 |
*/
|
83 |
private function activate_actions() {
|
84 |
if ( is_multisite() ) {
|
85 |
+
if ( apply_filters( 'ai1wm_multisite_menu', false ) ) {
|
86 |
+
add_action( 'network_admin_menu', array( $this, 'admin_menu' ) );
|
87 |
+
} else {
|
88 |
+
add_action( 'network_admin_notices', array( $this, 'multisite_notice' ) );
|
89 |
+
}
|
90 |
} else {
|
91 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
92 |
}
|
93 |
+
|
94 |
add_action( 'admin_init', array( $this, 'router' ) );
|
95 |
+
add_action( 'admin_init', array( $this, 'create_folders' ) );
|
96 |
+
add_action( 'admin_init', array( $this, 'http_authentication' ) );
|
97 |
+
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
98 |
+
add_action( 'get_header', array( $this, 'get_header' ) );
|
|
|
|
|
99 |
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Register listeners for filters
|
105 |
+
*
|
106 |
+
* @return Object Instance of this class
|
107 |
+
*/
|
108 |
+
private function activate_filters() {
|
109 |
// Add a links to plugin list page
|
110 |
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
|
111 |
|
112 |
+
// Add export buttons
|
113 |
+
add_filter( 'ai1wm_export_buttons', 'Ai1wm_Export_Controller::buttons' );
|
114 |
+
|
115 |
+
// Add import buttons
|
116 |
+
add_filter( 'ai1wm_import_buttons', 'Ai1wm_Import_Controller::buttons' );
|
117 |
+
|
118 |
+
// Add chunk size limit
|
119 |
+
add_filter( 'ai1wm_max_chunk_size', 'Ai1wm_Import_Controller::max_chunk_size' );
|
120 |
+
|
121 |
return $this;
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
+
* Display multisite notice
|
126 |
+
*
|
127 |
+
* @return void
|
128 |
+
*/
|
129 |
+
public function multisite_notice() {
|
130 |
+
?>
|
131 |
+
<div class="error">
|
132 |
+
<p>
|
133 |
+
<?php
|
134 |
+
_e(
|
135 |
+
'WordPress Multisite is supported via our All in One WP Migration Multisite Extension. ' .
|
136 |
+
'You can get a copy of it here',
|
137 |
+
AI1WM_PLUGIN_NAME
|
138 |
+
);
|
139 |
+
?>
|
140 |
+
<a href="https://servmask.com/products/multisite-extension" target="_blank" class="ai1wm-label">
|
141 |
+
<i class="ai1wm-icon-notification"></i>
|
142 |
+
<?php _e( 'Get multisite', AI1WM_PLUGIN_NAME ); ?>
|
143 |
+
</a>
|
144 |
+
</p>
|
145 |
+
</div>
|
146 |
+
<?php
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Display storage directory notice
|
151 |
+
*
|
152 |
+
* @return void
|
153 |
+
*/
|
154 |
+
public function storage_notice() {
|
155 |
+
?>
|
156 |
+
<div class="error">
|
157 |
+
<p>
|
158 |
+
<?php
|
159 |
+
printf(
|
160 |
+
__(
|
161 |
+
'All in One WP Migration is not able to create <strong>%s</strong> folder. ' .
|
162 |
+
'You will need to create this folder and grant it read/write/execute permissions (0777) ' .
|
163 |
+
'for the All in One WP Migration plugin to function properly.',
|
164 |
+
AI1WM_PLUGIN_NAME
|
165 |
+
),
|
166 |
+
AI1WM_STORAGE_PATH
|
167 |
+
)
|
168 |
+
?>
|
169 |
+
</p>
|
170 |
+
</div>
|
171 |
+
<?php
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Display index file notice
|
176 |
+
*
|
177 |
+
* @return void
|
178 |
+
*/
|
179 |
+
public function index_notice() {
|
180 |
+
?>
|
181 |
+
<div class="error">
|
182 |
+
<p>
|
183 |
+
<?php
|
184 |
+
printf(
|
185 |
+
__(
|
186 |
+
'All in One WP Migration is not able to create <strong>%s</strong> file. ' .
|
187 |
+
'Try to change permissions of the parent folder or send us an email at ' .
|
188 |
+
'<a href="mailto:support@servmask.com">support@servmask.com</a> for assistance.',
|
189 |
+
AI1WM_PLUGIN_NAME
|
190 |
+
),
|
191 |
+
AI1WM_DIRECTORY_INDEX
|
192 |
+
)
|
193 |
+
?>
|
194 |
+
</p>
|
195 |
+
</div>
|
196 |
+
<?php
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Display backups directory notice
|
201 |
+
*
|
202 |
* @return void
|
203 |
*/
|
204 |
+
public function backups_notice() {
|
205 |
+
?>
|
206 |
+
<div class="error">
|
207 |
+
<p>
|
208 |
+
<?php
|
209 |
+
printf(
|
210 |
+
__(
|
211 |
+
'All in One WP Migration is not able to create <strong>%s</strong> folder. ' .
|
212 |
+
'You will need to create this folder and grant it read/write/execute permissions (0777) ' .
|
213 |
+
'for the All in One WP Migration plugin to function properly.',
|
214 |
+
AI1WM_PLUGIN_NAME
|
215 |
+
),
|
216 |
+
AI1WM_BACKUPS_PATH
|
217 |
+
)
|
218 |
+
?>
|
219 |
+
</p>
|
220 |
+
</div>
|
221 |
+
<?php
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Add a links to plugin list page
|
226 |
+
*
|
227 |
+
* @return array
|
228 |
+
*/
|
229 |
+
public function plugin_row_meta( $links, $file ) {
|
230 |
if ( $file == AI1WM_PLUGIN_BASENAME ) {
|
231 |
+
$links[] = __( '<a href="https://servmask.com/help" target="_blank">Get Support</a>', AI1WM_PLUGIN_NAME );
|
232 |
}
|
233 |
|
234 |
return $links;
|
235 |
}
|
236 |
|
237 |
/**
|
238 |
+
* Show maintenance page
|
239 |
+
*
|
240 |
+
* @return void
|
241 |
*/
|
242 |
+
public function get_header() {
|
243 |
+
Ai1wm_Maintenance::display();
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Register initial router
|
248 |
+
*
|
249 |
+
* @return void
|
250 |
+
*/
|
251 |
+
public function router() {
|
252 |
+
// Public
|
253 |
+
add_action( 'wp_ajax_nopriv_ai1wm_export', 'Ai1wm_Export_Controller::export' );
|
254 |
+
add_action( 'wp_ajax_nopriv_ai1wm_import', 'Ai1wm_Import_Controller::import' );
|
255 |
+
|
256 |
+
// Private
|
257 |
+
if ( ! current_user_can( 'export' ) || ! current_user_can( 'import' ) ) {
|
258 |
+
return;
|
259 |
+
}
|
260 |
+
|
261 |
+
// Register ajax calls
|
262 |
+
add_action( 'wp_ajax_ai1wm_export', 'Ai1wm_Export_Controller::export' );
|
263 |
+
add_action( 'wp_ajax_ai1wm_import', 'Ai1wm_Import_Controller::import' );
|
264 |
+
add_action( 'wp_ajax_ai1wm_leave_feedback', 'Ai1wm_Feedback_Controller::leave_feedback' );
|
265 |
+
add_action( 'wp_ajax_ai1wm_report_problem', 'Ai1wm_Report_Controller::report_problem' );
|
266 |
+
add_action( 'wp_ajax_ai1wm_close_message', 'Ai1wm_Message_Controller::close_message' );
|
267 |
+
add_action( 'wp_ajax_ai1wm_backup_delete', 'Ai1wm_Backup_Controller::delete' );
|
268 |
+
add_action( 'wp_ajax_ai1wm_disable_maintenance', 'Ai1wm_Maintenance::disable' );
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Create folders needed for plugin operation, if they don't exist
|
273 |
+
*
|
274 |
+
* @return void
|
275 |
+
*/
|
276 |
+
public function create_folders() {
|
277 |
+
// Check if storage folder exist
|
278 |
+
if ( ! file_exists( AI1WM_STORAGE_PATH ) ) {
|
279 |
+
// Folder doesn't exist, attempt to create it
|
280 |
+
if ( ! mkdir( AI1WM_STORAGE_PATH ) ) {
|
281 |
+
// We couldn't create the folder, so let's tell the user
|
282 |
+
if ( is_multisite() ) {
|
283 |
+
return add_action( 'network_admin_notices', array( $this, 'storage_notice' ) );
|
284 |
+
} else {
|
285 |
+
return add_action( 'admin_notices', array( $this, 'storage_notice' ) );
|
286 |
+
}
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
// Create index.php in storage folder
|
291 |
+
$this->create_index_file( AI1WM_STORAGE_PATH );
|
292 |
+
|
293 |
+
// Check if backups folder exist
|
294 |
+
if ( ! file_exists( AI1WM_BACKUPS_PATH ) ) {
|
295 |
+
// Folder doesn't exist, attempt to create it
|
296 |
+
if ( ! mkdir( AI1WM_BACKUPS_PATH ) ) {
|
297 |
+
// We couldn't create the folder, so let's tell the user
|
298 |
+
if ( is_multisite() ) {
|
299 |
+
return add_action( 'network_admin_notices', array( $this, 'backups_notice' ) );
|
300 |
+
} else {
|
301 |
+
return add_action( 'admin_notices', array( $this, 'backups_notice' ) );
|
302 |
+
}
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
// Create index.php in backups folder
|
307 |
+
$this->create_index_file( AI1WM_BACKUPS_PATH );
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Creates a index.php file in specific folder
|
312 |
+
*
|
313 |
+
* The method will create index.php file with contents '<?php // silence is golden' without the single quotes
|
314 |
+
* at the path specified by the argument. The file is only created if it doesn't exist. If the file is unable to
|
315 |
+
* be created, the method will call wp_die to notify the user and stop the execution
|
316 |
+
*
|
317 |
+
* @param $path string Path to the folder where the index.php file needs to be created
|
318 |
+
* @return void
|
319 |
+
*/
|
320 |
+
protected function create_index_file( $path ) {
|
321 |
+
// Name of the index file with the path
|
322 |
+
$file = $path . DIRECTORY_SEPARATOR . AI1WM_DIRECTORY_INDEX;
|
323 |
+
|
324 |
+
// Check if the file exists
|
325 |
+
if ( ! file_exists( $file ) ) {
|
326 |
+
// File doesn't exist attempt to create ti
|
327 |
+
$handle = fopen( $file, 'w' );
|
328 |
+
|
329 |
+
// Check if we were able to open the file
|
330 |
+
if ( false === $handle ) {
|
331 |
+
// We couldn't create the folder, so let's tell the user
|
332 |
+
if ( is_multisite() ) {
|
333 |
+
return add_action( 'network_admin_notices', array( $this, 'index_notice' ) );
|
334 |
+
} else {
|
335 |
+
return add_action( 'admin_notices', array( $this, 'index_notice' ) );
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
fwrite( $handle, '<?php // silence is golden' );
|
340 |
+
fclose( $handle );
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Store HTTP authentication credentials
|
346 |
+
*
|
347 |
+
* @return void
|
348 |
+
*/
|
349 |
+
public function http_authentication() {
|
350 |
+
// Set username
|
351 |
+
if ( isset( $_SERVER['PHP_AUTH_USER'] ) ) {
|
352 |
+
update_site_option( AI1WM_AUTH_USER, $_SERVER['PHP_AUTH_USER'] );
|
353 |
+
}
|
354 |
+
|
355 |
+
// Set password
|
356 |
+
if ( isset( $_SERVER['PHP_AUTH_PW'] ) ) {
|
357 |
+
update_site_option( AI1WM_AUTH_PASSWORD, $_SERVER['PHP_AUTH_PW'] );
|
358 |
+
}
|
359 |
}
|
360 |
|
361 |
/**
|
362 |
* Register plugin menus
|
363 |
+
*
|
364 |
+
* @return void
|
365 |
*/
|
366 |
public function admin_menu() {
|
367 |
// top level WP Migration menu
|
368 |
add_menu_page(
|
369 |
+
'All-in-One WP Migration',
|
370 |
+
'All-in-One WP Migration',
|
371 |
'export',
|
372 |
'site-migration-export',
|
373 |
'Ai1wm_Export_Controller::index',
|
374 |
'',
|
375 |
+
'76.295'
|
376 |
);
|
377 |
+
// sublevel Export menu
|
|
|
378 |
$export_page_hook_suffix = add_submenu_page(
|
379 |
'site-migration-export',
|
380 |
'Export',
|
387 |
'admin_print_scripts-' . $export_page_hook_suffix,
|
388 |
array( $this, 'register_export_scripts_and_styles' )
|
389 |
);
|
|
|
390 |
// sublevel Import menu
|
391 |
$import_page_hook_suffix = add_submenu_page(
|
392 |
'site-migration-export',
|
400 |
'admin_print_scripts-' . $import_page_hook_suffix,
|
401 |
array( $this, 'register_import_scripts_and_styles' )
|
402 |
);
|
403 |
+
// sublevel Backups menu
|
404 |
+
$backup_page_hook_suffix = add_submenu_page(
|
405 |
+
'site-migration-export',
|
406 |
+
'Backups',
|
407 |
+
'Backups',
|
408 |
+
'export',
|
409 |
+
'site-migration-backup',
|
410 |
+
'Ai1wm_Backup_Controller::index'
|
411 |
+
);
|
412 |
+
add_action(
|
413 |
+
'admin_print_scripts-' . $backup_page_hook_suffix,
|
414 |
+
array( $this, 'register_backup_scripts_and_styles' )
|
415 |
+
);
|
416 |
}
|
417 |
|
418 |
/**
|
419 |
* Outputs menu icon between head tags
|
420 |
+
*
|
421 |
+
* @return void
|
422 |
*/
|
423 |
public function admin_head() {
|
424 |
global $wp_version;
|
|
|
425 |
?>
|
426 |
<style type="text/css" media="all">
|
427 |
@font-face {
|
428 |
font-family: 'servmask';
|
429 |
+
src: url('<?php echo esc_url( AI1WM_URL ); ?>/lib/view/assets/font/servmask.eot?v=<?php echo AI1WM_VERSION; ?>');
|
430 |
+
src: url('<?php echo esc_url( AI1WM_URL ); ?>/lib/view/assets/font/servmask.eot?v=<?php echo AI1WM_VERSION; ?>#iefix') format('embedded-opentype'),
|
431 |
+
url('<?php echo esc_url( AI1WM_URL ); ?>/lib/view/assets/font/servmask.woff?v=<?php echo AI1WM_VERSION; ?>') format('woff'),
|
432 |
+
url('<?php echo esc_url( AI1WM_URL ); ?>/lib/view/assets/font/servmask.ttf?v=<?php echo AI1WM_VERSION; ?>') format('truetype'),
|
433 |
+
url('<?php echo esc_url( AI1WM_URL ); ?>/lib/view/assets/font/servmask.svg?v=<?php echo AI1WM_VERSION; ?>#servmask') format('svg');
|
434 |
font-weight: normal;
|
435 |
font-style: normal;
|
436 |
}
|
437 |
+
|
438 |
+
[class^="ai1wm-icon-"], [class*=" ai1wm-icon-"] {
|
439 |
+
font-family: 'servmask';
|
440 |
+
speak: none;
|
441 |
+
font-style: normal;
|
442 |
+
font-weight: normal;
|
443 |
+
font-variant: normal;
|
444 |
+
text-transform: none;
|
445 |
+
line-height: 1;
|
446 |
+
|
447 |
+
/* Better Font Rendering =========== */
|
448 |
+
-webkit-font-smoothing: antialiased;
|
449 |
+
-moz-osx-font-smoothing: grayscale;
|
450 |
+
}
|
451 |
+
|
452 |
+
.ai1wm-icon-notification:before {
|
453 |
+
content: "\e619";
|
454 |
+
}
|
455 |
+
|
456 |
+
.ai1wm-label {
|
457 |
+
border: 1px solid #5cb85c;
|
458 |
+
background-color: transparent;
|
459 |
+
color: #5cb85c;
|
460 |
+
cursor: pointer;
|
461 |
+
text-transform: uppercase;
|
462 |
+
font-weight: 600;
|
463 |
+
outline: none;
|
464 |
+
transition: background-color 0.2s ease-out;
|
465 |
+
padding: .2em .6em;
|
466 |
+
font-size: 0.8em;
|
467 |
+
border-radius: 5px;
|
468 |
+
text-decoration: none !important;
|
469 |
+
}
|
470 |
+
|
471 |
+
.ai1wm-label:hover {
|
472 |
+
background-color: #5cb85c;
|
473 |
+
color: #fff;
|
474 |
+
}
|
475 |
+
|
476 |
<?php if ( version_compare( $wp_version, '3.8', '<' ) ) : ?>
|
477 |
+
.toplevel_page_site-migration-export > div.wp-menu-image {
|
478 |
+
background: none !important;
|
479 |
+
}
|
480 |
+
|
481 |
+
.toplevel_page_site-migration-export > div.wp-menu-image:before {
|
482 |
+
line-height: 27px !important;
|
483 |
+
content: '';
|
484 |
+
background: url('<?php echo esc_url( AI1WM_URL ); ?>/lib/view/assets/img/logo.svg') no-repeat center center;
|
485 |
+
speak: none !important;
|
486 |
+
font-style: normal !important;
|
487 |
+
font-weight: normal !important;
|
488 |
+
font-variant: normal !important;
|
489 |
+
text-transform: none !important;
|
490 |
+
margin-left: 7px;
|
491 |
+
/* Better Font Rendering =========== */
|
492 |
+
-webkit-font-smoothing: antialiased !important;
|
493 |
+
-moz-osx-font-smoothing: grayscale !important;
|
494 |
+
}
|
495 |
+
|
496 |
<?php else : ?>
|
497 |
.toplevel_page_site-migration-export > div.wp-menu-image:before {
|
498 |
+
position: relative;
|
499 |
+
display: inline-block;
|
500 |
+
content: '';
|
501 |
+
background: url('<?php echo esc_url( AI1WM_URL ); ?>/lib/view/assets/img/logo.svg') no-repeat center center;
|
502 |
speak: none !important;
|
503 |
font-style: normal !important;
|
504 |
font-weight: normal !important;
|
509 |
-webkit-font-smoothing: antialiased !important;
|
510 |
-moz-osx-font-smoothing: grayscale !important;
|
511 |
}
|
512 |
+
|
513 |
+
.wp-menu-open.toplevel_page_site-migration-export,
|
514 |
+
.wp-menu-open.toplevel_page_site-migration-export > a {
|
515 |
+
background-color: #111 !important;
|
516 |
+
}
|
517 |
+
|
518 |
<?php endif; ?>
|
519 |
</style>
|
520 |
+
<?php
|
521 |
}
|
522 |
|
523 |
/**
|
524 |
* Register scripts and styles for Export Controller
|
525 |
+
*
|
526 |
+
* @return void
|
527 |
*/
|
528 |
public function register_export_scripts_and_styles() {
|
529 |
+
do_action( 'ai1mw-register-export-scripts-and-styles' );
|
530 |
+
|
531 |
+
// we don't want heartbeat to occur when exporting
|
532 |
+
wp_deregister_script( 'heartbeat' );
|
533 |
+
|
534 |
wp_enqueue_script(
|
535 |
'ai1wm-js-export',
|
536 |
Ai1wm_Template::asset_link( 'javascript/export.min.js' ),
|
537 |
+
array( 'jquery' )
|
538 |
);
|
539 |
wp_enqueue_style(
|
540 |
'ai1wm-css-export',
|
541 |
Ai1wm_Template::asset_link( 'css/export.min.css' )
|
542 |
);
|
543 |
+
wp_localize_script( 'ai1wm-js-export', 'ai1wm_feedback', array(
|
544 |
'ajax' => array(
|
545 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_leave_feedback' ),
|
546 |
),
|
547 |
+
) );
|
548 |
+
wp_localize_script( 'ai1wm-js-export', 'ai1wm_report', array(
|
|
|
549 |
'ajax' => array(
|
550 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_report_problem' ),
|
551 |
),
|
552 |
+
) );
|
553 |
+
wp_localize_script( 'ai1wm-js-export', 'ai1wm_message', array(
|
|
|
554 |
'ajax' => array(
|
555 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_close_message' ),
|
556 |
),
|
557 |
+
) );
|
558 |
+
wp_localize_script( 'ai1wm-js-export', 'ai1wm_maintenance', array(
|
|
|
559 |
'ajax' => array(
|
560 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_disable_maintenance' ),
|
561 |
+
),
|
562 |
+
) );
|
563 |
+
wp_localize_script( 'ai1wm-js-export', 'ai1wm_export', array(
|
564 |
+
'ajax' => array(
|
565 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_export' ),
|
566 |
+
),
|
567 |
+
'status' => array(
|
568 |
+
'url' => AI1WM_STORAGE_URL,
|
569 |
),
|
570 |
+
'secret_key' => get_site_option( AI1WM_SECRET_KEY, false, false ),
|
571 |
+
) );
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Register scripts and styles for Backup Controller
|
576 |
+
*
|
577 |
+
* @return void
|
578 |
+
*/
|
579 |
+
public function register_backup_scripts_and_styles() {
|
580 |
+
do_action( 'ai1mw-register-backup-scripts-and-styles' );
|
581 |
+
wp_enqueue_script(
|
582 |
+
'ai1wm-js-backup',
|
583 |
+
Ai1wm_Template::asset_link( 'javascript/backup.min.js' ),
|
584 |
+
array( 'jquery' )
|
585 |
);
|
586 |
+
wp_enqueue_style(
|
587 |
+
'ai1wm-css-backup',
|
588 |
+
Ai1wm_Template::asset_link( 'css/backup.min.css' )
|
589 |
+
);
|
590 |
+
wp_localize_script( 'ai1wm-js-backup', 'ai1wm_feedback', array(
|
591 |
+
'ajax' => array(
|
592 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_leave_feedback' ),
|
593 |
+
),
|
594 |
+
) );
|
595 |
+
wp_localize_script( 'ai1wm-js-backup', 'ai1wm_report', array(
|
596 |
+
'ajax' => array(
|
597 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_report_problem' ),
|
598 |
+
),
|
599 |
+
) );
|
600 |
+
wp_localize_script( 'ai1wm-js-backup', 'ai1wm_maintenance', array(
|
601 |
+
'ajax' => array(
|
602 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_disable_maintenance' ),
|
603 |
+
),
|
604 |
+
) );
|
605 |
+
wp_localize_script( 'ai1wm-js-backup', 'ai1wm_backup', array(
|
606 |
+
'ajax' => array(
|
607 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_backup_delete' ),
|
608 |
+
),
|
609 |
+
) );
|
610 |
}
|
611 |
|
612 |
/**
|
613 |
* Register scripts and styles for Import Controller
|
614 |
+
*
|
615 |
+
* @return void
|
616 |
*/
|
617 |
public function register_import_scripts_and_styles() {
|
618 |
+
do_action( 'ai1mw-register-import-scripts-and-styles' );
|
619 |
+
|
620 |
+
// we don't want heartbeat to occur when importing
|
621 |
+
wp_deregister_script( 'heartbeat' );
|
622 |
+
|
623 |
wp_enqueue_script(
|
624 |
'ai1wm-js-import',
|
625 |
Ai1wm_Template::asset_link( 'javascript/import.min.js' ),
|
629 |
'ai1wm-css-import',
|
630 |
Ai1wm_Template::asset_link( 'css/import.min.css' )
|
631 |
);
|
632 |
+
wp_localize_script( 'ai1wm-js-import', 'ai1wm_uploader', array(
|
633 |
'runtimes' => 'html5,silverlight,flash,html4',
|
634 |
+
'browse_button' => 'ai1wm-import-file',
|
635 |
'container' => 'ai1wm-plupload-upload-ui',
|
636 |
'drop_element' => 'ai1wm-drag-drop-area',
|
637 |
'file_data_name' => 'upload-file',
|
|
|
638 |
'chunk_size' => apply_filters( 'ai1wm_max_chunk_size', AI1WM_MAX_CHUNK_SIZE ),
|
639 |
'max_retries' => apply_filters( 'ai1wm_max_chunk_retries', AI1WM_MAX_CHUNK_RETRIES ),
|
640 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_import' ),
|
641 |
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
642 |
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
643 |
'multiple_queues' => false,
|
644 |
+
'multi_selection' => false,
|
645 |
'urlstream_upload' => true,
|
646 |
'unique_names' => true,
|
647 |
'multipart' => true,
|
648 |
'multipart_params' => array(
|
649 |
+
'provider' => 'file',
|
650 |
+
'method' => 'import',
|
651 |
+
'secret_key' => get_site_option( AI1WM_SECRET_KEY, false, false ),
|
652 |
),
|
653 |
'filters' => array(
|
654 |
+
'ai1wm_archive_extension' => 'wpress',
|
655 |
+
'ai1wm_archive_size' => apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ),
|
|
|
|
|
656 |
),
|
657 |
+
) );
|
658 |
+
wp_localize_script( 'ai1wm-js-import', 'ai1wm_feedback', array(
|
|
|
659 |
'ajax' => array(
|
660 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_leave_feedback' ),
|
661 |
),
|
662 |
+
) );
|
663 |
+
wp_localize_script( 'ai1wm-js-import', 'ai1wm_report', array(
|
|
|
664 |
'ajax' => array(
|
665 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_report_problem' ),
|
666 |
),
|
667 |
+
) );
|
668 |
+
wp_localize_script( 'ai1wm-js-import', 'ai1wm_maintenance', array(
|
|
|
669 |
'ajax' => array(
|
670 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_disable_maintenance' ),
|
671 |
),
|
672 |
+
) );
|
673 |
+
wp_localize_script( 'ai1wm-js-import', 'ai1wm_import', array(
|
|
|
674 |
'ajax' => array(
|
675 |
+
'url' => admin_url( 'admin-ajax.php?action=ai1wm_import' ),
|
676 |
),
|
677 |
+
'status' => array(
|
678 |
+
'url' => AI1WM_STORAGE_URL,
|
679 |
+
),
|
680 |
+
'secret_key' => get_site_option( AI1WM_SECRET_KEY, false, false ),
|
681 |
+
'oversize' => sprintf(
|
682 |
+
__(
|
683 |
+
'The file that you are trying to import is over the maximum upload file size limit of <strong>%s</strong>.' .
|
684 |
+
'<br />You can remove this restriction by purchasing our ' .
|
685 |
+
'<a href="https://servmask.com/products/unlimited-extension" target="_blank">Unlimited Extension</a>.',
|
686 |
+
AI1WM_PLUGIN_NAME
|
687 |
+
),
|
688 |
+
size_format( apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ) )
|
689 |
+
),
|
690 |
+
'invalid_extension' =>
|
691 |
+
sprintf(
|
692 |
+
__(
|
693 |
+
'Version 2.1.1 of All in One WP Migration introduces new compression algorithm. ' .
|
694 |
+
'It makes exporting and importing 10 times faster.' .
|
695 |
+
'<br />Unfortunately, the new format is not back compatible with backups made with earlier ' .
|
696 |
+
'versions of the plugin.' .
|
697 |
+
'<br />You can either create a new backup with the latest version of the ' .
|
698 |
+
'plugin, or convert the archive to the new format using our tools ' .
|
699 |
+
'<a href="%s" target="_blank">here</a>.',
|
700 |
+
AI1WM_PLUGIN_NAME
|
701 |
+
),
|
702 |
+
AI1WM_ARCHIVE_TOOLS_URL
|
703 |
+
),
|
704 |
+
) );
|
705 |
}
|
706 |
}
|
lib/controller/class-ai1wm-message-controller.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (C) 2014 ServMask Inc.
|
4 |
*
|
@@ -22,9 +23,8 @@
|
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
|
|
25 |
|
26 |
-
class Ai1wm_Message_Controller
|
27 |
-
{
|
28 |
public static function close_message() {
|
29 |
$errors = array();
|
30 |
|
@@ -37,7 +37,6 @@ class Ai1wm_Message_Controller
|
|
37 |
// Close message
|
38 |
$model = new Ai1wm_Message;
|
39 |
$result = $model->close_message( $key );
|
40 |
-
|
41 |
echo json_encode( $result );
|
42 |
exit;
|
43 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (C) 2014 ServMask Inc.
|
5 |
*
|
23 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
*/
|
26 |
+
class Ai1wm_Message_Controller {
|
27 |
|
|
|
|
|
28 |
public static function close_message() {
|
29 |
$errors = array();
|
30 |
|
37 |
// Close message
|
38 |
$model = new Ai1wm_Message;
|
39 |
$result = $model->close_message( $key );
|
|
|
40 |
echo json_encode( $result );
|
41 |
exit;
|
42 |
}
|
lib/controller/class-ai1wm-report-controller.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (C) 2014 ServMask Inc.
|
4 |
*
|
@@ -22,9 +23,8 @@
|
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
|
|
25 |
|
26 |
-
class Ai1wm_Report_Controller
|
27 |
-
{
|
28 |
public static function report_problem() {
|
29 |
// Set E-mail
|
30 |
$email = null;
|
@@ -47,7 +47,6 @@ class Ai1wm_Report_Controller
|
|
47 |
// Send Feedback
|
48 |
$model = new Ai1wm_Report;
|
49 |
$result = $model->report_problem( $email, $message, $terms );
|
50 |
-
|
51 |
echo json_encode( $result );
|
52 |
exit;
|
53 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (C) 2014 ServMask Inc.
|
5 |
*
|
23 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
*/
|
26 |
+
class Ai1wm_Report_Controller {
|
27 |
|
|
|
|
|
28 |
public static function report_problem() {
|
29 |
// Set E-mail
|
30 |
$email = null;
|
47 |
// Send Feedback
|
48 |
$model = new Ai1wm_Report;
|
49 |
$result = $model->report_problem( $email, $message, $terms );
|
|
|
50 |
echo json_encode( $result );
|
51 |
exit;
|
52 |
}
|
lib/exception/class-ai1wm-backup-exception.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (C) 2014 ServMask Inc.
|
5 |
+
*
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, either version 3 of the License, or
|
9 |
+
* (at your option) any later version.
|
10 |
+
*
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* You should have received a copy of the GNU General Public License
|
17 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
+
*
|
19 |
+
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
20 |
+
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
21 |
+
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
22 |
+
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
23 |
+
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
+
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
+
*/
|
26 |
+
class Ai1wm_Backup_Exception extends Exception {
|
27 |
+
|
28 |
+
}
|
lib/exception/class-ai1wm-export-exception.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (C) 2014 ServMask Inc.
|
4 |
*
|
@@ -22,7 +23,6 @@
|
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
|
|
25 |
|
26 |
-
class Ai1wm_Export_Exception extends Exception
|
27 |
-
{
|
28 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (C) 2014 ServMask Inc.
|
5 |
*
|
23 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
*/
|
26 |
+
class Ai1wm_Export_Exception extends Exception {
|
27 |
|
|
|
|
|
28 |
}
|
lib/exception/class-ai1wm-import-exception.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (C) 2014 ServMask Inc.
|
4 |
*
|
@@ -22,7 +23,58 @@
|
|
22 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (C) 2014 ServMask Inc.
|
5 |
*
|
23 |
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
*/
|
26 |
+
class Ai1wm_Import_Exception extends Exception {
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Exception title
|
30 |
+
* @type string
|
31 |
+
*/
|
32 |
+
protected $title;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Extend constructor to accept message and title
|
36 |
+
*
|
37 |
+
* We want to be able to set the title of our modal and default Exception class
|
38 |
+
* doesn't have at title property so we have to extend the constructor to accept one
|
39 |
+
*
|
40 |
+
* @param string $message Exception message
|
41 |
+
* @param string $title Exception title
|
42 |
+
*/
|
43 |
+
public function __construct( $message = '', $title = '' ) {
|
44 |
+
// initialize our parent
|
45 |
+
parent::__construct( $message );
|
46 |
+
|
47 |
+
$this->title = $title;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get exception title
|
52 |
+
*
|
53 |
+
* We check if the title is set and return it if it is,
|
54 |
+
* if title is not set (empty string), we return a default string
|
55 |
+
* Site could not be imported, which should be a catch all phrase
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function get_title() {
|
60 |
+
if ( empty( $this->title ) ) {
|
61 |
+
// no title is set, return default title
|
62 |
+
return __( 'Site could not be imported', AI1WM_PLUGIN_NAME );
|
63 |
+
} else {
|
64 |
+
return $this->title;
|
65 |
+
}
|
66 |
+
}
|
67 |
|
68 |
+
/**
|
69 |
+
* Get exception message
|
70 |
+
*
|
71 |
+
* We are creating our own WordPress code-style compatible function to
|
72 |
+
* return the value of getMessage method of our parent, Exception, class.
|
73 |
+
* This is only necessary so that we have a common way to name our methods
|
74 |
+
*
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function get_message() {
|
78 |
+
return $this->getMessage();
|
79 |
+
}
|
80 |
}
|
lib/exception/class-ai1wm-not-accessible-exception.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (C) 2014 ServMask Inc.
|
5 |
+
*
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, either version 3 of the License, or
|
9 |
+
* (at your option) any later version.
|
10 |
+
*
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* You should have received a copy of the GNU General Public License
|
17 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
+
*
|
19 |
+
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
20 |
+
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
21 |
+
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
22 |
+
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
23 |
+
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
+
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
+
*/
|
26 |
+
class Ai1wm_Not_Accesible_Exception extends Exception {
|
27 |
+
|
28 |
+
}
|
lib/exception/class-ai1wm-not-found-exception.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (C) 2014 ServMask Inc.
|
5 |
+
*
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, either version 3 of the License, or
|
9 |
+
* (at your option) any later version.
|
10 |
+
*
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* You should have received a copy of the GNU General Public License
|
17 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
+
*
|
19 |
+
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
20 |
+
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
21 |
+
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
22 |
+
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
23 |
+
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
+
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
+
*/
|
26 |
+
class Ai1wm_Not_Found_Exception extends Exception {
|
27 |
+
}
|
lib/exception/class-ai1wm-not-readable-exception.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (C) 2014 ServMask Inc.
|
5 |
+
*
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, either version 3 of the License, or
|
9 |
+
* (at your option) any later version.
|
10 |
+
*
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* You should have received a copy of the GNU General Public License
|
17 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
+
*
|
19 |
+
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
20 |
+
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
21 |
+
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
22 |
+
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
23 |
+
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
24 |
+
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
25 |
+
*/
|
26 |
+
class Ai1wm_Not_Readable_Exception extends Exception {
|
27 |
+
|
28 |
+
}
|
lib/exception/class-ai1wm-not-writable-exception.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|