All-in-One WP Migration - Version 3.0.1

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 Icon 128x128 All-in-One WP Migration
Version 3.0.1
Comparing to
See all releases

Code changes from version 2.0.5 to 3.0.1

Files changed (103) hide show
  1. all-in-one-wp-migration.php +10 -1
  2. constants.php +105 -63
  3. lib/controller/class-ai1wm-backup-controller.php +62 -0
  4. lib/controller/class-ai1wm-export-controller.php +88 -67
  5. lib/controller/class-ai1wm-feedback-controller.php +2 -2
  6. lib/controller/class-ai1wm-import-controller.php +94 -142
  7. lib/controller/class-ai1wm-main-controller.php +497 -123
  8. lib/controller/class-ai1wm-message-controller.php +2 -3
  9. lib/controller/class-ai1wm-report-controller.php +2 -3
  10. lib/exception/class-ai1wm-backup-exception.php +28 -0
  11. lib/exception/class-ai1wm-export-exception.php +2 -2
  12. lib/exception/class-ai1wm-import-exception.php +54 -2
  13. lib/exception/class-ai1wm-not-accessible-exception.php +28 -0
  14. lib/exception/class-ai1wm-not-found-exception.php +27 -0
  15. lib/exception/class-ai1wm-not-readable-exception.php +28 -0
  16. lib/exception/class-ai1wm-not-writable-exception.php +28 -0
  17. lib/exception/class-ai1wm-storage-exception.php +28 -0
  18. lib/model/class-ai1wm-backup.php +121 -0
  19. lib/model/class-ai1wm-error.php +4 -4
  20. lib/model/class-ai1wm-export-abstract.php +393 -0
  21. lib/model/class-ai1wm-export-file.php +63 -0
  22. lib/model/class-ai1wm-export.php +0 -152
  23. lib/model/class-ai1wm-feedback.php +9 -10
  24. lib/model/class-ai1wm-import-abstract.php +446 -0
  25. lib/model/{service/class-ai1wm-service-sites.php → class-ai1wm-import-file.php} +42 -62
  26. lib/model/class-ai1wm-import.php +0 -204
  27. lib/model/class-ai1wm-log.php +135 -0
  28. lib/model/class-ai1wm-logger.php +5 -7
  29. lib/model/class-ai1wm-maintenance.php +10 -11
  30. lib/model/class-ai1wm-message.php +18 -17
  31. lib/model/class-ai1wm-report.php +8 -9
  32. lib/model/class-ai1wm-status.php +144 -0
  33. lib/model/class-ai1wm-storage.php +157 -0
  34. lib/model/class-ai1wm-template.php +15 -7
  35. lib/model/service/class-ai1wm-service-database.php +138 -34
  36. lib/model/service/class-ai1wm-service-interface.php +3 -2
  37. lib/model/service/class-ai1wm-service-package.php +85 -21
  38. lib/vendor/bandar/bandar/lib/Bandar.php +170 -164
  39. lib/vendor/bandar/bandar/lib/Exceptions/TemplateDoesNotExistException.php +1 -1
  40. lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpFactory.php +19 -19
  41. lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpInterface.php +238 -255
  42. lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpPDO.php +723 -730
  43. lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpSQL.php +672 -677
  44. lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlFileAdapter.php +22 -22
  45. lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlQueryAdapter.php +74 -61
  46. lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlUtility.php +47 -47
  47. lib/vendor/servmask/archiver/class-ai1wm-archiver.php +235 -0
  48. lib/vendor/servmask/archiver/class-ai1wm-compressor.php +113 -0
  49. lib/vendor/servmask/archiver/class-ai1wm-extractor.php +304 -0
  50. lib/{model/service/class-ai1wm-service-plugins.php → vendor/servmask/cron/class-ai1wm-cron.php} +32 -51
  51. lib/{model/service/class-ai1wm-service-media.php → vendor/servmask/filesystem/class-ai1wm-file.php} +30 -34
  52. lib/vendor/servmask/filter/class-ai1wm-recursive-exclude-filter.php +42 -0
  53. lib/{model/service/class-ai1wm-service-themes.php → vendor/servmask/iterator/class-ai1wm-recursive-directory-iterator.php} +17 -35
  54. lib/vendor/storage-factory/storage-factory/LICENSE +0 -20
  55. lib/vendor/storage-factory/storage-factory/lib/StorageAbstract.php +0 -70
  56. lib/vendor/storage-factory/storage-factory/lib/StorageArea.php +0 -130
  57. lib/vendor/storage-factory/storage-factory/lib/StorageDirectory.php +0 -100
  58. lib/vendor/storage-factory/storage-factory/lib/StorageFile.php +0 -100
  59. lib/vendor/storage-factory/storage-factory/lib/StorageUtility.php +0 -162
  60. lib/vendor/zip-factory/zip-factory/LICENSE +0 -20
  61. lib/vendor/zip-factory/zip-factory/lib/ArchiverInterface.php +0 -118
  62. lib/vendor/zip-factory/zip-factory/lib/ArchiverPclZip.php +0 -218
  63. lib/vendor/zip-factory/zip-factory/lib/ArchiverZipArchive.php +0 -223
  64. lib/vendor/zip-factory/zip-factory/lib/ZipFactory.php +0 -70
  65. lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/gnu-lgpl.txt +0 -504
  66. lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/pclzip.lib.php +0 -5690
  67. lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/readme.txt +0 -421
  68. lib/view/assets/css/backup.min.css +1 -0
  69. lib/view/assets/css/export.min.css +1 -1
  70. lib/view/assets/css/import.min.css +1 -1
  71. lib/view/assets/font/servmask.eot +0 -0
  72. lib/view/assets/font/servmask.svg +6 -0
  73. lib/view/assets/font/servmask.ttf +0 -0
  74. lib/view/assets/font/servmask.woff +0 -0
  75. lib/view/assets/img/logo.svg +69 -0
  76. lib/view/assets/javascript/backup.min.js +1 -0
  77. lib/view/assets/javascript/export.min.js +1 -1
  78. lib/view/assets/javascript/import.min.js +1 -1
  79. lib/view/backup/index.php +140 -0
  80. lib/view/common/export-modal.php +14 -0
  81. lib/view/common/leave-feedback.php +47 -0
  82. lib/view/common/maintenance-mode.php +11 -0
  83. lib/view/common/report-problem.php +26 -0
  84. lib/view/common/share-buttons.php +50 -0
  85. lib/view/export/button-dropbox.php +1 -0
  86. lib/view/export/button-file.php +1 -0
  87. lib/view/export/button-ftp.php +1 -0
  88. lib/view/export/button-gdrive.php +1 -0
  89. lib/view/export/button-s3.php +1 -0
  90. lib/view/export/export-buttons.php +36 -0
  91. lib/view/export/find-replace.php +22 -0
  92. lib/view/export/help-section.php +23 -0
  93. lib/view/export/index.php +21 -282
  94. lib/view/import/button-dropbox.php +1 -0
  95. lib/view/import/button-file.php +1 -0
  96. lib/view/import/button-ftp.php +1 -0
  97. lib/view/import/button-gdrive.php +1 -0
  98. lib/view/import/button-s3.php +1 -0
  99. lib/view/import/import-buttons.php +63 -0
  100. lib/view/import/index.php +12 -198
  101. loader.php +99 -27
  102. readme.txt +57 -54
  103. 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: 2.0.5
 
 
 
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', '2.0.5' );
30
 
31
  // ===============
32
  // = Plugin Name =
33
  // ===============
34
  define( 'AI1WM_PLUGIN_NAME', 'all-in-one-wp-migration' );
35
 
36
- // ===============
37
- // = Storage Index =
38
- // ===============
39
- define( 'AI1WM_STORAGE_INDEX', 'index.php' );
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( 'BANDAR_TEMPLATES_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'view' );
 
 
 
 
 
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
- // = Messages Key =
153
  // ==============
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  define( 'AI1WM_MESSAGES', 'ai1wm_messages' );
155
 
156
- // ==============
 
 
 
 
 
157
  // = Max File Size =
158
- // ==============
159
- define( 'AI1WM_MAX_FILE_SIZE', '512MB' );
160
 
161
- // ==============
162
  // = Max Chunk Size =
163
- // ==============
164
- define( 'AI1WM_MAX_CHUNK_SIZE', '500KB' );
165
 
166
- // ==============
167
  // = Max Chunk Retries =
168
- // ==============
169
- define( 'AI1WM_MAX_CHUNK_RETRIES', '100' );
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
- try {
30
- $is_accessible = StorageArea::getInstance()->getRootPath();
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' => $messages,
43
- 'is_accessible' => $is_accessible,
44
  )
45
  );
46
  }
47
 
48
- public static function export() {
49
- // Set default handlers
50
- set_error_handler( array( 'Ai1wm_Error', 'error_handler' ) );
51
- set_exception_handler( array( 'Ai1wm_Error', 'exception_handler' ) );
52
-
53
- // Get options
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
- // Flush storage
84
- StorageArea::getInstance()->flush();
85
- exit;
86
- }
87
- }
88
 
89
- public static function filename() {
90
- $url = parse_url( home_url() );
91
- $name = array();
 
 
92
 
93
- // Add domain
94
- if ( isset( $url['host'] ) ) {
95
- $name[] = $url['host'];
96
- }
 
 
 
 
 
97
 
98
- // Add path
99
- if ( isset( $url['path'] ) ) {
100
- $name[] = $url['path'];
101
- }
 
102
 
103
- // Add year, month and day
104
- $name[] = date('Ymd');
 
 
 
 
 
 
 
105
 
106
- // Add hours, minutes and seconds
107
- $name[] = date('His');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
- return sprintf( '%s.zip', implode( '-', $name ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- try {
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
- global $wp_rewrite;
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
- if ( isset( $_FILES['upload-file'] ) || isset( $_REQUEST['force'] ) ) {
59
- $options = array(
60
- 'chunk' => 0,
61
- 'chunks' => 1,
62
- 'import' => array(
63
- 'file' => null,
64
- 'force' => null,
65
- ),
66
- );
67
 
68
- // Ordinal number of the current chunk in the set (starts with zero)
69
- if ( isset( $_REQUEST['chunk'] ) ) {
70
- $options['chunk'] = intval( $_REQUEST['chunk'] );
71
  }
72
 
73
- // Total number of chunks in the file
74
- if ( isset( $_REQUEST['chunks'] ) ) {
75
- $options['chunks'] = intval( $_REQUEST['chunks'] );
 
76
  }
77
 
78
- // Import file
79
- if ( isset( $_REQUEST['name'] ) ) {
80
- $options['import']['file'] = $_REQUEST['name'];
 
 
 
 
 
81
  }
82
 
83
- // Force file
84
- if ( isset( $_REQUEST['force'] ) ) {
85
- $options['import']['force'] = $_REQUEST['force'];
 
86
  }
87
 
88
- try {
89
- // Upload file
90
- if ( self::upload( $options ) ) {
91
-
92
- // Import site
93
- $model = new Ai1wm_Import( $options );
94
- if ( $model->import() ) {
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
- // Display messages
124
- echo json_encode( $messages );
125
- exit;
126
- }
 
127
 
128
- public static function upload( $options ) {
129
- $storage = StorageArea::getInstance();
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
- 'Site could not be imported!<br />' .
180
- 'Please contact ServMask Support and report the following error code: %d'
181
- ),
182
- $_FILES['upload-file']['error']
183
  )
184
  );
185
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  }
 
187
 
188
- // Upload completed?
189
- if ( ! $options['chunks'] || $options['chunk'] == $options['chunks'] - 1 ) {
190
- return $partial_file;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  }
192
- exit;
 
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
- AI1WM_PLUGIN_NAME .
36
- DIRECTORY_SEPARATOR .
37
- AI1WM_PLUGIN_NAME .
38
- '.php',
39
  array( $this, 'activation_hook' )
40
  );
41
- $this
42
- ->activate_actions()
43
- ->activate_filters();
 
 
44
  }
45
 
46
  /**
47
  * Activation hook callback
 
48
  * @return Object Instance of this class
49
  */
50
  public function activation_hook() {
51
- // Load plugin text domain.
52
- // $this->load_textdomain();
53
  }
54
 
55
  /**
56
  * Initializes language domain for the plugin
 
57
  * @return Object Instance of this class
58
  */
59
- private function load_textdomain() {
 
 
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
- add_action( 'network_admin_menu', array( $this, 'admin_menu' ) );
 
 
 
 
70
  } else {
71
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
72
  }
73
- add_action( 'admin_head', array( $this, 'admin_head' ) );
74
  add_action( 'admin_init', array( $this, 'router' ) );
75
- add_action( 'wp_ajax_leave_feedback', 'Ai1wm_Feedback_Controller::leave_feedback' );
76
- add_action( 'wp_ajax_report_problem', 'Ai1wm_Report_Controller::report_problem' );
77
- add_action( 'wp_ajax_import', 'Ai1wm_Import_Controller::import' );
78
- add_action( 'wp_ajax_close_message', 'Ai1wm_Message_Controller::close_message' );
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
- * Add a links to plugin list page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  * @return void
91
  */
92
- public function plugin_row_meta( $links, $file ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  if ( $file == AI1WM_PLUGIN_BASENAME ) {
94
- $links[] = sprintf( __( '<a href="%s" target="_blank">Get Support</a>', AI1WM_PLUGIN_NAME ), 'https://servmask.com/#contactModal' );
95
  }
96
 
97
  return $links;
98
  }
99
 
100
  /**
101
- * Register listeners for filters
102
- * @return Object Instance of this class
 
103
  */
104
- private function activate_filters() {
105
- return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
 
108
  /**
109
  * Register plugin menus
 
 
110
  */
111
  public function admin_menu() {
112
  // top level WP Migration menu
113
  add_menu_page(
114
- 'Site Migration',
115
- 'Site Migration',
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( $url ); ?>/font/servmask.eot?v=<?php echo AI1WM_VERSION; ?>');
163
- src:url('<?php echo esc_url( $url ); ?>/font/servmask.eot?v=<?php echo AI1WM_VERSION; ?>#iefix') format('embedded-opentype'),
164
- url('<?php echo esc_url( $url ); ?>/font/servmask.woff?v=<?php echo AI1WM_VERSION; ?>') format('woff'),
165
- url('<?php echo esc_url( $url ); ?>/font/servmask.ttf?v=<?php echo AI1WM_VERSION; ?>') format('truetype'),
166
- url('<?php echo esc_url( $url ); ?>/font/servmask.svg?v=<?php echo AI1WM_VERSION; ?>#servmask') format('svg');
167
  font-weight: normal;
168
  font-style: normal;
169
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  <?php if ( version_compare( $wp_version, '3.8', '<' ) ) : ?>
171
- .toplevel_page_site-migration-export > div.wp-menu-image {
172
- background: none !important;
173
- }
174
- .toplevel_page_site-migration-export > div.wp-menu-image:before {
175
- line-height: 27px !important;
176
- content: '\e603' !important;
177
- font-family: 'servmask' !important;
178
- speak: none !important;
179
- font-style: normal !important;
180
- font-weight: normal !important;
181
- font-variant: normal !important;
182
- text-transform: none !important;
183
- margin-left: 7px;
184
- /* Better Font Rendering =========== */
185
- -webkit-font-smoothing: antialiased !important;
186
- -moz-osx-font-smoothing: grayscale !important;
187
- }
 
 
188
  <?php else : ?>
189
  .toplevel_page_site-migration-export > div.wp-menu-image:before {
190
- content: '\e603' !important;
191
- font-family: 'servmask' !important;
 
 
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
- <?php
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( 'plupload-all', 'jquery' )
215
  );
216
  wp_enqueue_style(
217
  'ai1wm-css-export',
218
  Ai1wm_Template::asset_link( 'css/export.min.css' )
219
  );
220
- $feedback_init = array(
221
  'ajax' => array(
222
- 'url' => admin_url( 'admin-ajax.php' ) . '?action=leave_feedback',
223
  ),
224
- );
225
- wp_localize_script( 'ai1wm-js-export', 'ai1wm_feedback', $feedback_init );
226
- $report_init = array(
227
  'ajax' => array(
228
- 'url' => admin_url( 'admin-ajax.php' ) . '?action=report_problem',
229
  ),
230
- );
231
- wp_localize_script( 'ai1wm-js-export', 'ai1wm_report', $report_init );
232
- $message_init = array(
233
  'ajax' => array(
234
- 'url' => admin_url( 'admin-ajax.php' ) . '?action=close_message',
235
  ),
236
- );
237
- wp_localize_script( 'ai1wm-js-export', 'ai1wm_message', $message_init );
238
- $maintenance_init = array(
239
  'ajax' => array(
240
- 'url' => admin_url( 'admin-ajax.php' ) . '?action=disable_maintenance',
 
 
 
 
 
 
 
 
241
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  );
243
- wp_localize_script( 'ai1wm-js-export', 'ai1wm_maintenance', $maintenance_init );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- $plupload_init = array(
260
  'runtimes' => 'html5,silverlight,flash,html4',
261
- 'browse_button' => 'ai1wm-browse-button',
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
- 'action' => 'import',
 
 
277
  ),
278
  'filters' => array(
279
- array(
280
- 'title' => __( 'Allowed Files' ),
281
- 'extensions' => 'zip',
282
- ),
283
  ),
284
- );
285
- wp_localize_script( 'ai1wm-js-import', 'ai1wm_uploader', $plupload_init );
286
- $feedback_init = array(
287
  'ajax' => array(
288
- 'url' => admin_url( 'admin-ajax.php' ) . '?action=leave_feedback',
289
  ),
290
- );
291
- wp_localize_script( 'ai1wm-js-import', 'ai1wm_feedback', $feedback_init );
292
- $report_init = array(
293
  'ajax' => array(
294
- 'url' => admin_url( 'admin-ajax.php' ) . '?action=report_problem',
295
  ),
296
- );
297
- wp_localize_script( 'ai1wm-js-import', 'ai1wm_report', $report_init );
298
- $maintenance_init = array(
299
  'ajax' => array(
300
- 'url' => admin_url( 'admin-ajax.php' ) . '?action=disable_maintenance',
301
  ),
302
- );
303
- wp_localize_script( 'ai1wm-js-import', 'ai1wm_maintenance', $maintenance_init );
304
- $import_init = array(
305
  'ajax' => array(
306
- 'url' => admin_url( 'admin-ajax.php' ) . '?action=import',
307
  ),
308
- );
309
- wp_localize_script( 'ai1wm-js-import', 'ai1wm_import', $import_init );
310
- }
311
-
312
- /**
313
- * Register initial router
314
- */
315
- public function router() {
316
- if ( isset( $_POST['options']['action'] ) && ( $action = $_POST['options']['action'] ) ) {
317
- switch ( $action ) {
318
- case 'export':
319
- if ( current_user_can( 'export' ) ) {
320
- Ai1wm_Export_Controller::export();
321
- }
322
- break;
323
-
324
- case 'staging':
325
- break;
326
-
327
- case 'production':
328
- break;
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
- class Ai1wm_Import_Exception extends Exception
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 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Writable_Exception extends Exception {
27
+
28
+ }
lib/exception/class-ai1wm-storage-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_Storage_Exception extends Exception {
27
+
28
+ }
lib/model/class-ai1wm-backup.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 {
27
+
28
+ /**
29
+ * Get all backup files
30
+ *
31
+ * @return array
32
+ */
33
+ public function get_files() {
34
+ $backups = array();
35
+
36
+ try {
37
+ $iterator = new RegexIterator(
38
+ new DirectoryIterator( AI1WM_BACKUPS_PATH ),
39
+ '/^(.+)-(\d+)-(\d+)-(\d+)\.wpress$/',
40
+ RegexIterator::GET_MATCH
41
+ );
42
+
43
+ foreach ( $iterator as $item ) {
44
+ try {
45
+ $backup = new Ai1wm_File;
46
+ $backup->setFile( $item[0] );
47
+ $backup->setName( $item[1] );
48
+ $backup->setSize( $iterator->getSize() );
49
+ $backup->setCreatedAt( strtotime( "{$item[2]} {$item[3]}" ) );
50
+
51
+ // Add backup file
52
+ $backups[] = $backup;
53
+ } catch ( Exception $e ) {
54
+ // Log the error
55
+ Ai1wm_Log::error( 'Exception while listing backup file: ' . $e->getMessage() );
56
+ }
57
+ }
58
+ } catch ( Exception $e ) {
59
+ $backups = array();
60
+ }
61
+
62
+ // Sort backups by most recent first
63
+ usort( $backups, array( $this, 'compare' ) );
64
+
65
+ return $backups;
66
+ }
67
+
68
+ /**
69
+ * Delete file
70
+ *
71
+ * @param string $file File name
72
+ * @return boolean
73
+ */
74
+ public function delete_file( $file ) {
75
+ if ( empty( $file ) ) {
76
+ throw new Ai1wm_Backup_Exception( __( 'File name is not specified.', AI1WM_PLUGIN_NAME ) );
77
+ } else if ( ! unlink( AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . $file ) ) {
78
+ throw new Ai1wm_Backup_Exception(
79
+ sprintf(
80
+ __( 'Unable to delete <strong>"%s"</strong> file.', AI1WM_PLUGIN_NAME ),
81
+ AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . $file
82
+ )
83
+ );
84
+ }
85
+
86
+ return true;
87
+ }
88
+
89
+ /**
90
+ * Get free disk space
91
+ *
92
+ * @return integer
93
+ */
94
+ public function get_free_space() {
95
+ return @disk_free_space( AI1WM_BACKUPS_PATH );
96
+ }
97
+
98
+ /**
99
+ * Get total disk space
100
+ *
101
+ * @return integer
102
+ */
103
+ public function get_total_space() {
104
+ return @disk_total_space( AI1WM_BACKUPS_PATH );
105
+ }
106
+
107
+ /**
108
+ * Compare backup files by created at
109
+ *
110
+ * @param Ai1wm_File $a File object
111
+ * @param Ai1wm_File $b File object
112
+ * @return integer
113
+ */
114
+ public function compare( $a, $b ) {
115
+ if ( $a->getCreatedAt() === $b->getCreatedAt() ) {
116
+ return 0;
117
+ }
118
+
119
+ return ( $a->getCreatedAt() > $b->getCreatedAt() ) ? - 1 : 1;
120
+ }
121
+ }
lib/model/class-ai1wm-error.php CHANGED
@@ -23,8 +23,8 @@
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
25
 
26
- class Ai1wm_Error
27
- {
28
  const ERROR_LIMIT = 10;
29
  const EXCEPTION_LIMIT = 10;
30
 
@@ -38,7 +38,7 @@ class Ai1wm_Error
38
  * @return void
39
  */
40
  public static function error_handler( $code, $message, $file, $line ) {
41
- $errors = get_option( AI1WM_ERROR_HANDLER, array() );
42
 
43
  // Limit errors
44
  if ( count( $errors ) > self::ERROR_LIMIT ) {
@@ -64,7 +64,7 @@ class Ai1wm_Error
64
  * @return void
65
  */
66
  public static function exception_handler( $e ) {
67
- $exceptions = get_option( AI1WM_EXCEPTION_HANDLER, array() );
68
 
69
  // Limit errors
70
  if ( count( $exceptions ) > self::EXCEPTION_LIMIT ) {
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
25
 
26
+ class Ai1wm_Error {
27
+
28
  const ERROR_LIMIT = 10;
29
  const EXCEPTION_LIMIT = 10;
30
 
38
  * @return void
39
  */
40
  public static function error_handler( $code, $message, $file, $line ) {
41
+ $errors = get_site_option( AI1WM_ERROR_HANDLER, array() );
42
 
43
  // Limit errors
44
  if ( count( $errors ) > self::ERROR_LIMIT ) {
64
  * @return void
65
  */
66
  public static function exception_handler( $e ) {
67
+ $exceptions = get_site_option( AI1WM_EXCEPTION_HANDLER, array() );
68
 
69
  // Limit errors
70
  if ( count( $exceptions ) > self::EXCEPTION_LIMIT ) {
lib/model/class-ai1wm-export-abstract.php ADDED
@@ -0,0 +1,393 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ abstract class Ai1wm_Export_Abstract {
27
+
28
+ protected $args = array();
29
+
30
+ protected $storage = null;
31
+
32
+ public function __construct( array $args = array() ) {
33
+ $this->args = $args;
34
+ }
35
+
36
+ /**
37
+ * Create empty archive and add package config
38
+ *
39
+ * @return void
40
+ */
41
+ public function start() {
42
+ // Set default progress
43
+ Ai1wm_Status::set( array(
44
+ 'total' => 0,
45
+ 'processed' => 0,
46
+ 'type' => 'info',
47
+ 'message' => __( 'Creating an empty archive...', AI1WM_PLUGIN_NAME )
48
+ ) );
49
+
50
+ // Get package file
51
+ $service = new Ai1wm_Service_Package( $this->args );
52
+ $service->export();
53
+
54
+ // Get archive file
55
+ $archive = new Ai1wm_Compressor( $this->storage()->archive() );
56
+
57
+ // Add package file
58
+ $archive->add_file( $this->storage()->package(), AI1WM_PACKAGE_NAME );
59
+ $archive->close();
60
+
61
+ // Set progress
62
+ Ai1wm_Status::set( array(
63
+ 'message' => __( 'Done creating an empty archive.', AI1WM_PLUGIN_NAME )
64
+ ) );
65
+
66
+ // Redirect
67
+ $this->route_to( 'enumerate' );
68
+ }
69
+
70
+ /**
71
+ * Enumerate content files and directories
72
+ *
73
+ * @return void
74
+ */
75
+ public function enumerate() {
76
+ // Set progress
77
+ Ai1wm_Status::set( array(
78
+ 'message' => __( 'Retrieving a list of all WordPress files...', AI1WM_PLUGIN_NAME )
79
+ ) );
80
+
81
+ // Enable maintenance mode
82
+ if ( apply_filters( 'ai1wm-enable-maintenance-on-export', false ) ) {
83
+ Ai1wm_Maintenance::enable();
84
+ }
85
+
86
+ // Set exclude filters
87
+ $exclude = apply_filters( 'ai1wm_exclude_content_from_export', array(
88
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration',
89
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-dropbox-extension',
90
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-gdrive-extension',
91
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-s3-extension',
92
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-multisite-extension',
93
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-unlimited-extension',
94
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-pro-extension',
95
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-ftp-extension',
96
+ ) );
97
+
98
+ // Create map file
99
+ $filemap = fopen( $this->storage()->filemap(), 'a+' );
100
+
101
+ // Total files
102
+ $total = 0;
103
+
104
+ // Iterate over WP_CONTENT_DIR directory
105
+ $iterator = new RecursiveIteratorIterator(
106
+ new Ai1wm_Recursive_Exclude_Filter(
107
+ new Ai1wm_Recursive_Directory_Iterator(
108
+ WP_CONTENT_DIR
109
+ ),
110
+ $exclude
111
+ ),
112
+ RecursiveIteratorIterator::SELF_FIRST
113
+ );
114
+
115
+ foreach ( $iterator as $item ) {
116
+ if ( $item->isFile() ) {
117
+ // Write path line
118
+ if ( fwrite( $filemap, $iterator->getSubPathName() . PHP_EOL ) ) {
119
+ $total++;
120
+ }
121
+ }
122
+ }
123
+
124
+ fclose( $filemap );
125
+
126
+ // Set progress
127
+ Ai1wm_Status::set( array(
128
+ 'total' => $total,
129
+ 'message' => __( 'Done retrieving a list of all WordPress files.', AI1WM_PLUGIN_NAME )
130
+ ) );
131
+
132
+ // Redirect
133
+ $this->route_to( 'content' );
134
+ }
135
+
136
+ /**
137
+ * Add content files and directories
138
+ *
139
+ * @return void
140
+ */
141
+ public function content() {
142
+ // Total and processed files
143
+ $total = (int) Ai1wm_Status::get( 'total' );
144
+ $processed = (int) Ai1wm_Status::get( 'processed' );
145
+
146
+ // What percent of files have we processed?
147
+ $progress = @(int) ( ( $processed / $total ) * 100 );
148
+
149
+ // Set progress
150
+ Ai1wm_Status::set( array(
151
+ 'message' => sprintf( __( 'Archiving %d files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $total, $progress )
152
+ ) );
153
+
154
+ // Get map file
155
+ $filemap = fopen( $this->storage()->filemap(), 'r' );
156
+
157
+ // Start time
158
+ $start = microtime( true );
159
+
160
+ // Flag to hold if all files have been processed
161
+ $completed = true;
162
+
163
+ // Set file map pointer at the current index
164
+ if ( fseek( $filemap, $this->pointer() ) !== -1 ) {
165
+ // Get archive
166
+ $archive = new Ai1wm_Compressor( $this->storage()->archive() );
167
+
168
+ while ( $path = trim( fgets( $filemap ) ) ) {
169
+ // Add file to archive
170
+ $archive->add_file( WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $path, $path );
171
+
172
+ $processed++;
173
+
174
+ // time elapsed
175
+ $time = microtime( true ) - $start;
176
+
177
+ if ( $time > 3 ) {
178
+ // More than 3 seconds have passed, break and do another request
179
+ $completed = false;
180
+ break;
181
+ }
182
+ }
183
+
184
+ $archive->close();
185
+ }
186
+
187
+ // Set new file map pointer
188
+ $this->pointer( ftell( $filemap ) );
189
+
190
+ fclose( $filemap );
191
+
192
+ // Set progress
193
+ Ai1wm_Status::set( array( 'processed' => $processed ) );
194
+
195
+ // Redirect
196
+ if ( $completed ) {
197
+ // Redirect
198
+ $this->route_to( 'database' );
199
+ } else {
200
+ $this->route_to( 'content' );
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Add database
206
+ *
207
+ * @return void
208
+ */
209
+ public function database() {
210
+ // Set exclude database
211
+ if ( apply_filters( 'ai1wm_exclude_database_from_export', false ) ) {
212
+ return $this->route_to( 'export' );
213
+ }
214
+
215
+ // Set progress
216
+ Ai1wm_Status::set( array( 'message' => __( 'Exporting database...', AI1WM_PLUGIN_NAME ) ) );
217
+
218
+ // Get databsae file
219
+ $service = new Ai1wm_Service_Database( $this->args );
220
+ $service->export();
221
+
222
+ // Get archive file
223
+ $archive = new Ai1wm_Compressor( $this->storage()->archive() );
224
+
225
+ // Add database to archive
226
+ $archive->add_file( $this->storage()->database(), AI1WM_DATABASE_NAME );
227
+ $archive->close();
228
+
229
+ // Set progress
230
+ Ai1wm_Status::set( array( 'message' => __( 'Done exporting database.', AI1WM_PLUGIN_NAME ) ) );
231
+
232
+ // Disable maintenance mode
233
+ if ( apply_filters( 'ai1wm_enable_maintenance_on_export', false ) ) {
234
+ Ai1wm_Maintenance::disable();
235
+ }
236
+
237
+ // Redirect
238
+ $this->route_to( 'export' );
239
+ }
240
+
241
+ /**
242
+ * Stop export and clean storage
243
+ *
244
+ * @return void
245
+ */
246
+ public function stop() {
247
+ $this->storage()->clean();
248
+ }
249
+
250
+ /**
251
+ * Clean storage path
252
+ *
253
+ * @return void
254
+ */
255
+ public function clean() {
256
+ $this->storage()->clean();
257
+ }
258
+
259
+ /**
260
+ * Get export package
261
+ *
262
+ * @return void
263
+ */
264
+ abstract public function export();
265
+
266
+ /*
267
+ * Get storage object
268
+ *
269
+ * @return Ai1wm_Storage
270
+ */
271
+ protected function storage() {
272
+ if ( $this->storage === null ) {
273
+ if ( isset( $this->args['archive'] ) ) {
274
+ $this->args['archive'] = basename( $this->args['archive'] );
275
+ } else {
276
+ $this->args['archive'] = $this->filename();
277
+ }
278
+
279
+ $this->storage = new Ai1wm_Storage( $this->args );
280
+ }
281
+
282
+ return $this->storage;
283
+ }
284
+
285
+ /**
286
+ * Get filemap pointer or set new one
287
+ *
288
+ * @param int $pointer Set new file pointer
289
+ * @return int
290
+ */
291
+ protected function pointer( $pointer = null ) {
292
+ if ( ! isset( $this->args['pointer'] ) ) {
293
+ $this->args['pointer'] = 0;
294
+ } else if ( ! is_null( $pointer ) ) {
295
+ $this->args['pointer'] = $pointer;
296
+ }
297
+
298
+ return (int) $this->args['pointer'];
299
+ }
300
+
301
+ /**
302
+ * Get file name
303
+ *
304
+ * @return string
305
+ */
306
+ protected function filename() {
307
+ $url = parse_url( home_url() );
308
+ $name = array();
309
+
310
+ // Add domain
311
+ if ( isset( $url['host'] ) ) {
312
+ $name[] = $url['host'];
313
+ }
314
+
315
+ // Add path
316
+ if ( isset( $url['path'] ) ) {
317
+ $name[] = trim( $url['path'], '/' );
318
+ }
319
+
320
+ // Add year, month and day
321
+ $name[] = date( 'Ymd' );
322
+
323
+ // Add hours, minutes and seconds
324
+ $name[] = date( 'His' );
325
+
326
+ // Add unique identifier
327
+ $name[] = rand( 100, 999 );
328
+
329
+ return sprintf( '%s.wpress', implode( '-', $name ) );
330
+ }
331
+
332
+ /**
333
+ * Get folder name
334
+ *
335
+ * @return string
336
+ */
337
+ protected function foldername() {
338
+ $url = parse_url( home_url() );
339
+ $name = array();
340
+
341
+ // Add domain
342
+ if ( isset( $url['host'] ) ) {
343
+ $name[] = $url['host'];
344
+ }
345
+
346
+ // Add path
347
+ if ( isset( $url['path'] ) ) {
348
+ $name[] = trim( $url['path'] , '/' );
349
+ }
350
+
351
+ return implode( '-', $name );
352
+ }
353
+
354
+ /**
355
+ * Route to method
356
+ *
357
+ * @param string $method Name of the method
358
+ * @return void
359
+ */
360
+ protected function route_to( $method ) {
361
+ // Redirect arguments
362
+ $this->args['method'] = $method;
363
+ $this->args['secret_key'] = get_site_option( AI1WM_SECRET_KEY, false, false );
364
+
365
+ // Check the status of the export, maybe we need to stop it
366
+ if ( ! is_file( $this->storage()->archive() ) ) {
367
+ exit;
368
+ }
369
+
370
+ $headers = array();
371
+
372
+ // HTTP authentication
373
+ $auth_user = get_site_option( AI1WM_AUTH_USER, false, false );
374
+ $auth_password = get_site_option( AI1WM_AUTH_PASSWORD, false, false );
375
+ if ( $auth_user !== false && $auth_password !== false ) {
376
+ $headers['Authorization'] = 'Basic ' . base64_encode( $auth_user . ':' . $auth_password );
377
+ }
378
+
379
+ // HTTP request
380
+ remove_all_filters( 'http_request_args', 1 );
381
+ wp_remote_post(
382
+ admin_url( 'admin-ajax.php?action=ai1wm_export' ),
383
+ array(
384
+ 'timeout' => 5,
385
+ 'blocking' => false,
386
+ 'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
387
+ 'user-agent' => 'ai1wm',
388
+ 'body' => $this->args,
389
+ 'headers' => $headers,
390
+ )
391
+ );
392
+ }
393
+ }
lib/model/class-ai1wm-export-file.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Export_File extends Ai1wm_Export_Abstract {
27
+
28
+ public function export() {
29
+ // Set progress
30
+ Ai1wm_Status::set( array( 'message' => __( 'Renaming exported file...', AI1WM_PLUGIN_NAME ) ) );
31
+
32
+ // Close achive file
33
+ $archive = new Ai1wm_Compressor( $this->storage()->archive() );
34
+
35
+ // Append EOF block
36
+ $archive->close( true );
37
+
38
+ // Rename archive file
39
+ if ( rename( $this->storage()->archive(), $this->storage()->backup() ) ) {
40
+
41
+ // Set progress
42
+ Ai1wm_Status::set(
43
+ array(
44
+ 'type' => 'download',
45
+ 'message' => sprintf(
46
+ __(
47
+ '<a href="%s/%s" class="ai1wm-button-green ai1wm-emphasize">' .
48
+ '<span>Download %s</span>' .
49
+ '<em>Size: %s</em>' .
50
+ '</a>',
51
+ AI1WM_PLUGIN_NAME
52
+ ),
53
+ AI1WM_BACKUPS_URL,
54
+ basename( $this->storage()->backup() ),
55
+ parse_url( home_url(), PHP_URL_HOST ),
56
+ size_format( filesize( $this->storage()->backup() ) )
57
+ )
58
+ ),
59
+ $this->storage()->status() // status.php file
60
+ );
61
+ }
62
+ }
63
+ }
lib/model/class-ai1wm-export.php DELETED
@@ -1,152 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (C) 2014 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
27
- {
28
- protected $options = array();
29
-
30
- public function __construct( array $options = array() ) {
31
- $this->options = $options;
32
- }
33
-
34
- /**
35
- * Export site
36
- *
37
- * @return StorageFile
38
- */
39
- public function export() {
40
- $storage = StorageArea::getInstance();
41
-
42
- // Enable maintenance mode
43
- Ai1wm_Maintenance::enable();
44
-
45
- // Create export file
46
- $export_file = $storage->makeFile();
47
-
48
- // Make archive file
49
- try {
50
- $zip = ZipFactory::makeZipArchiver( $export_file->getName(), ! class_exists( 'ZipArchive' ), true );
51
- } catch ( Exception $e ) {
52
- $zip = ZipFactory::makeZipArchiver( $export_file->getName(), true, true );
53
- }
54
-
55
- // Package
56
- if ( $this->should_export_package() ) {
57
- $service = new Ai1wm_Service_Package( $this->options );
58
- $zip->addFromString( AI1WM_PACKAGE_NAME, $service->export() );
59
- }
60
-
61
- // Database
62
- if ( $this->should_export_database() ) {
63
- $service = new Ai1wm_Service_Database( $this->options );
64
-
65
- // Add database to archive
66
- $zip->addFile( $service->export(), AI1WM_DATABASE_NAME );
67
- }
68
-
69
- // Media
70
- if ( $this->should_export_media() ) {
71
- $service = new Ai1wm_Service_Media( $this->options );
72
-
73
- // Add media to archive
74
- $zip->addDir( $service->export(), AI1WM_MEDIA_NAME );
75
-
76
- // Sites (Network mode)
77
- $service = new Ai1wm_Service_Sites( $this->options );
78
- if ( ( $sites = $service->export() ) ) {
79
- // Add sites to archive
80
- $zip->addDir( $sites, AI1WM_SITES_NAME );
81
- }
82
- }
83
-
84
- // Themes
85
- if ( $this->should_export_themes() ) {
86
- $service = new Ai1wm_Service_Themes( $this->options );
87
-
88
- // Add themes to archive
89
- $zip->addDir( $service->export(), AI1WM_THEMES_NAME );
90
- }
91
-
92
- // Plugins
93
- if ( $this->should_export_plugins() ) {
94
- $service = new Ai1wm_Service_Plugins( $this->options );
95
-
96
- // Add plugins to archive
97
- if ( ( $plugins = $service->get_installed_plugins() ) ) {
98
- $zip->addDir( $service->export(), AI1WM_PLUGINS_NAME, $plugins );
99
- }
100
- }
101
-
102
- // Disable maintenance mode
103
- Ai1wm_Maintenance::disable();
104
-
105
- return $export_file;
106
- }
107
-
108
- /**
109
- * Should export package?
110
- *
111
- * @return boolean
112
- */
113
- public function should_export_package() {
114
- return true;
115
- }
116
-
117
- /**
118
- * Should export database?
119
- *
120
- * @return boolean
121
- */
122
- public function should_export_database() {
123
- return ! isset( $this->options['export-database'] );
124
- }
125
-
126
- /**
127
- * Should export media?
128
- *
129
- * @return boolean
130
- */
131
- public function should_export_media() {
132
- return ! isset( $this->options['export-media'] );
133
- }
134
-
135
- /**
136
- * Should export themes?
137
- *
138
- * @return boolean
139
- */
140
- public function should_export_themes() {
141
- return ! isset( $this->options['export-themes'] );
142
- }
143
-
144
- /**
145
- * Should export plugins?
146
- *
147
- * @return boolean
148
- */
149
- public function should_export_plugins() {
150
- return ! isset( $this->options['export-plugins'] );
151
- }
152
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/model/class-ai1wm-feedback.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
27
- {
28
  /**
29
  * Submit customer feedback to ServMask.com
30
  *
@@ -32,11 +32,11 @@ class Ai1wm_Feedback
32
  * @param string $email User E-mail
33
  * @param string $message User Message
34
  * @param integer $terms User Accept Terms
 
35
  * @return array
36
  */
37
  public function leave_feedback( $type, $email, $message, $terms ) {
38
  $errors = array();
39
-
40
  // Submit feedback to ServMask
41
  if ( empty( $type ) ) {
42
  $errors[] = 'Feedback type is invalid.';
@@ -51,16 +51,15 @@ class Ai1wm_Feedback
51
  AI1WM_FEEDBACK_URL,
52
  array(
53
  'body' => array(
54
- 'type' => $type,
55
- 'email' => $email,
56
- 'message' => $message,
57
- 'export_options' => json_encode( get_option( AI1WM_EXPORT_OPTIONS, array() ) ),
58
- 'error_handler' => json_encode( get_option( AI1WM_ERROR_HANDLER, array() ) ),
59
- 'exception_handler' => json_encode( get_option( AI1WM_EXCEPTION_HANDLER, array() ) ),
60
  ),
61
  )
62
  );
63
-
64
  if ( is_wp_error( $response ) ) {
65
  $errors[] = 'Something went wrong: ' . $response->get_error_message();
66
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Feedback {
27
 
 
 
28
  /**
29
  * Submit customer feedback to ServMask.com
30
  *
32
  * @param string $email User E-mail
33
  * @param string $message User Message
34
  * @param integer $terms User Accept Terms
35
+ *
36
  * @return array
37
  */
38
  public function leave_feedback( $type, $email, $message, $terms ) {
39
  $errors = array();
 
40
  // Submit feedback to ServMask
41
  if ( empty( $type ) ) {
42
  $errors[] = 'Feedback type is invalid.';
51
  AI1WM_FEEDBACK_URL,
52
  array(
53
  'body' => array(
54
+ 'type' => $type,
55
+ 'email' => $email,
56
+ 'message' => $message,
57
+ 'export_options' => json_encode( get_site_option( AI1WM_EXPORT_OPTIONS, array() ) ),
58
+ 'error_handler' => json_encode( get_site_option( AI1WM_ERROR_HANDLER, array() ) ),
59
+ 'exception_handler' => json_encode( get_site_option( AI1WM_EXCEPTION_HANDLER, array() ) ),
60
  ),
61
  )
62
  );
 
63
  if ( is_wp_error( $response ) ) {
64
  $errors[] = 'Something went wrong: ' . $response->get_error_message();
65
  }
lib/model/class-ai1wm-import-abstract.php ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ abstract class Ai1wm_Import_Abstract {
27
+
28
+ protected $args = array();
29
+
30
+ protected $storage = null;
31
+
32
+ public function __construct( array $args = array() ) {
33
+ $this->args = $args;
34
+ }
35
+
36
+ /**
37
+ * Unpack archive
38
+ *
39
+ * @return void
40
+ */
41
+ public function start() {
42
+ // Set default progress
43
+ Ai1wm_Status::set( array(
44
+ 'total' => 0,
45
+ 'processed' => 0,
46
+ 'type' => 'info',
47
+ 'message' => __( 'Unpacking archive...', AI1WM_PLUGIN_NAME ),
48
+ ) );
49
+
50
+ // Open the archive file for reading
51
+ $archive = new Ai1wm_Extractor( $this->storage()->archive() );
52
+
53
+ // Unpack package.json and database.sql files
54
+ $archive->extract_by_files_array(
55
+ $this->storage()->path(),
56
+ array(
57
+ AI1WM_PACKAGE_NAME,
58
+ AI1WM_DATABASE_NAME,
59
+ )
60
+ );
61
+
62
+ // Close the archive file
63
+ $archive->close();
64
+
65
+ // Validate the archive file
66
+ if ( $this->validate() ) {
67
+
68
+ // Parse the package file
69
+ $service = new Ai1wm_Service_Package( $this->args );
70
+ if ( $service->import() ) {
71
+ $this->route_to( 'confirm' );
72
+ } else {
73
+ throw new Ai1wm_Import_Exception( __( 'Invalid package.json file.', AI1WM_PLUGIN_NAME ) );
74
+ }
75
+
76
+ } else {
77
+ throw new Ai1wm_Import_Exception(
78
+ __( 'Invalid archive file. It should contain <strong>package.json</strong> file.', AI1WM_PLUGIN_NAME )
79
+ );
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Confirm import
85
+ *
86
+ * @return void
87
+ */
88
+ public function confirm() {
89
+ // Obtain the size of the archive
90
+ $size = @filesize( $this->storage()->archive() );
91
+
92
+ if ( false === $size ) {
93
+ throw new Ai1wm_Not_Accesible_Exception(
94
+ sprintf(
95
+ __(
96
+ 'Unable to get the file size of <strong>"%s"</strong>',
97
+ AI1WM_PLUGIN_NAME
98
+ ),
99
+ $this->storage()->archive()
100
+ )
101
+ );
102
+ }
103
+
104
+ $allowed_size = apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE );
105
+
106
+ // Let's check the size of the file to make sure it is less than the maximum allowed
107
+ if ( ( $allowed_size > 0 ) && ( $size > $allowed_size ) ) {
108
+ throw new Ai1wm_Import_Exception(
109
+ sprintf(
110
+ __(
111
+ 'The file that you are trying to import is over the maximum upload file size limit of %s.' .
112
+ '<br />You can remove this restriction by purchasing our ' .
113
+ '<a href="https://servmask.com/products/unlimited-extension" target="_blank">Unlimited Extension</a>.',
114
+ AI1WM_PLUGIN_NAME
115
+ ),
116
+ apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE )
117
+ )
118
+ );
119
+ }
120
+
121
+ // Set progress
122
+ Ai1wm_Status::set(
123
+ array(
124
+ 'type' => 'confirm',
125
+ 'message' => __(
126
+ 'The import process will overwrite your database, media, plugins, and themes. ' .
127
+ 'Please ensure that you have a backup of your data before proceeding to the next step.',
128
+ AI1WM_PLUGIN_NAME
129
+ ),
130
+ )
131
+ );
132
+ }
133
+
134
+ /**
135
+ * Enumerate content files and directories
136
+ *
137
+ * @return void
138
+ */
139
+ public function enumerate() {
140
+ // Set progress
141
+ Ai1wm_Status::set( array(
142
+ 'type' => 'info',
143
+ 'message' => __( 'Retrieving a list of all WordPress files...', AI1WM_PLUGIN_NAME )
144
+ ) );
145
+
146
+ // Open the archive file for reading
147
+ $archive = new Ai1wm_Extractor( $this->storage()->archive() );
148
+
149
+ // Unpack package.json and database.sql files
150
+ $total = $archive->get_number_of_files();
151
+
152
+ // Substract database.sql and package.json
153
+ $total -= 2;
154
+
155
+ // close the archive file
156
+ $archive->close();
157
+
158
+ // Set progress
159
+ Ai1wm_Status::set( array(
160
+ 'total' => $total,
161
+ 'type' => 'info',
162
+ 'message' => __( 'Done retrieving a list of all WordPress files.', AI1WM_PLUGIN_NAME ),
163
+ ) );
164
+
165
+ // Redirect
166
+ $this->route_to( 'truncate' );
167
+ }
168
+
169
+ /**
170
+ * Truncate content files and directories
171
+ *
172
+ * @return void
173
+ */
174
+ public function truncate() {
175
+ // Enable maintenance mode
176
+ Ai1wm_Maintenance::enable();
177
+
178
+ // Redirect
179
+ $this->route_to( 'content' );
180
+ }
181
+
182
+ /**
183
+ * Add content files and directories
184
+ *
185
+ * @return void
186
+ */
187
+ public function content() {
188
+ // Total and processed files
189
+ $total = Ai1wm_Status::get( 'total' );
190
+ $processed = Ai1wm_Status::get( 'processed' );
191
+ $progress = (int) ( ( $processed / $total ) * 100 ) or $progress = 4;
192
+
193
+ // Set progress
194
+ Ai1wm_Status::set( array(
195
+ 'type' => 'info',
196
+ 'message' => sprintf( __( 'Restoring %d files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $total, $progress ),
197
+ ) );
198
+
199
+ // Start time
200
+ $start = microtime( true );
201
+
202
+ // Flag to hold if all files have been processed
203
+ $completed = true;
204
+
205
+ // Open the archive file for reading
206
+ $archive = new Ai1wm_Extractor( $this->storage()->archive() );
207
+
208
+ // Set the file pointer to the one that we have saved
209
+ $archive->set_file_pointer( null, $this->pointer() );
210
+
211
+ while ( $archive->has_not_reached_eof() ) {
212
+ // Extract a file from archive to wp_content_dir
213
+ $archive->extract_one_file_to( WP_CONTENT_DIR, array(
214
+ AI1WM_PACKAGE_NAME,
215
+ AI1WM_DATABASE_NAME,
216
+ ) );
217
+
218
+ // Increment processed files counter
219
+ $processed++;
220
+
221
+ // We are only extracting files for 5 seconds at a time
222
+ $time = microtime( true ) - $start;
223
+ if ( $time > 5 ) {
224
+ // More than 5 seconds have passed, break and do another request
225
+ $completed = false;
226
+ break;
227
+ }
228
+ }
229
+
230
+ // Set new file map pointer
231
+ $this->pointer( $archive->get_file_pointer() );
232
+
233
+ // Close the archive file
234
+ $archive->close();
235
+
236
+ // Set progress
237
+ Ai1wm_Status::set( array(
238
+ 'processed' => $processed,
239
+ ) );
240
+
241
+ // Redirect
242
+ if ( $completed ) {
243
+ $this->route_to( 'database' );
244
+ } else {
245
+ $this->route_to( 'content' );
246
+ }
247
+ }
248
+
249
+ /**
250
+ * Add database
251
+ *
252
+ * @return void
253
+ */
254
+ public function database() {
255
+ // Set exclude database
256
+ if ( ! is_file( $this->storage()->database() ) ) {
257
+ return $this->route_to( 'finish' );
258
+ }
259
+
260
+ // Display progress
261
+ Ai1wm_Status::set( array(
262
+ 'message' => __( 'Restoring database...', AI1WM_PLUGIN_NAME ),
263
+ ) );
264
+
265
+ // Get database file
266
+ $service = new Ai1wm_Service_Database( $this->args );
267
+ $service->import();
268
+
269
+ // Redirect
270
+ $this->route_to( 'finish' );
271
+ }
272
+
273
+ /**
274
+ * Finish import process
275
+ *
276
+ * @return void
277
+ */
278
+ public function finish() {
279
+ // Set progress
280
+ Ai1wm_Status::set( array(
281
+ 'type' => 'finish',
282
+ 'title' => __( 'Your data has been imported successfuly!', AI1WM_PLUGIN_NAME ),
283
+ 'message' => sprintf(
284
+ __(
285
+ 'You need to perform two more steps:<br />' .
286
+ '<strong>1. You must save your permalinks structure twice. <a class="ai1wm-no-underline" href="%s" target="_blank">Permalinks Settings</a></strong> <small>(opens a new window)</small><br />' .
287
+ '<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> <small>(opens a new window)</small>',
288
+ AI1WM_PLUGIN_NAME
289
+ ),
290
+ admin_url( 'options-permalink.php#submit' )
291
+ )
292
+ ) );
293
+
294
+ // Disable maintenance mode
295
+ Ai1wm_Maintenance::disable();
296
+ }
297
+
298
+ /**
299
+ * Stop import and clean storage
300
+ *
301
+ * @return void
302
+ */
303
+ public function stop() {
304
+ $this->storage->clean();
305
+ }
306
+
307
+ /**
308
+ * Clean storage path
309
+ *
310
+ * @return void
311
+ */
312
+ public function clean() {
313
+ $this->storage()->clean();
314
+ }
315
+
316
+ /**
317
+ * Get import archive
318
+ *
319
+ * @return void
320
+ */
321
+ abstract public function import();
322
+
323
+ /**
324
+ * Validate archive and WP_CONTENT_DIR permissions
325
+ *
326
+ * @return boolean
327
+ */
328
+ protected function validate() {
329
+ if ( is_file( $this->storage()->package() ) ) {
330
+ // Set exclude filters
331
+ $exclude = apply_filters( 'ai1wm_exclude_content_from_import', array(
332
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration',
333
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-dropbox-extension',
334
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-gdrive-extension',
335
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-s3-extension',
336
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-multisite-extension',
337
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-unlimited-extension',
338
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-pro-extension',
339
+ 'plugins' . DIRECTORY_SEPARATOR . 'all-in-one-wp-migration-ftp-extension',
340
+ ) );
341
+
342
+ // Iterate over WP_CONTENT_DIR directory
343
+ $iterator = new RecursiveIteratorIterator(
344
+ new Ai1wm_Recursive_Exclude_Filter(
345
+ new Ai1wm_Recursive_Directory_Iterator(
346
+ WP_CONTENT_DIR
347
+ ),
348
+ $exclude
349
+ ),
350
+ RecursiveIteratorIterator::SELF_FIRST
351
+ );
352
+
353
+ foreach ( $iterator as $item ) {
354
+ if ( ! is_readable( $item->getPathname() ) || ! is_writable( $item->getPathname() ) ) {
355
+ throw new Ai1wm_Import_Exception(
356
+ sprintf(
357
+ __(
358
+ 'Ensure that file permissions are correctly set-up - 775 or 777 to <strong>%s</strong> ' .
359
+ 'directory and all files and folders that it contains.',
360
+ AI1WM_PLUGIN_NAME
361
+ ),
362
+ WP_CONTENT_DIR
363
+ )
364
+ );
365
+ }
366
+ }
367
+
368
+ return true;
369
+ }
370
+
371
+ return false;
372
+ }
373
+
374
+ /*
375
+ * Get storage object
376
+ *
377
+ * @return Ai1wm_Storage
378
+ */
379
+ protected function storage() {
380
+ if ( $this->storage === null ) {
381
+ if ( isset( $this->args['archive'] ) ) {
382
+ $this->args['archive'] = basename( $this->args['archive'] );
383
+ }
384
+
385
+ $this->storage = new Ai1wm_Storage( $this->args );
386
+ }
387
+
388
+ return $this->storage;
389
+ }
390
+
391
+ /**
392
+ * Get filemap pointer or set new one
393
+ *
394
+ * @param int $pointer Set new file pointer
395
+ * @return int
396
+ */
397
+ protected function pointer( $pointer = null ) {
398
+ if ( ! isset( $this->args['pointer'] ) ) {
399
+ $this->args['pointer'] = 0;
400
+ } else if ( ! is_null( $pointer ) ) {
401
+ $this->args['pointer'] = $pointer;
402
+ }
403
+
404
+ return (int) $this->args['pointer'];
405
+ }
406
+
407
+ /**
408
+ * Route to method
409
+ *
410
+ * @param string $method Name of the method
411
+ * @return void
412
+ */
413
+ protected function route_to( $method ) {
414
+ // Redirect arguments
415
+ $this->args['method'] = $method;
416
+ $this->args['secret_key'] = get_site_option( AI1WM_SECRET_KEY, false, false );
417
+
418
+ // Check the status of the import, maybe we need to stop it
419
+ if ( ! is_file( $this->storage()->archive() ) ) {
420
+ exit;
421
+ }
422
+
423
+ $headers = array();
424
+
425
+ // HTTP authentication
426
+ $auth_user = get_site_option( AI1WM_AUTH_USER, false, false );
427
+ $auth_password = get_site_option( AI1WM_AUTH_PASSWORD, false, false );
428
+ if ( $auth_user !== false && $auth_password !== false ) {
429
+ $headers['Authorization'] = 'Basic ' . base64_encode( $auth_user . ':' . $auth_password );
430
+ }
431
+
432
+ // HTTP request
433
+ remove_all_filters( 'http_request_args', 1 );
434
+ wp_remote_post(
435
+ admin_url( 'admin-ajax.php?action=ai1wm_import' ),
436
+ array(
437
+ 'timeout' => 5,
438
+ 'blocking' => false,
439
+ 'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
440
+ 'user-agent' => 'ai1wm',
441
+ 'body' => $this->args,
442
+ 'headers' => $headers,
443
+ )
444
+ );
445
+ }
446
+ }
lib/model/{service/class-ai1wm-service-sites.php → class-ai1wm-import-file.php} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,78 +23,57 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- class Ai1wm_Service_Sites implements Ai1wm_Service_Interface
27
- {
28
- protected $options = array();
29
-
30
- public function __construct( array $options = array() ) {
31
- $this->options = $options;
32
- }
33
-
34
- /**
35
- * Import sites (Network mode)
36
- *
37
- * @return void
38
- */
39
  public function import() {
40
- global $wp_version;
41
-
42
- $storage = StorageArea::getInstance();
43
-
44
- if ( version_compare( $wp_version, '3.5', '<' ) ) {
45
- // Blogs.dir directory
46
- $blogs_dir = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . AI1WM_BLOGS_NAME;
47
- if ( ! is_dir( $blogs_dir ) ) {
48
- mkdir( $blogs_dir );
49
- }
50
-
51
- // Backup blogs.dir files
52
- $backup_blogs_to = $storage->makeDirectory();
53
-
54
- StorageUtility::copy( $blogs_dir, $backup_blogs_to->getName() );
55
-
56
- // Flush blogs.dir files
57
- StorageUtility::flush( $blogs_dir );
58
 
59
- // Import blogs.dir files
60
- StorageUtility::copy( $storage->getRootPath() . AI1WM_SITES_NAME, $blogs_dir );
 
61
  } else {
62
- // Media directory
63
- $upload_dir = wp_upload_dir();
64
- $upload_basedir = $upload_dir['basedir'];
65
- if ( ! is_dir( $upload_basedir ) ) {
66
- mkdir( $upload_basedir );
67
- }
68
 
69
- // Sites directory
70
- $sites_dir = $upload_basedir . DIRECTORY_SEPARATOR . AI1WM_SITES_NAME;
71
- if ( ! is_dir( $sites_dir ) ) {
72
- mkdir( $sites_dir );
73
- }
 
74
 
75
- // Backup sites files
76
- $backup_sites_to = $storage->makeDirectory();
 
 
77
 
78
- StorageUtility::copy( $sites_dir, $backup_sites_to->getName() );
 
79
 
80
- // Flush sites files
81
- StorageUtility::flush( $sites_dir );
 
 
 
 
 
 
 
 
82
 
83
- // Import sites files
84
- StorageUtility::copy( $storage->getRootPath() . AI1WM_SITES_NAME, $sites_dir );
85
- }
86
- }
87
 
88
- /**
89
- * Export sites (Network mode)
90
- *
91
- * @return string
92
- */
93
- public function export() {
94
- $blogs_dir = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . AI1WM_BLOGS_NAME;
95
- if ( is_dir( $blogs_dir ) ) {
96
- return $blogs_dir;
97
  }
98
  }
99
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Import_File extends Ai1wm_Import_Abstract {
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  public function import() {
29
+ // Get upload file
30
+ if ( ! isset( $_FILES['upload-file'] ) ) {
31
+ wp_die( 'Unable to process file upload.' );
32
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ // Set chunk
35
+ if ( isset( $this->args['chunk'] ) ) {
36
+ $chunk = (int) $this->args['chunk'];
37
  } else {
38
+ $chunk = 0;
39
+ }
 
 
 
 
40
 
41
+ // Set chunks
42
+ if ( isset( $this->args['chunks'] ) ) {
43
+ $chunks = (int) $this->args['chunks'];
44
+ } else {
45
+ $chunks = 1;
46
+ }
47
 
48
+ // Set archive
49
+ if ( isset( $this->args['name'] ) ) {
50
+ $this->args['archive'] = $this->args['name'];
51
+ }
52
 
53
+ // Has any upload error?
54
+ if ( empty( $_FILES['upload-file']['error'] ) ) {
55
 
56
+ // Open partial file
57
+ $out = fopen( $this->storage()->archive(), $chunk === 0 ? 'wb' : 'ab' );
58
+ if ( $out ) {
59
+ // Read binary input stream and append it to temp file
60
+ $in = fopen( $_FILES['upload-file']['tmp_name'], 'rb' );
61
+ if ( $in ) {
62
+ while ( $buff = fread( $in, 4096 ) ) {
63
+ fwrite( $out, $buff );
64
+ }
65
+ }
66
 
67
+ fclose( $in );
68
+ fclose( $out );
 
 
69
 
70
+ // Remove temporary uploaded file
71
+ unlink( $_FILES['upload-file']['tmp_name'] );
72
+ } else {
73
+ status_header( 500 );
74
+ }
75
+ } else {
76
+ status_header( 500 );
 
 
77
  }
78
  }
79
  }
lib/model/class-ai1wm-import.php DELETED
@@ -1,204 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (C) 2014 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_Import
27
- {
28
- protected $options = array();
29
-
30
- public function __construct( array $options = array() ) {
31
- $this->options = $options;
32
- }
33
-
34
- /**
35
- * Import site
36
- *
37
- * @return StorageFile
38
- */
39
- public function import() {
40
- global $wp_version;
41
-
42
- $storage = StorageArea::getInstance();
43
-
44
- // Create import file
45
- $import_file = $storage->makeFile( $this->options['import']['file'] );
46
-
47
- // Extract archive
48
- try {
49
- try {
50
- $zip = ZipFactory::makeZipArchiver( $import_file->getName(), ! class_exists( 'ZipArchive' ) );
51
- $zip->extractTo( $storage->getRootPath() );
52
- $zip->close();
53
- } catch ( Exception $e ) {
54
- $zip = ZipFactory::makeZipArchiver( $import_file->getName(), true );
55
- $zip->extractTo( $storage->getRootPath() );
56
- $zip->close();
57
- }
58
- } catch ( Exception $e ) {
59
- throw new Ai1wm_Import_Exception(
60
- _(
61
- 'Site could not be imported!<br />' .
62
- 'Archive file is broken or is not compatible with the plugin! Please verify your archive file.'
63
- )
64
- );
65
- }
66
-
67
- // Verify package
68
- if ( $this->should_import_package() ) {
69
-
70
- // Enable maintenance mode
71
- Ai1wm_Maintenance::enable();
72
-
73
- // Database
74
- if ( $this->should_import_database() ) {
75
- $service = new Ai1wm_Service_Database( $this->options );
76
- $service->import();
77
- }
78
-
79
- // Media
80
- if ( $this->should_import_media() ) {
81
- $service = new Ai1wm_Service_Media( $this->options );
82
- $service->import();
83
- }
84
-
85
- // Sites (Network mode)
86
- if ( $this->should_import_sites() ) {
87
- $service = new Ai1wm_Service_Sites( $this->options );
88
- $service->import();
89
- }
90
-
91
- // Themes
92
- if ( $this->should_import_themes() ) {
93
- $service = new Ai1wm_Service_Themes( $this->options );
94
- $service->import();
95
- }
96
-
97
- // Plugins
98
- if ( $this->should_import_plugins() ) {
99
- $service = new Ai1wm_Service_Plugins( $this->options );
100
- $service->import();
101
- }
102
-
103
- // Disable maintenance mode
104
- Ai1wm_Maintenance::disable();
105
-
106
- } else {
107
- throw new Ai1wm_Import_Exception(
108
- _(
109
- 'Site could not be imported!<br />' .
110
- 'Archive file is not compatible with the plugin! Please verify your archive file.'
111
- )
112
- );
113
- }
114
-
115
- return $import_file;
116
- }
117
-
118
- /**
119
- * Should import package?
120
- *
121
- * @return boolean
122
- */
123
- public function should_import_package() {
124
- global $wp_version;
125
-
126
- // Has package.json file?
127
- if ( ! is_file( StorageArea::getInstance()->getRootPath() . AI1WM_PACKAGE_NAME ) ) {
128
- return false;
129
- }
130
-
131
- // Force import
132
- if ( isset( $this->options['import']['force'] ) ) {
133
- return true;
134
- }
135
-
136
- // Get configuration
137
- $service = new Ai1wm_Service_Package( $this->options );
138
- $config = $service->import();
139
-
140
- // Verify WordPress version
141
- if ( version_compare( $config['WordPress']['Version'], $wp_version, '<=' ) ) {
142
- return true;
143
- } else {
144
- throw new Ai1wm_Import_Exception(
145
- sprintf(
146
- _(
147
- 'You are trying to import data from WordPress v%1$s into WordPress v%2$s, while the process might work,' .
148
- 'we do not recommend this. You should update your WordPress to version %1$s or above and then import the file.' .
149
- 'If you still want to proceed, after making a backup, using the plugin,' .
150
- '<button type="button" class="ai1wm-button-green-small" id="ai1wm-force-import" data-name="%3$s">CLICK HERE TO CONTINUE</button>'
151
- ),
152
- $config['WordPress']['Version'],
153
- $wp_version,
154
- $this->options['import']['file']
155
- )
156
- );
157
- }
158
- }
159
-
160
- /**
161
- * Should import database?
162
- *
163
- * @return boolean
164
- */
165
- public function should_import_database() {
166
- return is_file( StorageArea::getInstance()->getRootPath() . AI1WM_DATABASE_NAME );
167
- }
168
-
169
- /**
170
- * Should import media?
171
- *
172
- * @return boolean
173
- */
174
- public function should_import_media() {
175
- return is_dir( StorageArea::getInstance()->getRootPath() . AI1WM_MEDIA_NAME );
176
- }
177
-
178
- /**
179
- * Should import sites?
180
- *
181
- * @return boolean
182
- */
183
- public function should_import_sites() {
184
- return is_dir( StorageArea::getInstance()->getRootPath() . AI1WM_SITES_NAME );
185
- }
186
-
187
- /**
188
- * Should import themes?
189
- *
190
- * @return boolean
191
- */
192
- public function should_import_themes() {
193
- return is_dir( StorageArea::getInstance()->getRootPath() . AI1WM_THEMES_NAME );
194
- }
195
-
196
- /**
197
- * Should import plugins?
198
- *
199
- * @return boolean
200
- */
201
- public function should_import_plugins() {
202
- return is_dir( StorageArea::getInstance()->getRootPath() . AI1WM_PLUGINS_NAME );
203
- }
204
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/model/class-ai1wm-log.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2014 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_Log {
27
+
28
+ /**
29
+ * Write log message of INFO type
30
+ *
31
+ * @param string $message Log message
32
+ * @return void
33
+ */
34
+ public static function info( $message ) {
35
+ self::write( $message, 'INFO' );
36
+ }
37
+
38
+ /**
39
+ * Write log message of INFO type
40
+ *
41
+ * @param string $message Log message
42
+ * @return void
43
+ */
44
+ public static function error( $message ) {
45
+ self::write( $message, 'ERROR' );
46
+ }
47
+
48
+ /**
49
+ * Write log message with the specified type
50
+ *
51
+ * @param string $message Log message
52
+ * @param string $type Log type
53
+ * @return void
54
+ */
55
+ public static function write( $message, $type = 'INFO' ) {
56
+ // Set date to UTC
57
+ @date_default_timezone_set( 'UTC' );
58
+
59
+ // Build message array
60
+ $_message = array();
61
+
62
+ // Append the date
63
+ $_message[] = '[' . date( 'M d Y H:i:s' ) . ']';
64
+
65
+ // Append the type
66
+ $_message[] = $type;
67
+
68
+ // Append the message
69
+ $_message[] = $message;
70
+
71
+ // Append new line
72
+ $_message[] = PHP_EOL;
73
+
74
+ // Convert message to string
75
+ $_message = implode( ' ', $_message );
76
+
77
+ // Append the message to our error.log and close the file handle
78
+ // only if we can get a handle
79
+ if ( $handle = @fopen( AI1WM_LOG_FILE, 'a' ) ) {
80
+ @fwrite( $handle, $_message );
81
+ @fclose( $handle );
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Error handler
87
+ *
88
+ * @param int $errno Error level
89
+ * @param string $errstr Error message
90
+ * @param string $errfile Error file
91
+ * @param int $errline Error line
92
+ * @return void
93
+ */
94
+ public static function error_handler( $errno, $errstr, $errfile, $errline ) {
95
+ // Only log errors and warnings
96
+ if ( in_array( $errno, array( E_ERROR, E_WARNING ) ) ) {
97
+ // Build message array
98
+ $message = array();
99
+
100
+ // Add an empty line
101
+ $message[] = '';
102
+ $message[] = 'Number: ' . $errno;
103
+ $message[] = 'Message: ' . $errstr;
104
+ $message[] = 'File: ' . $errfile;
105
+ $message[] = 'Line: ' . $errline;
106
+ $message[] = '--------------------------------------------';
107
+
108
+ $message = implode( PHP_EOL, $message );
109
+
110
+ self::write( $message, 'ERROR_HANDLER' );
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Exception handler
116
+ *
117
+ * @param Exception $exception Exception object
118
+ * @return void
119
+ */
120
+ public static function exception_handler( $exception ) {
121
+ $message = array();
122
+
123
+ // Add an empty line
124
+ $message[] = '';
125
+ $message[] = 'Number: ' . $exception->getCode();
126
+ $message[] = 'Message: ' . $exception->getMessage();
127
+ $message[] = 'File: ' . $exception->getFile();
128
+ $message[] = 'Line: ' . $exception->getLine();
129
+ $message[] = '--------------------------------------------';
130
+
131
+ $message = implode( PHP_EOL, $message );
132
+
133
+ self::write( $message, 'EXCEPTION_HANDLER' );
134
+ }
135
+ }
lib/model/class-ai1wm-logger.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_Logger
27
- {
28
  /**
29
  * Log debug data
30
  *
@@ -42,13 +42,11 @@ class Ai1wm_Logger
42
  $data['memory_limit'] = ini_get( 'memory_limit' );
43
  $data['memory_get_peak_usage'] = memory_get_peak_usage();
44
  $data['memory_get_usage'] = memory_get_usage();
45
- $data['ZipArchive'] = class_exists( 'ZipArchive' ) ? 1 : 0;
46
- $data['ZLIB_installed'] = function_exists( 'gzopen' ) ? 1 : 0;
47
  $data['PDO_available'] = class_exists( 'PDO' ) ? 1 : 0;
48
  $data['site_url'] = site_url();
49
  $data['home_url'] = home_url();
50
 
51
- return update_option( $key, $data );
52
  }
53
 
54
  /**
@@ -57,7 +55,7 @@ class Ai1wm_Logger
57
  * @return boolean
58
  */
59
  public static function error( $key, array $data = array() ) {
60
- return update_option( $key, $data );
61
  }
62
 
63
  /**
@@ -66,6 +64,6 @@ class Ai1wm_Logger
66
  * @return boolean
67
  */
68
  public static function info( $key, array $data = array() ) {
69
- return update_option( $key, $data );
70
  }
71
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Logger {
27
 
 
 
28
  /**
29
  * Log debug data
30
  *
42
  $data['memory_limit'] = ini_get( 'memory_limit' );
43
  $data['memory_get_peak_usage'] = memory_get_peak_usage();
44
  $data['memory_get_usage'] = memory_get_usage();
 
 
45
  $data['PDO_available'] = class_exists( 'PDO' ) ? 1 : 0;
46
  $data['site_url'] = site_url();
47
  $data['home_url'] = home_url();
48
 
49
+ return update_site_option( $key, $data );
50
  }
51
 
52
  /**
55
  * @return boolean
56
  */
57
  public static function error( $key, array $data = array() ) {
58
+ return update_site_option( $key, $data );
59
  }
60
 
61
  /**
64
  * @return boolean
65
  */
66
  public static function info( $key, array $data = array() ) {
67
+ return update_site_option( $key, $data );
68
  }
69
  }
lib/model/class-ai1wm-maintenance.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,16 +23,15 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- class Ai1wm_Maintenance
27
- {
28
  /**
29
  * Enable WordPress maintenance mode
30
  *
31
  * @return boolean
32
  */
33
  public static function enable() {
34
- return update_option( AI1WM_MAINTENANCE_MODE, true );
35
  }
36
 
37
  /**
@@ -40,11 +40,11 @@ class Ai1wm_Maintenance
40
  * @return boolean
41
  */
42
  public static function disable() {
43
- update_option( AI1WM_MAINTENANCE_MODE, false );
44
  }
45
 
46
  public static function active() {
47
- return get_option( AI1WM_MAINTENANCE_MODE );
48
  }
49
 
50
  /**
@@ -54,15 +54,14 @@ class Ai1wm_Maintenance
54
  */
55
  public static function display() {
56
  if ( self::active() ) {
57
- $title = _( 'Maintenance Mode' );
58
  $body = sprintf(
59
  '<h1>%s</h1><p>%s<br /><strong>%s%s</strong></p>',
60
- _( 'Website Under Maintenance' ),
61
- _( 'Hi, our Website is currently undergoing scheduled maintenance' ),
62
- _( 'Please check back very soon. ' ),
63
- _( 'Sorry for the inconvenience!' )
64
  );
65
-
66
  wp_die( $body, $title );
67
  }
68
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Maintenance {
27
 
 
 
28
  /**
29
  * Enable WordPress maintenance mode
30
  *
31
  * @return boolean
32
  */
33
  public static function enable() {
34
+ return update_site_option( AI1WM_MAINTENANCE_MODE, true );
35
  }
36
 
37
  /**
40
  * @return boolean
41
  */
42
  public static function disable() {
43
+ return update_site_option( AI1WM_MAINTENANCE_MODE, false );
44
  }
45
 
46
  public static function active() {
47
+ return get_site_option( AI1WM_MAINTENANCE_MODE );
48
  }
49
 
50
  /**
54
  */
55
  public static function display() {
56
  if ( self::active() ) {
57
+ $title = __( 'Maintenance Mode', AI1WM_PLUGIN_NAME );
58
  $body = sprintf(
59
  '<h1>%s</h1><p>%s<br /><strong>%s%s</strong></p>',
60
+ __( 'Website Under Maintenance', AI1WM_PLUGIN_NAME ),
61
+ __( 'Hi, our Website is currently undergoing scheduled maintenance', AI1WM_PLUGIN_NAME ),
62
+ __( 'Please check back very soon. ', AI1WM_PLUGIN_NAME ),
63
+ __( 'Sorry for the inconvenience!', AI1WM_PLUGIN_NAME )
64
  );
 
65
  wp_die( $body, $title );
66
  }
67
  }
lib/model/class-ai1wm-message.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,31 +23,31 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- class Ai1wm_Message
27
- {
28
  protected $messages = array();
29
 
30
  public function __construct() {
31
  $this->messages = array(
32
- 'SiteURLDepricated' => _(
33
  'Since version 1.8.0, Site URL is deprecated.' .
34
- 'Upon import, the plugin auto-detects Site URL and makes necessary changes to the database.'
 
35
  ),
36
  );
37
 
38
  // Prepare messages
39
  $msgs = array();
40
- $keys = get_option( AI1WM_MESSAGES );
41
  foreach ( array_keys( $this->messages ) as $key ) {
42
- if ( ! isset( $keys[$key] ) ) {
43
- $msgs[$key] = true;
44
  }
45
  }
46
 
47
  // Update messages
48
  if ( $msgs ) {
49
- update_option( AI1WM_MESSAGES, $msgs );
50
  }
51
  }
52
 
@@ -57,10 +58,10 @@ class Ai1wm_Message
57
  */
58
  public function get_messages() {
59
  $msgs = array();
60
- $keys = get_option( AI1WM_MESSAGES );
61
  foreach ( $keys as $key => $active ) {
62
- if ( isset( $this->messages[$key] ) && $active ) {
63
- $msgs[$key] = $this->messages[$key];
64
  }
65
  }
66
 
@@ -70,19 +71,19 @@ class Ai1wm_Message
70
  /**
71
  * Close message by key
72
  *
73
- * @param string $key Message key
 
74
  * @return array
75
  */
76
  public function close_message( $key ) {
77
  $errors = array();
78
-
79
- $keys = get_option( AI1WM_MESSAGES );
80
- if ( isset( $keys[$key] ) ) {
81
  // Deactivate message from the list
82
- $keys[$key] = false;
83
 
84
  // Update keys
85
- if ( ! update_option( AI1WM_MESSAGES, $keys ) ) {
86
  $errors[] = 'Something went wrong! Please try again later.';
87
  }
88
  } else {
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Message {
27
 
 
 
28
  protected $messages = array();
29
 
30
  public function __construct() {
31
  $this->messages = array(
32
+ 'SiteURLDepricated' => __(
33
  'Since version 1.8.0, Site URL is deprecated.' .
34
+ 'Upon import, the plugin auto-detects Site URL and makes necessary changes to the database.',
35
+ AI1WM_PLUGIN_NAME
36
  ),
37
  );
38
 
39
  // Prepare messages
40
  $msgs = array();
41
+ $keys = get_site_option( AI1WM_MESSAGES );
42
  foreach ( array_keys( $this->messages ) as $key ) {
43
+ if ( ! isset( $keys[ $key ] ) ) {
44
+ $msgs[ $key ] = true;
45
  }
46
  }
47
 
48
  // Update messages
49
  if ( $msgs ) {
50
+ update_site_option( AI1WM_MESSAGES, $msgs );
51
  }
52
  }
53
 
58
  */
59
  public function get_messages() {
60
  $msgs = array();
61
+ $keys = get_site_option( AI1WM_MESSAGES );
62
  foreach ( $keys as $key => $active ) {
63
+ if ( isset( $this->messages[ $key ] ) && $active ) {
64
+ $msgs[ $key ] = $this->messages[ $key ];
65
  }
66
  }
67
 
71
  /**
72
  * Close message by key
73
  *
74
+ * @param string $key Message key
75
+ *
76
  * @return array
77
  */
78
  public function close_message( $key ) {
79
  $errors = array();
80
+ $keys = get_site_option( AI1WM_MESSAGES );
81
+ if ( isset( $keys[ $key ] ) ) {
 
82
  // Deactivate message from the list
83
+ $keys[ $key ] = false;
84
 
85
  // Update keys
86
+ if ( ! update_site_option( AI1WM_MESSAGES, $keys ) ) {
87
  $errors[] = 'Something went wrong! Please try again later.';
88
  }
89
  } else {
lib/model/class-ai1wm-report.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,20 +23,19 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- class Ai1wm_Report
27
- {
28
  /**
29
  * Submit customer report to ServMask.com
30
  *
31
  * @param string $email User E-mail
32
  * @param string $message User Message
33
  * @param integer $terms User Accept Terms
 
34
  * @return array
35
  */
36
  public function report_problem( $email, $message, $terms ) {
37
  $errors = array();
38
-
39
  // Submit report to ServMask
40
  if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
41
  $errors[] = 'Your email is not valid.';
@@ -48,15 +48,14 @@ class Ai1wm_Report
48
  AI1WM_REPORT_URL,
49
  array(
50
  'body' => array(
51
- 'email' => $email,
52
- 'message' => $message,
53
- 'export_options' => json_encode( get_option( AI1WM_EXPORT_OPTIONS, array() ) ),
54
- 'error_handler' => json_encode( get_option( AI1WM_ERROR_HANDLER, array() ) ),
55
- 'exception_handler' => json_encode( get_option( AI1WM_EXCEPTION_HANDLER, array() ) ),
56
  ),
57
  )
58
  );
59
-
60
  if ( is_wp_error( $response ) ) {
61
  $errors[] = 'Something went wrong: ' . $response->get_error_message();
62
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Report {
27
 
 
 
28
  /**
29
  * Submit customer report to ServMask.com
30
  *
31
  * @param string $email User E-mail
32
  * @param string $message User Message
33
  * @param integer $terms User Accept Terms
34
+ *
35
  * @return array
36
  */
37
  public function report_problem( $email, $message, $terms ) {
38
  $errors = array();
 
39
  // Submit report to ServMask
40
  if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
41
  $errors[] = 'Your email is not valid.';
48
  AI1WM_REPORT_URL,
49
  array(
50
  'body' => array(
51
+ 'email' => $email,
52
+ 'message' => $message,
53
+ 'export_options' => json_encode( get_site_option( AI1WM_EXPORT_OPTIONS, array() ) ),
54
+ 'error_handler' => json_encode( get_site_option( AI1WM_ERROR_HANDLER, array() ) ),
55
+ 'exception_handler' => json_encode( get_site_option( AI1WM_EXCEPTION_HANDLER, array() ) ),
56
  ),
57
  )
58
  );
 
59
  if ( is_wp_error( $response ) ) {
60
  $errors[] = 'Something went wrong: ' . $response->get_error_message();
61
  }
lib/model/class-ai1wm-status.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Status {
27
+
28
+ public static function get( $key = null ) {
29
+ // have we got a status file yet?
30
+ if ( is_file( AI1WM_STATUS_FILE ) ) {
31
+ // open status file for reading
32
+ $handle = @fopen( AI1WM_STATUS_FILE, 'r' );
33
+ if ( false === $handle ) {
34
+ throw new Ai1wm_Not_Accesible_Exception(
35
+ sprintf(
36
+ __( 'Unable to open <strong>"%s"</strong> for reading.', AI1WM_PLUGIN_NAME ),
37
+ AI1WM_STATUS_FILE
38
+ )
39
+ );
40
+ }
41
+
42
+ // holds the content of the file
43
+ $content = '';
44
+ while ( false === feof( $handle ) ) {
45
+ $chunk = @fread( $handle, 512 );
46
+ if ( false === $chunk ) {
47
+ throw new Ai1wm_Not_Readable_Exception(
48
+ sprintf(
49
+ __( 'Unable to read from <strong>"%s"</strong>', AI1WM_PLUGIN_NAME ),
50
+ AI1WM_STATUS_FILE
51
+ )
52
+ );
53
+ }
54
+
55
+ // append the chunk we read from the file to our content
56
+ $content .= $chunk;
57
+ }
58
+
59
+ // do we have something to parse?
60
+ if ( empty( $content ) ) {
61
+ // file is empty, return empty array
62
+ return array();
63
+ }
64
+
65
+ // close status file handle
66
+ fclose( $handle );
67
+
68
+ // decode status
69
+ $data = @json_decode( $content, true );
70
+
71
+ if ( is_null( $data ) ) {
72
+ throw new Exception(
73
+ sprintf(
74
+ __( 'Unable to decode <strong>"%s"</strong> with json_decode', AI1WM_PLUGIN_NAME ),
75
+ $content
76
+ )
77
+ );
78
+ }
79
+
80
+ // are we asking for particular key?
81
+ if ( false === is_null( $key ) ) {
82
+ // is the key available in the data array?
83
+ if ( false === isset( $data[$key] ) ) {
84
+ // key is not available :/
85
+ return false;
86
+ }
87
+
88
+ // give the user the value they asked for
89
+ return $data[$key];
90
+ }
91
+
92
+ // return the full status array
93
+ return $data;
94
+ }
95
+
96
+ // no status file yet, return empty array
97
+ return array();
98
+ }
99
+
100
+ public static function set( $status ) {
101
+ // get old status before truncating file
102
+ $status_old = self::get();
103
+
104
+ // open status file for writing, truncate its content
105
+ $handle = @fopen( AI1WM_STATUS_FILE, 'w' );
106
+ if ( false === $handle ) {
107
+ throw new Ai1wm_Not_Accesible_Exception(
108
+ sprintf(
109
+ __( 'Unable to open <strong>"%s"</strong> for writing.', AI1WM_PLUGIN_NAME ),
110
+ AI1WM_STATUS_FILE
111
+ )
112
+ );
113
+ }
114
+
115
+ // create the status that we want to write to the status file
116
+ $content = json_encode( $status + $status_old ); // union the statuses
117
+
118
+ if ( false === $content ) {
119
+ throw new Exception(
120
+ sprintf(
121
+ __( 'Unable to encode <strong>"%s"</strong> with json_encode', AI1WM_PLUGIN_NAME ),
122
+ print_r( $status + $status_old, true )
123
+ )
124
+ );
125
+ }
126
+
127
+ // write the new status in status file
128
+ $result = @fwrite( $handle, $content );
129
+
130
+ // check if we were able to write to the file
131
+ if ( false === $result ) {
132
+ throw new Ai1wm_Not_Writable_Exception(
133
+ sprintf(
134
+ __( 'Unable to write <strong>"%s"</strong> in <strong>"%s"</strong>.', AI1WM_PLUGIN_NAME ),
135
+ $content,
136
+ AI1WM_STATUS_FILE
137
+ )
138
+ );
139
+ }
140
+
141
+ // close status file handle
142
+ fclose( $handle );
143
+ }
144
+ }
lib/model/class-ai1wm-storage.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Storage {
27
+
28
+ protected $storage = null;
29
+
30
+ protected $archive = null;
31
+
32
+ public function __construct( array $args = array() ) {
33
+ // Set storage
34
+ if ( isset( $args['storage'] ) ) {
35
+ $this->storage = basename( $args['storage'] );
36
+ }
37
+
38
+ // Set archive
39
+ if ( isset( $args['archive'] ) ) {
40
+ $this->archive = basename( $args['archive'] );
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Get storage path
46
+ *
47
+ * @return string
48
+ */
49
+ public function path() {
50
+ if ( ! isset( $this->storage ) ) {
51
+ throw new Ai1wm_Storage_Exception( 'Storage name is not configured.' );
52
+ }
53
+
54
+ // Make storage directory
55
+ $path = AI1WM_STORAGE_PATH . DIRECTORY_SEPARATOR . $this->storage;
56
+ if ( ! is_dir( $path ) ) {
57
+ mkdir( $path );
58
+ }
59
+
60
+ return $path;
61
+ }
62
+
63
+ /**
64
+ * Get archive path
65
+ *
66
+ * @return string
67
+ */
68
+ public function archive() {
69
+ if ( ! isset( $this->archive ) ) {
70
+ throw new Ai1wm_Storage_Exception( 'Archive name is not configured.' );
71
+ }
72
+
73
+ // Use backup if needed for restore purposes
74
+ if ( file_exists( $this->backup() ) ) {
75
+ return $this->backup();
76
+ }
77
+
78
+ return $this->path() . DIRECTORY_SEPARATOR . $this->archive;
79
+ }
80
+
81
+ /**
82
+ * Get backup path
83
+ *
84
+ * @return string
85
+ */
86
+ public function backup() {
87
+ if ( ! isset( $this->archive ) ) {
88
+ throw new Ai1wm_Storage_Exception( 'Archive name is not configured.' );
89
+ }
90
+
91
+ return AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . $this->archive;
92
+ }
93
+
94
+ /**
95
+ * Get package file path
96
+ *
97
+ * @return string
98
+ */
99
+ public function package() {
100
+ return $this->path() . DIRECTORY_SEPARATOR . AI1WM_PACKAGE_NAME;
101
+ }
102
+
103
+ /**
104
+ * Get file map path
105
+ *
106
+ * @return string
107
+ */
108
+ public function filemap() {
109
+ return $this->path() . DIRECTORY_SEPARATOR . AI1WM_FILEMAP_NAME;
110
+ }
111
+
112
+ /**
113
+ * Get database file path
114
+ *
115
+ * @return string
116
+ */
117
+ public function database() {
118
+ return $this->path() . DIRECTORY_SEPARATOR . AI1WM_DATABASE_NAME;
119
+ }
120
+
121
+ /**
122
+ * Get status file path
123
+ *
124
+ * @return string
125
+ */
126
+ public function status() {
127
+ return $this->path() . DIRECTORY_SEPARATOR . AI1WM_STATUS_NAME;
128
+ }
129
+
130
+ /**
131
+ * Clean storage path
132
+ *
133
+ * @return void
134
+ */
135
+ public function clean() {
136
+ $iterator = new RecursiveIteratorIterator(
137
+ new RecursiveDirectoryIterator($this->path()),
138
+ RecursiveIteratorIterator::CHILD_FIRST
139
+ );
140
+
141
+ foreach ($iterator as $item) {
142
+ // Skip dots
143
+ if ($iterator->isDot()) {
144
+ continue;
145
+ }
146
+
147
+ if ($item->isFile()) {
148
+ unlink($item->getPathname());
149
+ } else {
150
+ rmdir($item->getPathname());
151
+ }
152
+ }
153
+
154
+ // Remove storage path
155
+ rmdir($this->path());
156
+ }
157
+ }
lib/model/class-ai1wm-template.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,25 +23,32 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- class Ai1wm_Template extends Bandar
27
- {
28
  /**
29
- * Renders a file and returns its contents bacl
 
30
  * @param string $file View to render
31
  * @param array $args Set of arguments
 
32
  * @return string Rendered view
33
  */
34
- public static function render( $view, $args = array() ) {
35
- parent::render( $view, $args );
36
  }
37
 
38
  /**
39
  * Returns link to an asset file
 
40
  * @param string $asset Asset file
 
41
  * @return string Asset URL
42
  */
43
- public static function asset_link( $asset ) {
44
- return AI1WM_URL . '/lib/view/assets/' . $asset . '?v=' . AI1WM_VERSION;
 
 
 
 
45
  }
46
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Template extends Bandar {
27
 
 
 
28
  /**
29
+ * Renders a file and returns its contents
30
+ *
31
  * @param string $file View to render
32
  * @param array $args Set of arguments
33
+ *
34
  * @return string Rendered view
35
  */
36
+ public static function render( $view, $args = array(), $path = false ) {
37
+ parent::render( $view, $args, $path );
38
  }
39
 
40
  /**
41
  * Returns link to an asset file
42
+ *
43
  * @param string $asset Asset file
44
+ *
45
  * @return string Asset URL
46
  */
47
+ public static function asset_link( $asset, $prefix = 'AI1WM' ) {
48
+ return constant( $prefix . '_URL' ) . '/lib/view/assets/' . $asset . '?v=' . constant( $prefix . '_VERSION' );
49
+ }
50
+
51
+ public static function get_content( $template, $args = array(), $path = false ) {
52
+ return parent::getTemplateContent( $template, $args, $path );
53
  }
54
  }
lib/model/service/class-ai1wm-service-database.php CHANGED
@@ -25,13 +25,14 @@
25
 
26
  class Ai1wm_Service_Database implements Ai1wm_Service_Interface
27
  {
28
- protected $options = array();
 
 
29
 
30
  protected $connection = null;
31
 
32
- public function __construct( array $options = array() ) {
33
- // Set options
34
- $this->options = $options;
35
 
36
  // Make connection
37
  try {
@@ -68,49 +69,143 @@ class Ai1wm_Service_Database implements Ai1wm_Service_Interface
68
  public function import() {
69
  global $wpdb;
70
 
71
- // Backup database
72
- $this->export();
73
-
74
- // Flush database
75
- $this->connection->flush();
76
-
77
  // Get configuration
78
- $service = new Ai1wm_Service_Package( $this->options );
79
  $config = $service->import();
80
 
81
  $old_values = array();
82
  $new_values = array();
83
 
84
  // Get Site URL
85
- if ( isset( $config['SiteURL'] ) && ( $config['SiteURL'] != site_url() ) ) {
86
  $old_values[] = $config['SiteURL'];
87
  $new_values[] = site_url();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
 
90
  // Get Home URL
91
- if ( isset( $config['HomeURL'] ) && ( $config['HomeURL'] != home_url() ) ) {
92
  $old_values[] = $config['HomeURL'];
93
  $new_values[] = home_url();
 
94
 
95
- // Get Domain
96
- $old_domain = parse_url( $config['HomeURL'] );
97
- $new_domain = parse_url( home_url() );
 
 
98
 
99
- // Replace Domain
100
- $old_values[] = sprintf( '%s://%s', $old_domain['scheme'], $old_domain['host'] );
101
- $new_values[] = sprintf( '%s://%s', $new_domain['scheme'], $new_domain['host'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
103
 
104
- $database_file = StorageArea::getInstance()->makeFile( AI1WM_DATABASE_NAME );
 
105
 
106
  // Import database
107
  $this->connection->setOldTablePrefix( AI1WM_TABLE_PREFIX )
108
  ->setNewTablePrefix( $wpdb->prefix )
109
  ->setOldReplaceValues( $old_values )
110
  ->setNewReplaceValues( $new_values )
111
- ->import( $database_file->getName() );
112
 
113
- return $database_file->getName();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
 
116
  /**
@@ -121,24 +216,22 @@ class Ai1wm_Service_Database implements Ai1wm_Service_Interface
121
  public function export() {
122
  global $wpdb;
123
 
124
- $database_file = StorageArea::getInstance()->makeFile();
125
-
126
  // Set include tables
127
  $include_tables = array();
128
- if ( isset( $this->options['include-tables'] ) ) {
129
- $include_tables = $this->options['include-tables'];
130
  }
131
 
132
  // Set exclude tables
133
  $exclude_tables = array();
134
- if ( isset( $this->options['exclude-tables' ] ) ) {
135
- $exclude_tables = $this->options['exclude-tables'];
136
  }
137
 
138
  $clauses = array();
139
 
140
  // Spam comments
141
- if ( isset( $this->options['export-spam-comments'] ) ) {
142
  $clauses[ $wpdb->comments ] = " WHERE comment_approved != 'spam' ";
143
  $clauses[ $wpdb->commentmeta ] = sprintf(
144
  " WHERE comment_id IN ( SELECT comment_ID FROM `%s` WHERE comment_approved != 'spam' ) ",
@@ -147,12 +240,12 @@ class Ai1wm_Service_Database implements Ai1wm_Service_Interface
147
  }
148
 
149
  // Post revisions
150
- if ( isset( $this->options['export-revisions'] ) ) {
151
  $clauses[ $wpdb->posts ] = " WHERE post_type != 'revision' ";
152
  }
153
 
154
  // No table data, but leave Admin account
155
- $no_table_data = isset( $this->options['no-table-data'] );
156
  if ( $no_table_data ) {
157
  $clauses = array();
158
  $clauses[ $wpdb->users ] = ' WHERE id = 1 ';
@@ -162,7 +255,7 @@ class Ai1wm_Service_Database implements Ai1wm_Service_Interface
162
  // Find and replace
163
  $old_values = array();
164
  $new_values = array();
165
- if ( isset( $this->options['replace'] ) && ( $replace = $this->options['replace'] ) ) {
166
  for ( $i = 0; $i < count( $replace['old-value'] ); $i++ ) {
167
  if ( isset( $replace['old-value'][$i] ) && isset( $replace['new-value'][$i] ) ) {
168
  $old_values[] = $replace['old-value'][$i];
@@ -172,7 +265,7 @@ class Ai1wm_Service_Database implements Ai1wm_Service_Interface
172
  }
173
 
174
  // Set dump options
175
- $this->connection->setFileName( $database_file->getName() )
176
  ->setIncludeTables( $include_tables )
177
  ->setExcludeTables( $exclude_tables )
178
  ->setNoTableData( $no_table_data )
@@ -184,7 +277,18 @@ class Ai1wm_Service_Database implements Ai1wm_Service_Interface
184
 
185
  // Export database
186
  $this->connection->export();
 
 
 
 
 
 
 
 
 
 
 
187
 
188
- return $database_file->getName();
189
  }
190
  }
25
 
26
  class Ai1wm_Service_Database implements Ai1wm_Service_Interface
27
  {
28
+ protected $args = array();
29
+
30
+ protected $storage = null;
31
 
32
  protected $connection = null;
33
 
34
+ public function __construct( array $args = array() ) {
35
+ $this->args = $args;
 
36
 
37
  // Make connection
38
  try {
69
  public function import() {
70
  global $wpdb;
71
 
 
 
 
 
 
 
72
  // Get configuration
73
+ $service = new Ai1wm_Service_Package( $this->args );
74
  $config = $service->import();
75
 
76
  $old_values = array();
77
  $new_values = array();
78
 
79
  // Get Site URL
80
+ if ( isset( $config['SiteURL'] ) && ( $config['SiteURL'] !== site_url() ) ) {
81
  $old_values[] = $config['SiteURL'];
82
  $new_values[] = site_url();
83
+
84
+ // Get Domain
85
+ $old_domain = parse_url( $config['SiteURL'] );
86
+ $new_domain = parse_url( site_url() );
87
+
88
+ // Replace Domain
89
+ $old_values[] = sprintf( '%s://%s', $old_domain['scheme'], $old_domain['host'] );
90
+ $new_values[] = sprintf( '%s://%s', $new_domain['scheme'], $new_domain['host'] );
91
+
92
+ // Replace Host
93
+ if ( stripos( site_url(), $old_domain['host'] ) === false && stripos( home_url(), $old_domain['host'] ) === false ) {
94
+ $old_values[] = $old_domain['host'];
95
+ $new_values[] = $new_domain['host'];
96
+ }
97
+
98
+ // Replace Path
99
+ $old_values[] = isset( $old_domain['path'] ) && ( $old_domain['path'] !== '/' ) ? trailingslashit( $old_domain['path'] ) : null;
100
+ $new_values[] = isset( $new_domain['path'] ) ? trailingslashit( $new_domain['path'] ) : '/';
101
  }
102
 
103
  // Get Home URL
104
+ if ( isset( $config['HomeURL'] ) && ( $config['HomeURL'] !== home_url() ) ) {
105
  $old_values[] = $config['HomeURL'];
106
  $new_values[] = home_url();
107
+ }
108
 
109
+ // Get WordPress Content
110
+ if ( isset( $config['WordPress']['Content'] ) && ( $config['WordPress']['Content'] !== WP_CONTENT_DIR ) ) {
111
+ $old_values[] = $config['WordPress']['Content'];
112
+ $new_values[] = WP_CONTENT_DIR;
113
+ }
114
 
115
+ // Get user details
116
+ if ( isset( $config['Import']['User']['Id'] ) && ( $id = $config['Import']['User']['Id'] ) ) {
117
+ $meta = get_userdata( $id );
118
+ $user = array(
119
+ 'user_login' => $meta->user_login,
120
+ 'user_pass' => $meta->user_pass,
121
+ 'user_nicename' => $meta->user_nicename,
122
+ 'user_url' => $meta->user_url,
123
+ 'user_email' => $meta->user_email,
124
+ 'display_name' => $meta->display_name,
125
+ 'nickname' => $meta->nickname,
126
+ 'first_name' => $meta->first_name,
127
+ 'last_name' => $meta->last_name,
128
+ 'description' => $meta->description,
129
+ 'rich_editing' => $meta->rich_editing,
130
+ 'user_registered' => $meta->user_registered,
131
+ 'jabber' => $meta->jabber,
132
+ 'aim' => $meta->aim,
133
+ 'yim' => $meta->yim,
134
+ 'show_admin_bar_front' => $meta->show_admin_bar_front,
135
+ );
136
+ } else {
137
+ $user = array();
138
  }
139
 
140
+ // Flush database
141
+ $this->connection->flush();
142
 
143
  // Import database
144
  $this->connection->setOldTablePrefix( AI1WM_TABLE_PREFIX )
145
  ->setNewTablePrefix( $wpdb->prefix )
146
  ->setOldReplaceValues( $old_values )
147
  ->setNewReplaceValues( $new_values )
148
+ ->import( $this->storage()->database() );
149
 
150
+ // Set new user identity
151
+ if ( isset( $config['Export']['User']['Id'] ) && ( $id = $config['Export']['User']['Id'] ) ) {
152
+
153
+ // Update user login and password
154
+ if ( isset( $user['user_login'] ) && isset( $user['user_pass'] ) ) {
155
+ $wpdb->update(
156
+ $wpdb->users,
157
+ array( 'user_login' => $user['user_login'], 'user_pass' => $user['user_pass'] ),
158
+ array( 'ID' => $id ),
159
+ array( '%s', '%s' ),
160
+ array( '%d' )
161
+ );
162
+
163
+ // Unset user login
164
+ unset( $user['user_login'] );
165
+
166
+ // Unset user password
167
+ unset( $user['user_pass'] );
168
+ }
169
+
170
+ // Update user details
171
+ $result = wp_update_user( array( 'ID' => $id ) + $user );
172
+
173
+ // Log the error
174
+ if ( is_wp_error( $result ) ) {
175
+ Ai1wm_Log::error( 'Exception while importing user identity: ' . $result->get_error_message() );
176
+ }
177
+ }
178
+
179
+ // Set the new secret key value, and sanitize it
180
+ $value = sanitize_option( AI1WM_SECRET_KEY, $this->args['secret_key'] );
181
+
182
+ // Handle both multi sites and single sites
183
+ if ( is_multisite() ) {
184
+ $result = $wpdb->update(
185
+ $wpdb->sitemeta,
186
+ array( 'meta_value' => $value ),
187
+ array( 'site_id' => $wpdb->siteid, 'meta_key' => AI1WM_SECRET_KEY )
188
+ );
189
+ } else {
190
+ $result = $wpdb->update(
191
+ $wpdb->options,
192
+ array( 'option_value' => $value ),
193
+ array( 'option_name' => AI1WM_SECRET_KEY )
194
+ );
195
+ }
196
+
197
+ // if we were not able to import the secret key, the import can be considered successful
198
+ // but we have to let the user know
199
+ if ( false === $result ) {
200
+ throw new Ai1wm_Import_Exception(
201
+ __(
202
+ 'Your data was imported successfully but we couldn\'t reach the end of import process. You must ' .
203
+ 'refresh this page, login, and save permalinks manually. If you run into any issues, let us ' .
204
+ 'know at support@servmask.com',
205
+ AI1WM_PLUGIN_NAME
206
+ )
207
+ );
208
+ }
209
  }
210
 
211
  /**
216
  public function export() {
217
  global $wpdb;
218
 
 
 
219
  // Set include tables
220
  $include_tables = array();
221
+ if ( isset( $this->args['options']['include-tables'] ) ) {
222
+ $include_tables = $this->args['options']['include-tables'];
223
  }
224
 
225
  // Set exclude tables
226
  $exclude_tables = array();
227
+ if ( isset( $this->args['options']['exclude-tables' ] ) ) {
228
+ $exclude_tables = $this->args['options']['exclude-tables'];
229
  }
230
 
231
  $clauses = array();
232
 
233
  // Spam comments
234
+ if ( isset( $this->args['options']['no-spam-comments'] ) ) {
235
  $clauses[ $wpdb->comments ] = " WHERE comment_approved != 'spam' ";
236
  $clauses[ $wpdb->commentmeta ] = sprintf(
237
  " WHERE comment_id IN ( SELECT comment_ID FROM `%s` WHERE comment_approved != 'spam' ) ",
240
  }
241
 
242
  // Post revisions
243
+ if ( isset( $this->args['options']['no-revisions'] ) ) {
244
  $clauses[ $wpdb->posts ] = " WHERE post_type != 'revision' ";
245
  }
246
 
247
  // No table data, but leave Admin account
248
+ $no_table_data = isset( $this->args['options']['no-table-data'] );
249
  if ( $no_table_data ) {
250
  $clauses = array();
251
  $clauses[ $wpdb->users ] = ' WHERE id = 1 ';
255
  // Find and replace
256
  $old_values = array();
257
  $new_values = array();
258
+ if ( isset( $this->args['options']['replace'] ) && ( $replace = $this->args['options']['replace'] ) ) {
259
  for ( $i = 0; $i < count( $replace['old-value'] ); $i++ ) {
260
  if ( isset( $replace['old-value'][$i] ) && isset( $replace['new-value'][$i] ) ) {
261
  $old_values[] = $replace['old-value'][$i];
265
  }
266
 
267
  // Set dump options
268
+ $this->connection->setFileName( $this->storage()->database() )
269
  ->setIncludeTables( $include_tables )
270
  ->setExcludeTables( $exclude_tables )
271
  ->setNoTableData( $no_table_data )
277
 
278
  // Export database
279
  $this->connection->export();
280
+ }
281
+
282
+ /*
283
+ * Get storage object
284
+ *
285
+ * @return Ai1wm_Storage
286
+ */
287
+ protected function storage() {
288
+ if ( $this->storage === null ) {
289
+ $this->storage = new Ai1wm_Storage( $this->args );
290
+ }
291
 
292
+ return $this->storage;
293
  }
294
  }
lib/model/service/class-ai1wm-service-interface.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,9 +23,9 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- interface Ai1wm_Service_Interface
27
- {
28
  public function import();
 
29
  public function export();
30
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ interface Ai1wm_Service_Interface {
27
 
 
 
28
  public function import();
29
+
30
  public function export();
31
  }
lib/model/service/class-ai1wm-service-package.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,13 +23,14 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
 
 
25
 
26
- class Ai1wm_Service_Package implements Ai1wm_Service_Interface
27
- {
28
- protected $options = array();
29
 
30
- public function __construct( array $options = array() ) {
31
- $this->options = $options;
32
  }
33
 
34
  /**
@@ -39,20 +41,44 @@ class Ai1wm_Service_Package implements Ai1wm_Service_Interface
39
  public function import() {
40
  global $wp_version;
41
 
42
- // Get config file
43
- $data = file_get_contents( StorageArea::getInstance()->getRootPath() . AI1WM_PACKAGE_NAME );
44
-
45
- // Parse config file
46
- $config = json_decode( $data, true );
47
 
48
- // Add plugin version
49
- if ( ! isset( $config['Plugin']['Version'] ) ) {
50
- $config['Plugin']['Version'] = AI1WM_VERSION;
 
51
  }
52
 
53
- // Add wordpress version
54
- if ( ! isset( $config['WordPress']['Version'] ) ) {
55
- $config['WordPress']['Version'] = $wp_version;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  return $config;
@@ -66,13 +92,51 @@ class Ai1wm_Service_Package implements Ai1wm_Service_Interface
66
  public function export() {
67
  global $wp_version;
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  $config = array(
70
- 'SiteURL' => site_url(),
71
- 'HomeURL' => home_url(),
72
- 'Plugin' => array( 'Version' => AI1WM_VERSION ),
73
- 'WordPress' => array( 'Version' => $wp_version ),
74
  );
75
 
76
- return json_encode( $config );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Service_Package implements Ai1wm_Service_Interface {
27
+
28
+ protected $args = array();
29
 
30
+ protected $storage = null;
 
 
31
 
32
+ public function __construct( array $args = array() ) {
33
+ $this->args = $args;
34
  }
35
 
36
  /**
41
  public function import() {
42
  global $wp_version;
43
 
44
+ $config = array();
 
 
 
 
45
 
46
+ // Get package file
47
+ $package = file_get_contents( $this->storage()->package() );
48
+ if ( false === $package ) {
49
+ throw new Ai1wm_Import_Exception( 'Unable to read package.json file' );
50
  }
51
 
52
+ // Get config data
53
+ if ( ( $config = json_decode( $package, true ) ) ) {
54
+
55
+ // Add plugin version
56
+ if ( ! isset( $config['Plugin']['Version'] ) ) {
57
+ $config['Plugin']['Version'] = AI1WM_VERSION;
58
+ }
59
+
60
+ // Add WordPress version
61
+ if ( ! isset( $config['WordPress']['Version'] ) ) {
62
+ $config['WordPress']['Version'] = $wp_version;
63
+ }
64
+
65
+ // Add WordPress content
66
+ if ( ! isset( $config['WordPress']['Content'] ) ) {
67
+ $config['WordPress']['Content'] = WP_CONTENT_DIR;
68
+ }
69
+
70
+ // Add user identity
71
+ if ( ! isset( $config['Import']['User'] ) && ! empty( $config['Export']['User'] ) ) {
72
+ $config['Import']['User'] = array( 'Id' => get_current_user_id() );
73
+
74
+ // Save package file
75
+ $package = file_put_contents( $this->storage()->package(), json_encode( $config ) );
76
+ if ( false === $package ) {
77
+ throw new Ai1wm_Import_Exception( 'Unable to write package.json file' );
78
+ }
79
+ }
80
+ } else {
81
+ throw new Ai1wm_Import_Exception( 'Unable to parse package.json file' );
82
  }
83
 
84
  return $config;
92
  public function export() {
93
  global $wp_version;
94
 
95
+ // Get options
96
+ $options = wp_load_alloptions();
97
+
98
+ // Get Site URL
99
+ $site_url = site_url();
100
+ if ( isset( $options['siteurl'] ) ) {
101
+ $site_url = rtrim( $options['siteurl'], '/' );
102
+ }
103
+
104
+ // Get Home URL
105
+ $home_url = home_url();
106
+ if ( isset( $options['home'] ) ) {
107
+ $home_url = rtrim( $options['home'], '/' );
108
+ }
109
+
110
+ // Default configuration
111
  $config = array(
112
+ 'SiteURL' => $site_url,
113
+ 'HomeURL' => $home_url,
114
+ 'Plugin' => array( 'Version' => AI1WM_VERSION ),
115
+ 'WordPress' => array( 'Version' => $wp_version, 'Content' => WP_CONTENT_DIR ),
116
  );
117
 
118
+ // Get user identity
119
+ if ( apply_filters( 'ai1wm_keep_user_identity_on_export', false ) ) {
120
+ $config['Export']['User'] = array( 'Id' => get_current_user_id() );
121
+ }
122
+
123
+ // Save package file
124
+ $package = file_put_contents( $this->storage()->package(), json_encode( $config ) );
125
+ if ( false === $package ) {
126
+ throw new Ai1wm_Import_Exception( 'Unable to write package.json file' );
127
+ }
128
+ }
129
+
130
+ /*
131
+ * Get storage object
132
+ *
133
+ * @return Ai1wm_Storage
134
+ */
135
+ protected function storage() {
136
+ if ( $this->storage === null ) {
137
+ $this->storage = new Ai1wm_Storage( $this->args );
138
+ }
139
+
140
+ return $this->storage;
141
  }
142
  }
lib/vendor/bandar/bandar/lib/Bandar.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Yani Iliev <yani@iliev.me>
30
  * @copyright 2013 Yani Iliev
31
  * @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 2.1.0
33
  * @link https://github.com/yani-/bandar/
34
  */
35
 
@@ -37,18 +37,18 @@
37
  * Define EOL for CLI and Web
38
  */
39
  if (!defined('BANDAR_EOL')) {
40
- define('BANDAR_EOL', php_sapi_name() === 'cli' ? PHP_EOL : '<br />');
41
  }
42
 
43
  /**
44
  * Include exceptions
45
  */
46
  require_once
47
- dirname(__FILE__) .
48
- DIRECTORY_SEPARATOR .
49
- 'Exceptions' .
50
- DIRECTORY_SEPARATOR .
51
- 'TemplateDoesNotExistException.php';
52
 
53
  /**
54
  * Bandar Main class
@@ -63,161 +63,167 @@ require_once
63
  */
64
  class Bandar
65
  {
66
- /**
67
- * Path to template files
68
- *
69
- * @var string|null
70
- */
71
- public static $templatesPath = null;
72
-
73
- /**
74
- * Template file to output
75
- * @var string|null
76
- */
77
- public static $template = null;
78
-
79
- /**
80
- * Outputs the passed string if Bandar is in debug mode
81
- *
82
- * @param string $str Debug string to output
83
- *
84
- * @return void
85
- */
86
- public static function debug($str)
87
- {
88
- /**
89
- * if debug flag is on, output the string
90
- */
91
- if (defined('BANDAR_DEBUG') && BANDAR_DEBUG) {
92
- echo $str;
93
- }
94
- }
95
-
96
- /**
97
- * Retrieves templatesPath from BANDAR_TEMPLATES_PATH constant
98
- *
99
- * @throws TemplatesPathNotSetException If BANDAR_TEMPLATES_PATH is not defined
100
- *
101
- * @return string|null Templates path
102
- */
103
- public static function getTemplatesPathFromConstant()
104
- {
105
- self::debug(
106
- 'Calling getTemplatesPathFromConstant' . BANDAR_EOL
107
- );
108
- if (defined('BANDAR_TEMPLATES_PATH')) {
109
- return realpath(BANDAR_TEMPLATES_PATH) . DIRECTORY_SEPARATOR;
110
- }
111
- return null;
112
- }
113
-
114
- /**
115
- * Setter for template
116
- *
117
- * @param string $template Template file
118
- *
119
- * @throws TemplateDoesNotExistException If template file is not found
120
- *
121
- * @return null
122
- */
123
- public static function setTemplate($template)
124
- {
125
- self::debug(
126
- 'Calling setTemplate with' . BANDAR_EOL .
127
- '$template = ' . $template . BANDAR_EOL .
128
- 'type of $template is ' . gettype($template) . BANDAR_EOL
129
- );
130
- $template = self::getTemplatesPathFromConstant() . $template;
131
- $template = realpath($template . '.php');
132
- /**
133
- * Check if passed template exist
134
- */
135
- if (self::templateExists($template)) {
136
- self::$template = $template;
137
- } else {
138
- throw new TemplateDoesNotExistException;
139
- }
140
- }
141
-
142
- /**
143
- * Checks if template exists by using file_exists
144
- *
145
- * @param string $template Template file
146
- *
147
- * @return boolean
148
- */
149
- public static function templateExists($template)
150
- {
151
- self::debug(
152
- 'Calling templateExists with ' . BANDAR_EOL .
153
- '$template = ' . $template . BANDAR_EOL .
154
- 'type of $template is ' . gettype($template) . BANDAR_EOL
155
- );
156
- return (!is_dir($template) && is_readable($template));
157
- }
158
-
159
- /**
160
- * Renders a passed template
161
- *
162
- * @param string $template Template name
163
- * @param array $args Variables to pass to the template file
164
- *
165
- * @return string Contents of the template
166
- */
167
- public static function render($template, $args=array())
168
- {
169
- self::debug(
170
- 'Calling render with' .
171
- '$template = ' . $template . BANDAR_EOL .
172
- 'type of $template is ' . gettype($template) . BANDAR_EOL .
173
- '$args = ' . print_r($args, true) . BANDAR_EOL .
174
- 'type of $args is ' . gettype($args) . BANDAR_EOL
175
- );
176
- self::setTemplate($template);
177
- /**
178
- * Extracting passed aguments
179
- */
180
- extract($args);
181
- ob_start();
182
- /**
183
- * Including the view
184
- */
185
- include self::$template;
186
-
187
- return ob_get_flush();
188
- }
189
-
190
- /**
191
- * Returns the content of a passed template
192
- *
193
- * @param string $template Template name
194
- * @param array $args Variables to pass to the template file
195
- *
196
- * @return string Contents of the template
197
- */
198
- public static function getTemplateContent($template, $args=array())
199
- {
200
- self::debug(
201
- 'Calling render with' .
202
- '$template = ' . $template . BANDAR_EOL .
203
- 'type of $template is ' . gettype($template) . BANDAR_EOL .
204
- '$args = ' . print_r($args, true) . BANDAR_EOL .
205
- 'type of $args is ' . gettype($args) . BANDAR_EOL
206
- );
207
- self::setTemplate($template);
208
- /**
209
- * Extracting passed aguments
210
- */
211
- extract($args);
212
- ob_start();
213
- /**
214
- * Including the view
215
- */
216
- include self::$template;
217
-
218
- $content = ob_get_contents();
219
- ob_end_clean();
220
-
221
- return $content;
222
- }
 
 
 
 
 
 
223
  }
29
  * @author Yani Iliev <yani@iliev.me>
30
  * @copyright 2013 Yani Iliev
31
  * @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 3.0.0
33
  * @link https://github.com/yani-/bandar/
34
  */
35
 
37
  * Define EOL for CLI and Web
38
  */
39
  if (!defined('BANDAR_EOL')) {
40
+ define('BANDAR_EOL', php_sapi_name() === 'cli' ? PHP_EOL : '<br />');
41
  }
42
 
43
  /**
44
  * Include exceptions
45
  */
46
  require_once
47
+ dirname(__FILE__) .
48
+ DIRECTORY_SEPARATOR .
49
+ 'Exceptions' .
50
+ DIRECTORY_SEPARATOR .
51
+ 'TemplateDoesNotExistException.php';
52
 
53
  /**
54
  * Bandar Main class
63
  */
64
  class Bandar
65
  {
66
+ /**
67
+ * Path to template files
68
+ *
69
+ * @var string|null
70
+ */
71
+ public static $templatesPath = null;
72
+
73
+ /**
74
+ * Template file to output
75
+ * @var string|null
76
+ */
77
+ public static $template = null;
78
+
79
+ /**
80
+ * Outputs the passed string if Bandar is in debug mode
81
+ *
82
+ * @param string $str Debug string to output
83
+ *
84
+ * @return void
85
+ */
86
+ public static function debug($str)
87
+ {
88
+ /**
89
+ * if debug flag is on, output the string
90
+ */
91
+ if (defined('BANDAR_DEBUG') && BANDAR_DEBUG) {
92
+ echo $str;
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Retrieves templatesPath from BANDAR_TEMPLATES_PATH constant
98
+ *
99
+ * @throws TemplatesPathNotSetException If BANDAR_TEMPLATES_PATH is not defined
100
+ *
101
+ * @return string|null Templates path
102
+ */
103
+ public static function getTemplatesPathFromConstant()
104
+ {
105
+ self::debug(
106
+ 'Calling getTemplatesPathFromConstant' . BANDAR_EOL
107
+ );
108
+ if (defined('BANDAR_TEMPLATES_PATH')) {
109
+ return realpath(BANDAR_TEMPLATES_PATH) . DIRECTORY_SEPARATOR;
110
+ }
111
+ return null;
112
+ }
113
+
114
+ /**
115
+ * Setter for template
116
+ *
117
+ * @param string $template Template file
118
+ *
119
+ * @throws TemplateDoesNotExistException If template file is not found
120
+ *
121
+ * @return null
122
+ */
123
+ public static function setTemplate($template, $path = false)
124
+ {
125
+ self::debug(
126
+ 'Calling setTemplate with' . BANDAR_EOL .
127
+ '$template = ' . $template . BANDAR_EOL .
128
+ 'type of $template is ' . gettype($template) . BANDAR_EOL
129
+ );
130
+
131
+ if ($path) {
132
+ $template = realpath($path) . DIRECTORY_SEPARATOR . $template;
133
+ } else {
134
+ $template = self::getTemplatesPathFromConstant() . $template;
135
+ }
136
+
137
+ $template = realpath($template . '.php');
138
+ /**
139
+ * Check if passed template exist
140
+ */
141
+ if (self::templateExists($template)) {
142
+ self::$template = $template;
143
+ } else {
144
+ throw new TemplateDoesNotExistException;
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Checks if template exists by using file_exists
150
+ *
151
+ * @param string $template Template file
152
+ *
153
+ * @return boolean
154
+ */
155
+ public static function templateExists($template)
156
+ {
157
+ self::debug(
158
+ 'Calling templateExists with ' . BANDAR_EOL .
159
+ '$template = ' . $template . BANDAR_EOL .
160
+ 'type of $template is ' . gettype($template) . BANDAR_EOL
161
+ );
162
+ return (!is_dir($template) && is_readable($template));
163
+ }
164
+
165
+ /**
166
+ * Renders a passed template
167
+ *
168
+ * @param string $template Template name
169
+ * @param array $args Variables to pass to the template file
170
+ *
171
+ * @return string Contents of the template
172
+ */
173
+ public static function render($template, $args=array(), $path = false)
174
+ {
175
+ self::debug(
176
+ 'Calling render with' .
177
+ '$template = ' . $template . BANDAR_EOL .
178
+ 'type of $template is ' . gettype($template) . BANDAR_EOL .
179
+ '$args = ' . print_r($args, true) . BANDAR_EOL .
180
+ 'type of $args is ' . gettype($args) . BANDAR_EOL
181
+ );
182
+ self::setTemplate($template, $path);
183
+ /**
184
+ * Extracting passed aguments
185
+ */
186
+ extract($args);
187
+ ob_start();
188
+ /**
189
+ * Including the view
190
+ */
191
+ include self::$template;
192
+
193
+ return ob_get_flush();
194
+ }
195
+
196
+ /**
197
+ * Returns the content of a passed template
198
+ *
199
+ * @param string $template Template name
200
+ * @param array $args Variables to pass to the template file
201
+ *
202
+ * @return string Contents of the template
203
+ */
204
+ public static function getTemplateContent($template, $args=array(), $path = false)
205
+ {
206
+ self::debug(
207
+ 'Calling render with' .
208
+ '$template = ' . $template . BANDAR_EOL .
209
+ 'type of $template is ' . gettype($template) . BANDAR_EOL .
210
+ '$args = ' . print_r($args, true) . BANDAR_EOL .
211
+ 'type of $args is ' . gettype($args) . BANDAR_EOL
212
+ );
213
+ self::setTemplate($template, $path);
214
+ /**
215
+ * Extracting passed aguments
216
+ */
217
+ extract($args);
218
+ ob_start();
219
+ /**
220
+ * Including the view
221
+ */
222
+ include self::$template;
223
+
224
+ $content = ob_get_contents();
225
+ ob_end_clean();
226
+
227
+ return $content;
228
+ }
229
  }
lib/vendor/bandar/bandar/lib/Exceptions/TemplateDoesNotExistException.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Yani Iliev <yani@iliev.me>
30
  * @copyright 2013 Yani Iliev
31
  * @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 2.1.0
33
  * @link https://github.com/yani-/bandar/
34
  */
35
 
29
  * @author Yani Iliev <yani@iliev.me>
30
  * @copyright 2013 Yani Iliev
31
  * @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 3.0.0
33
  * @link https://github.com/yani-/bandar/
34
  */
35
 
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpFactory.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.9.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,28 +42,28 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.9.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlDumpFactory
49
  {
50
- public static function makeMysqlDump($hostname = 'localhost', $username = '', $password = '', $database = '', $pdo = false)
51
- {
52
- // is PDO class available?
53
- if ($pdo) {
54
- require_once
55
- dirname(__FILE__) .
56
- DIRECTORY_SEPARATOR .
57
- 'MysqlDumpPDO.php';
58
 
59
- return new MysqlDumpPDO($hostname, $username, $password, $database);
60
- } else {
61
- require_once
62
- dirname(__FILE__) .
63
- DIRECTORY_SEPARATOR .
64
- 'MysqlDumpSQL.php';
65
 
66
- return new MysqlDumpSQL($hostname, $username, $password, $database);
67
- }
68
- }
69
  }
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 2.2.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 2.2.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlDumpFactory
49
  {
50
+ public static function makeMysqlDump($hostname = 'localhost', $username = '', $password = '', $database = '', $pdo = false)
51
+ {
52
+ // is PDO class available?
53
+ if ($pdo) {
54
+ require_once
55
+ dirname(__FILE__) .
56
+ DIRECTORY_SEPARATOR .
57
+ 'MysqlDumpPDO.php';
58
 
59
+ return new MysqlDumpPDO($hostname, $username, $password, $database);
60
+ } else {
61
+ require_once
62
+ dirname(__FILE__) .
63
+ DIRECTORY_SEPARATOR .
64
+ 'MysqlDumpSQL.php';
65
 
66
+ return new MysqlDumpSQL($hostname, $username, $password, $database);
67
+ }
68
+ }
69
  }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpInterface.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.9.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,262 +42,245 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.9.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  interface MysqlDumpInterface
49
  {
50
- const MAXLINESIZE = 200000;
51
-
52
- /**
53
- * Define MySQL credentials for the current connection
54
- *
55
- * @param string $hostname MySQL Hostname
56
- * @param string $username MySQL Username
57
- * @param string $password MySQL Password
58
- * @param string $database MySQL Database
59
- * @return void
60
- */
61
- public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '');
62
-
63
- /**
64
- * Export database into a file
65
- *
66
- * @return void
67
- */
68
- public function export();
69
-
70
- /**
71
- * Set output file name
72
- *
73
- * @param string $fileName Name of the output file
74
- * @return MysqlDumpInterface
75
- */
76
- public function setFileName($fileName);
77
-
78
- /**
79
- * Get output file name
80
- *
81
- * @return string
82
- */
83
- public function getFileName();
84
-
85
- /**
86
- * Set old table prefix
87
- *
88
- * @param string $prefix Name of the table prefix
89
- * @return MysqlDumpInterface
90
- */
91
- public function setOldTablePrefix($prefix);
92
-
93
- /**
94
- * Get old table prefix
95
- *
96
- * @return string
97
- */
98
- public function getOldTablePrefix();
99
-
100
- /**
101
- * Set new table prefix
102
- *
103
- * @param string $prefix Name of the table prefix
104
- * @return MysqlDumpInterface
105
- */
106
- public function setNewTablePrefix($prefix);
107
-
108
- /**
109
- * Get new table prefix
110
- *
111
- * @return string
112
- */
113
- public function getNewTablePrefix();
114
-
115
- /**
116
- * Set old replace values
117
- *
118
- * @param array $values List of values
119
- * @return MysqlDumpPDO
120
- */
121
- public function setOldReplaceValues($values);
122
-
123
- /**
124
- * Get old replace values
125
- *
126
- * @return array
127
- */
128
- public function getOldReplaceValues();
129
-
130
- /**
131
- * Set new replace values
132
- *
133
- * @param array $values List of values
134
- * @return MysqlDumpPDO
135
- */
136
- public function setNewReplaceValues($values);
137
-
138
- /**
139
- * Get new replace values
140
- *
141
- * @return array
142
- */
143
- public function getNewReplaceValues();
144
-
145
- /**
146
- * Set query clauses
147
- *
148
- * @param array $clauses List of SQL query clauses
149
- * @return MysqlDumpInterface
150
- */
151
- public function setQueryClauses($clauses);
152
-
153
- /**
154
- * Get query clauses
155
- *
156
- * @return array
157
- */
158
- public function getQueryClauses();
159
-
160
- /**
161
- * Set include tables
162
- *
163
- * @param array $tables List of tables
164
- * @return MysqlDumpInterface
165
- */
166
- public function setIncludeTables($tables);
167
-
168
- /**
169
- * Get include tables
170
- *
171
- * @return array
172
- */
173
- public function getIncludeTables();
174
-
175
- /**
176
- * Set exclude tables
177
- *
178
- * @param array $tables List of tables
179
- * @return MysqlDumpInterface
180
- */
181
- public function setExcludeTables($tables);
182
-
183
- /**
184
- * Get exclude tables
185
- *
186
- * @return array
187
- */
188
- public function getExcludeTables();
189
-
190
- /**
191
- * Set no table data flag
192
- *
193
- * @param bool $flag Do not export table data
194
- * @return MysqlDumpInterface
195
- */
196
- public function setNoTableData($flag);
197
-
198
- /**
199
- * Get no table data flag
200
- *
201
- * @return bool
202
- */
203
- public function getNoTableData();
204
-
205
- /**
206
- * Set add drop table flag
207
- *
208
- * @param bool $flag Add drop table SQL clause
209
- * @return MysqlDumpInterface
210
- */
211
- public function setAddDropTable($flag);
212
-
213
- /**
214
- * Get add drop table flag
215
- *
216
- * @return bool
217
- */
218
- public function getAddDropTable();
219
-
220
- /**
221
- * Set extended insert flag
222
- *
223
- * @param bool $flag Add extended insert SQL clause
224
- * @return MysqlDumpInterface
225
- */
226
- public function setExtendedInsert($flag);
227
-
228
- /**
229
- * Get extended insert flag
230
- *
231
- * @return bool
232
- */
233
- public function getExtendedInsert();
234
-
235
- /**
236
- * Flush database
237
- *
238
- * @return void
239
- */
240
- public function flush();
241
-
242
- /**
243
- * Import database from file
244
- *
245
- * @param string $fileName Name of file
246
- * @return bool
247
- */
248
- public function import($fileName);
249
-
250
- /**
251
- * Get list of tables
252
- *
253
- * @return array
254
- */
255
- public function listTables();
256
-
257
- /**
258
- * Replace table values
259
- *
260
- * @param string $input Table value
261
- * @return string
262
- */
263
- public function replaceTableValues($input);
264
-
265
- /**
266
- * Replace table name prefix
267
- *
268
- * @param string $input Table name
269
- * @return string
270
- */
271
- public function replaceTableNamePrefix($input);
272
-
273
- /**
274
- * Replace create table prefix
275
- *
276
- * @param string $input SQL statement
277
- * @return string
278
- */
279
- public function replaceCreateTablePrefix($input);
280
-
281
- /**
282
- * Replace insert into prefix
283
- *
284
- * @param string $input SQL statement
285
- * @return string
286
- */
287
- public function replaceInsertIntoPrefix($input);
288
-
289
- /**
290
- * Strip table constraints
291
- *
292
- * @param string $input SQL statement
293
- * @return string
294
- */
295
- public function stripTableConstraints($input);
296
-
297
- /**
298
- * Get MySQL connection (lazy loading)
299
- *
300
- * @return resource
301
- */
302
- public function getConnection();
303
  }
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 2.2.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 2.2.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  interface MysqlDumpInterface
49
  {
50
+ /**
51
+ * Define MySQL credentials for the current connection
52
+ *
53
+ * @param string $hostname MySQL Hostname
54
+ * @param string $username MySQL Username
55
+ * @param string $password MySQL Password
56
+ * @param string $database MySQL Database
57
+ * @return void
58
+ */
59
+ public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '');
60
+
61
+ /**
62
+ * Export database into a file
63
+ *
64
+ * @return void
65
+ */
66
+ public function export();
67
+
68
+ /**
69
+ * Set output file name
70
+ *
71
+ * @param string $fileName Name of the output file
72
+ * @return MysqlDumpInterface
73
+ */
74
+ public function setFileName($fileName);
75
+
76
+ /**
77
+ * Get output file name
78
+ *
79
+ * @return string
80
+ */
81
+ public function getFileName();
82
+
83
+ /**
84
+ * Set old table prefix
85
+ *
86
+ * @param string $prefix Name of the table prefix
87
+ * @return MysqlDumpInterface
88
+ */
89
+ public function setOldTablePrefix($prefix);
90
+
91
+ /**
92
+ * Get old table prefix
93
+ *
94
+ * @return string
95
+ */
96
+ public function getOldTablePrefix();
97
+
98
+ /**
99
+ * Set new table prefix
100
+ *
101
+ * @param string $prefix Name of the table prefix
102
+ * @return MysqlDumpInterface
103
+ */
104
+ public function setNewTablePrefix($prefix);
105
+
106
+ /**
107
+ * Get new table prefix
108
+ *
109
+ * @return string
110
+ */
111
+ public function getNewTablePrefix();
112
+
113
+ /**
114
+ * Set old replace values
115
+ *
116
+ * @param array $values List of values
117
+ * @return MysqlDumpPDO
118
+ */
119
+ public function setOldReplaceValues($values);
120
+
121
+ /**
122
+ * Get old replace values
123
+ *
124
+ * @return array
125
+ */
126
+ public function getOldReplaceValues();
127
+
128
+ /**
129
+ * Set new replace values
130
+ *
131
+ * @param array $values List of values
132
+ * @return MysqlDumpPDO
133
+ */
134
+ public function setNewReplaceValues($values);
135
+
136
+ /**
137
+ * Get new replace values
138
+ *
139
+ * @return array
140
+ */
141
+ public function getNewReplaceValues();
142
+
143
+ /**
144
+ * Set query clauses
145
+ *
146
+ * @param array $clauses List of SQL query clauses
147
+ * @return MysqlDumpInterface
148
+ */
149
+ public function setQueryClauses($clauses);
150
+
151
+ /**
152
+ * Get query clauses
153
+ *
154
+ * @return array
155
+ */
156
+ public function getQueryClauses();
157
+
158
+ /**
159
+ * Set include tables
160
+ *
161
+ * @param array $tables List of tables
162
+ * @return MysqlDumpInterface
163
+ */
164
+ public function setIncludeTables($tables);
165
+
166
+ /**
167
+ * Get include tables
168
+ *
169
+ * @return array
170
+ */
171
+ public function getIncludeTables();
172
+
173
+ /**
174
+ * Set exclude tables
175
+ *
176
+ * @param array $tables List of tables
177
+ * @return MysqlDumpInterface
178
+ */
179
+ public function setExcludeTables($tables);
180
+
181
+ /**
182
+ * Get exclude tables
183
+ *
184
+ * @return array
185
+ */
186
+ public function getExcludeTables();
187
+
188
+ /**
189
+ * Set no table data flag
190
+ *
191
+ * @param bool $flag Do not export table data
192
+ * @return MysqlDumpInterface
193
+ */
194
+ public function setNoTableData($flag);
195
+
196
+ /**
197
+ * Get no table data flag
198
+ *
199
+ * @return bool
200
+ */
201
+ public function getNoTableData();
202
+
203
+ /**
204
+ * Set add drop table flag
205
+ *
206
+ * @param bool $flag Add drop table SQL clause
207
+ * @return MysqlDumpInterface
208
+ */
209
+ public function setAddDropTable($flag);
210
+
211
+ /**
212
+ * Get add drop table flag
213
+ *
214
+ * @return bool
215
+ */
216
+ public function getAddDropTable();
217
+
218
+ /**
219
+ * Flush database
220
+ *
221
+ * @return void
222
+ */
223
+ public function flush();
224
+
225
+ /**
226
+ * Import database from file
227
+ *
228
+ * @param string $fileName Name of file
229
+ * @return bool
230
+ */
231
+ public function import($fileName);
232
+
233
+ /**
234
+ * Get list of tables
235
+ *
236
+ * @return array
237
+ */
238
+ public function listTables();
239
+
240
+ /**
241
+ * Replace table values
242
+ *
243
+ * @param string $input Table value
244
+ * @return string
245
+ */
246
+ public function replaceTableValues($input);
247
+
248
+ /**
249
+ * Replace table name prefix
250
+ *
251
+ * @param string $input Table name
252
+ * @return string
253
+ */
254
+ public function replaceTableNamePrefix($input);
255
+
256
+ /**
257
+ * Replace create table prefix
258
+ *
259
+ * @param string $input SQL statement
260
+ * @return string
261
+ */
262
+ public function replaceCreateTablePrefix($input);
263
+
264
+ /**
265
+ * Replace insert into prefix
266
+ *
267
+ * @param string $input SQL statement
268
+ * @return string
269
+ */
270
+ public function replaceInsertIntoPrefix($input);
271
+
272
+ /**
273
+ * Strip table constraints
274
+ *
275
+ * @param string $input SQL statement
276
+ * @return string
277
+ */
278
+ public function stripTableConstraints($input);
279
+
280
+ /**
281
+ * Get MySQL connection (lazy loading)
282
+ *
283
+ * @return resource
284
+ */
285
+ public function getConnection();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpPDO.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.9.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -47,752 +47,745 @@ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlUtility.php';
47
  * @author Bobby Angelov <bobby@servmask.com>
48
  * @copyright 2014 Yani Iliev, Bobby Angelov
49
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
50
- * @version GIT: 1.9.0
51
  * @link https://github.com/yani-/mysqldump-factory/
52
  */
53
  class MysqlDumpPDO implements MysqlDumpInterface
54
  {
55
- protected $hostname = null;
56
 
57
- protected $port = null;
58
 
59
- protected $socket = null;
60
 
61
- protected $username = null;
62
 
63
- protected $password = null;
64
 
65
- protected $database = null;
66
 
67
- protected $fileName = 'dump.sql';
68
 
69
- protected $fileAdapter = null;
70
 
71
- protected $queryAdapter = null;
72
 
73
- protected $connection = null;
74
 
75
- protected $oldTablePrefix = null;
76
 
77
- protected $newTablePrefix = null;
78
 
79
- protected $oldReplaceValues = array();
80
 
81
- protected $newReplaceValues = array();
82
 
83
- protected $queryClauses = array();
84
 
85
- protected $includeTables = array();
86
-
87
- protected $excludeTables = array();
88
-
89
- protected $noTableData = false;
90
-
91
- protected $addDropTable = false;
92
-
93
- protected $extendedInsert = true;
94
-
95
- /**
96
- * Define MySQL credentials for the current connection
97
- *
98
- * @param string $hostname MySQL Hostname
99
- * @param string $username MySQL Username
100
- * @param string $password MySQL Password
101
- * @param string $database MySQL Database
102
- * @return void
103
- */
104
- public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '')
105
- {
106
- $dsn = $this->parseDSN($hostname);
107
-
108
- // Set MySQL credentials
109
- $this->hostname = $dsn['host'];
110
- $this->port = $dsn['port'];
111
- $this->socket = $dsn['socket'];
112
- $this->username = $username;
113
- $this->password = $password;
114
- $this->database = $database;
115
-
116
- // Set Query Adapter
117
- $this->queryAdapter = new MysqlQueryAdapter('mysql');
118
- }
119
-
120
- /**
121
- * Export database into a file
122
- *
123
- * @return void
124
- */
125
- public function export()
126
- {
127
- // Set File Adapter
128
- $this->fileAdapter = new MysqlFileAdapter();
129
-
130
- // Set output file
131
- $this->fileAdapter->open($this->getFileName());
132
-
133
- // Write Headers Formatting dump file
134
- $this->fileAdapter->write($this->getHeader());
135
-
136
- // Listing all tables from database
137
- $tables = array();
138
- foreach ($this->listTables() as $table) {
139
- if (count($this->getIncludeTables()) === 0 || in_array($table, $this->getIncludeTables())) {
140
- $tables[] = $table;
141
- }
142
- }
143
-
144
- // Export Tables
145
- foreach ($tables as $table) {
146
- if (in_array($table, $this->getExcludeTables())) {
147
- continue;
148
- }
149
-
150
- $isTable = $this->getTableStructure($table);
151
- if (true === $isTable) {
152
- $this->listValues($table);
153
- }
154
- }
155
- }
156
-
157
- /**
158
- * Set output file name
159
- *
160
- * @param string $fileName Name of the output file
161
- * @return MysqlDumpPDO
162
- */
163
- public function setFileName($fileName)
164
- {
165
- $this->fileName = $fileName;
166
-
167
- return $this;
168
- }
169
-
170
- /**
171
- * Get output file name
172
- *
173
- * @return string
174
- */
175
- public function getFileName()
176
- {
177
- return $this->fileName;
178
- }
179
-
180
- /**
181
- * Set old table prefix
182
- *
183
- * @param string $prefix Name of the table prefix
184
- * @return MysqlDumpPDO
185
- */
186
- public function setOldTablePrefix($prefix)
187
- {
188
- $this->oldTablePrefix = $prefix;
189
-
190
- return $this;
191
- }
192
-
193
- /**
194
- * Get old table prefix
195
- *
196
- * @return string
197
- */
198
- public function getOldTablePrefix()
199
- {
200
- return $this->oldTablePrefix;
201
- }
202
-
203
- /**
204
- * Set new table prefix
205
- *
206
- * @param string $prefix Name of the table prefix
207
- * @return MysqlDumpPDO
208
- */
209
- public function setNewTablePrefix($prefix)
210
- {
211
- $this->newTablePrefix = $prefix;
212
-
213
- return $this;
214
- }
215
-
216
- /**
217
- * Get new table prefix
218
- *
219
- * @return string
220
- */
221
- public function getNewTablePrefix()
222
- {
223
- return $this->newTablePrefix;
224
- }
225
-
226
- /**
227
- * Set old replace values
228
- *
229
- * @param array $values List of values
230
- * @return MysqlDumpPDO
231
- */
232
- public function setOldReplaceValues($values)
233
- {
234
- $this->oldReplaceValues = $values;
235
-
236
- return $this;
237
- }
238
-
239
- /**
240
- * Get old replace values
241
- *
242
- * @return array
243
- */
244
- public function getOldReplaceValues()
245
- {
246
- return $this->oldReplaceValues;
247
- }
248
-
249
- /**
250
- * Set new replace values
251
- *
252
- * @param array $values List of values
253
- * @return MysqlDumpPDO
254
- */
255
- public function setNewReplaceValues($values)
256
- {
257
- $this->newReplaceValues = $values;
258
-
259
- return $this;
260
- }
261
-
262
- /**
263
- * Get new replace values
264
- *
265
- * @return array
266
- */
267
- public function getNewReplaceValues()
268
- {
269
- return $this->newReplaceValues;
270
- }
271
-
272
- /**
273
- * Set query clauses
274
- *
275
- * @param array $clauses List of SQL query clauses
276
- * @return MysqlDumpPDO
277
- */
278
- public function setQueryClauses($clauses)
279
- {
280
- $this->queryClauses = $clauses;
281
-
282
- return $this;
283
- }
284
-
285
- /**
286
- * Get query clauses
287
- *
288
- * @return array
289
- */
290
- public function getQueryClauses()
291
- {
292
- return $this->queryClauses;
293
- }
294
-
295
- /**
296
- * Set include tables
297
- *
298
- * @param array $tables List of tables
299
- * @return MysqlDumpPDO
300
- */
301
- public function setIncludeTables($tables)
302
- {
303
- $this->includeTables = $tables;
304
-
305
- return $this;
306
- }
307
-
308
- /**
309
- * Get include tables
310
- *
311
- * @return array
312
- */
313
- public function getIncludeTables()
314
- {
315
- return $this->includeTables;
316
- }
317
-
318
- /**
319
- * Set exclude tables
320
- *
321
- * @param array $tables List of tables
322
- * @return MysqlDumpPDO
323
- */
324
- public function setExcludeTables($tables)
325
- {
326
- $this->excludeTables = $tables;
327
-
328
- return $this;
329
- }
330
-
331
- /**
332
- * Get exclude tables
333
- *
334
- * @return array
335
- */
336
- public function getExcludeTables()
337
- {
338
- return $this->excludeTables;
339
- }
340
-
341
- /**
342
- * Set no table data flag
343
- *
344
- * @param bool $flag Do not export table data
345
- * @return MysqlDumpPDO
346
- */
347
- public function setNoTableData($flag)
348
- {
349
- $this->noTableData = (bool) $flag;
350
-
351
- return $this;
352
- }
353
-
354
- /**
355
- * Get no table data flag
356
- *
357
- * @return bool
358
- */
359
- public function getNoTableData()
360
- {
361
- return $this->noTableData;
362
- }
363
-
364
- /**
365
- * Set add drop table flag
366
- *
367
- * @param bool $flag Add drop table SQL clause
368
- * @return MysqlDumpPDO
369
- */
370
- public function setAddDropTable($flag)
371
- {
372
- $this->addDropTable = (bool) $flag;
373
-
374
- return $this;
375
- }
376
-
377
- /**
378
- * Get add drop table flag
379
- *
380
- * @return bool
381
- */
382
- public function getAddDropTable()
383
- {
384
- return $this->addDropTable;
385
- }
386
-
387
- /**
388
- * Set extended insert flag
389
- *
390
- * @param bool $flag Add extended insert SQL clause
391
- * @return MysqlDumpPDO
392
- */
393
- public function setExtendedInsert($flag)
394
- {
395
- $this->extendedInsert = (bool) $flag;
396
-
397
- return $this;
398
- }
399
-
400
- /**
401
- * Get extended insert flag
402
- *
403
- * @return bool
404
- */
405
- public function getExtendedInsert()
406
- {
407
- return $this->extendedInsert;
408
- }
409
-
410
- /**
411
- * Flush database
412
- *
413
- * @return void
414
- */
415
- public function flush()
416
- {
417
- $query = $this->queryAdapter->show_tables($this->database);
418
- $result = $this->getConnection()->query($query);
419
- $deleteTables = array();
420
- foreach ($result as $row) {
421
- // Drop table
422
- $deleteTables[] = $this->queryAdapter->drop_table($row['table_name']);
423
- }
424
- foreach ($deleteTables as $delete) {
425
- $this->getConnection()->query($delete);
426
- }
427
- }
428
-
429
- /**
430
- * Import database from file
431
- *
432
- * @param string $fileName Name of file
433
- * @return bool
434
- */
435
- public function import($fileName)
436
- {
437
- $fileHandler = fopen($fileName, 'r');
438
- if ($fileHandler) {
439
- $query = null;
440
-
441
- // Read database file line by line
442
- while (($line = fgets($fileHandler)) !== false) {
443
- // Replace create table prefix
444
- $line = $this->replaceCreateTablePrefix($line);
445
-
446
- // Replace insert into prefix
447
- $line = $this->replaceInsertIntoPrefix($line);
448
-
449
- // Replace table values
450
- $line = $this->replaceTableValues($line);
451
-
452
- $query .= $line;
453
- if (preg_match('/;\s*$/', $line)) {
454
- try {
455
- // Run SQL query
456
- $result = $this->getConnection()->query($query);
457
- if ($result) {
458
- $query = null;
459
- }
460
- } catch (PDOException $e) {
461
- continue;
462
- }
463
- }
464
- }
465
-
466
- return true;
467
- }
468
- }
469
-
470
- /**
471
- * Get list of tables
472
- *
473
- * @return array
474
- */
475
- public function listTables()
476
- {
477
- $tables = array();
478
-
479
- $query = $this->queryAdapter->show_tables($this->database);
480
- foreach ($this->getConnection()->query($query) as $row) {
481
- $tables[] = $row['table_name'];
482
- }
483
-
484
- return $tables;
485
- }
486
-
487
- /**
488
- * Replace table values
489
- *
490
- * @param string $input Table value
491
- * @return string
492
- */
493
- public function replaceTableValues($input)
494
- {
495
- $old = $this->getOldReplaceValues();
496
- $new = $this->getNewReplaceValues();
497
-
498
- $oldValues = array();
499
- $newValues = array();
500
-
501
- // Replace strings
502
- for ($i = 0; $i < count($old); $i++) {
503
- if (!empty($old[$i]) && ($old[$i] != $new[$i]) && !in_array($old[$i], $oldValues)) {
504
- $oldValues[] = '/\b' . preg_quote($old[$i], '/') . '\b/i';
505
- $newValues[] = $new[$i];
506
- }
507
- }
508
-
509
- // Replace table prefix
510
- $oldValues[] = '/\b' . preg_quote($this->getOldTablePrefix(), '/') . '/i';
511
- $newValues[] = $this->getNewTablePrefix();
512
-
513
- // Replace table values
514
- $input = preg_replace($oldValues, $newValues, $input);
515
-
516
- // Verify serialization
517
- return MysqlUtility::pregReplace(
518
- $input,
519
- '/s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");/'
520
- );
521
- }
522
-
523
- /**
524
- * Replace table name prefix
525
- *
526
- * @param string $input Table name
527
- * @return string
528
- */
529
- public function replaceTableNamePrefix($input)
530
- {
531
- $pattern = '/^(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)/i';
532
- $replace = $this->getNewTablePrefix() . '\2';
533
-
534
- return preg_replace($pattern, $replace, $input);
535
- }
536
-
537
- /**
538
- * Replace create table prefix
539
- *
540
- * @param string $input SQL statement
541
- * @return string
542
- */
543
- public function replaceCreateTablePrefix($input)
544
- {
545
- $pattern = '/^CREATE TABLE `(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)`/Ui';
546
- $replace = 'CREATE TABLE `' . $this->getNewTablePrefix() . '\2`';
547
-
548
- return preg_replace($pattern, $replace, $input);
549
- }
550
-
551
- /**
552
- * Replace insert into prefix
553
- *
554
- * @param string $input SQL statement
555
- * @return string
556
- */
557
- public function replaceInsertIntoPrefix($input)
558
- {
559
- $pattern = '/^INSERT INTO `(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)`/Ui';
560
- $replace = 'INSERT INTO `' . $this->getNewTablePrefix() . '\2`';
561
-
562
- return preg_replace($pattern, $replace, $input);
563
- }
564
-
565
- /**
566
- * Strip table constraints
567
- *
568
- * @param string $input SQL statement
569
- * @return string
570
- */
571
- public function stripTableConstraints($input)
572
- {
573
- $pattern = array(
574
- '/\s+CONSTRAINT(.+),/i',
575
- '/,\s+CONSTRAINT(.+)/i',
576
- );
577
- $replace = '';
578
-
579
- return preg_replace($pattern, $replace, $input);
580
- }
581
-
582
- /**
583
- * Get MySQL connection (lazy loading)
584
- *
585
- * @return PDO
586
- */
587
- public function getConnection()
588
- {
589
- if ($this->connection === null) {
590
- try {
591
- // Make connection (Socket)
592
- $this->connection = $this->makeConnection();
593
- } catch (Exception $e) {
594
- try {
595
- // Make connection (TCP)
596
- $this->connection = $this->makeConnection(false);
597
- } catch (Exception $e) {
598
- throw new Exception('Unable to connect to MySQL database server: ' . $e->getMessage());
599
- }
600
- }
601
- }
602
-
603
- return $this->connection;
604
- }
605
-
606
- /**
607
- * Make MySQL connection
608
- *
609
- * @param bool $useSocket Use socket or TCP connection
610
- * @return PDO
611
- */
612
- protected function makeConnection($useSocket = true)
613
- {
614
- // Use Socket or TCP
615
- $hostname = ($useSocket ? $this->hostname : gethostbyname($this->hostname));
616
-
617
- // Use default or custom port
618
- if ($this->port === 3306 || empty($this->port)) {
619
- $dsn = sprintf('mysql:host=%s;dbname=%s', $hostname, $this->database);
620
- } else if (!empty($this->socket)) {
621
- $dsn = sprintf('mysql:host=%s;unix_socket=%s;dbname=%s', $hostname, $this->socket, $this->database);
622
- } else {
623
- $dsn = sprintf('mysql:host=%s;port=%s;dbname=%s', $hostname, $this->port, $this->database);
624
- }
625
-
626
- // Make connection
627
- $connection = new PDO(
628
- $dsn,
629
- $this->username,
630
- $this->password,
631
- array(
632
- PDO::ATTR_PERSISTENT => true,
633
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
634
- )
635
- );
636
-
637
- // Set additional connection attributes
638
- $connection->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
639
- $connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
640
-
641
- // Set default encoding
642
- $query = $this->queryAdapter->set_names('utf8');
643
- $connection->exec($query);
644
-
645
- return $connection;
646
- }
647
-
648
- /**
649
- * Returns header for dump file
650
- *
651
- * @return string
652
- */
653
- protected function getHeader()
654
- {
655
- // Some info about software, source and time
656
- $header = "-- All In One WP Migration SQL Dump\n" .
657
- "-- http://servmask.com/\n" .
658
- "--\n" .
659
- "-- Host: {$this->hostname}\n" .
660
- "-- Generation Time: " . date('r') . "\n\n" .
661
- "--\n" .
662
- "-- Database: `{$this->database}`\n" .
663
- "--\n\n";
664
-
665
- return $header;
666
- }
667
-
668
- /**
669
- * Table structure extractor
670
- *
671
- * @param string $tableName Name of table to export
672
- * @return bool
673
- */
674
- protected function getTableStructure($tableName)
675
- {
676
- $query = $this->queryAdapter->show_create_table($tableName);
677
- foreach ($this->getConnection()->query($query) as $row) {
678
- if (isset($row['Create Table'])) {
679
- // Replace table name prefix
680
- $tableName = $this->replaceTableNamePrefix($tableName);
681
-
682
- $this->fileAdapter->write("-- " .
683
- "--------------------------------------------------------" .
684
- "\n\n" .
685
- "--\n" .
686
- "-- Table structure for table `$tableName`\n--\n\n");
687
-
688
- if ($this->getAddDropTable()) {
689
- $this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
690
- }
691
-
692
- // Replace create table prefix
693
- $createTable = $this->replaceCreateTablePrefix($row['Create Table']);
694
-
695
- // Strip table constraints
696
- $createTable = $this->stripTableConstraints($createTable);
697
-
698
- $this->fileAdapter->write($createTable . ";\n\n");
699
-
700
- return true;
701
- }
702
- }
703
- }
704
-
705
- /**
706
- * Table rows extractor
707
- *
708
- * @param string $tableName Name of table to export
709
- * @return void
710
- */
711
- protected function listValues($tableName)
712
- {
713
- $insertFirst = true;
714
- $lineSize = 0;
715
- $query = "SELECT * FROM `$tableName` ";
716
-
717
- // Apply additional query clauses
718
- $clauses = $this->getQueryClauses();
719
- if (isset($clauses[$tableName]) && ($queryClause = $clauses[$tableName])) {
720
- $query .= $queryClause;
721
- }
722
-
723
- // No table data
724
- if ($this->getNoTableData() && !isset($clauses[$tableName])) {
725
- return;
726
- }
727
-
728
- // Replace table name prefix
729
- $tableName = $this->replaceTableNamePrefix($tableName);
730
-
731
- $this->fileAdapter->write(
732
- "--\n" .
733
- "-- Dumping data for table `$tableName`\n" .
734
- "--\n\n"
735
- );
736
-
737
- // Generate insert statements
738
- $result = $this->getConnection()->query($query);
739
- $result->setFetchMode(PDO::FETCH_NUM);
740
- while ($row = $result->fetch()) {
741
- $items = array();
742
- foreach ($row as $value) {
743
- $items[] = is_null($value) ? 'NULL' : $this->getConnection()->quote($this->replaceTableValues($value));
744
- }
745
-
746
- if ($insertFirst || !$this->getExtendedInsert()) {
747
- $lineSize += $this->fileAdapter->write("INSERT INTO `$tableName` VALUES (" . implode(',', $items) . ')');
748
- $insertFirst = false;
749
- } else {
750
- $lineSize += $this->fileAdapter->write(',(' . implode(',', $items) . ')');
751
- }
752
-
753
- if (($lineSize > MysqlDumpInterface::MAXLINESIZE) || !$this->getExtendedInsert()) {
754
- $insertFirst = true;
755
- $lineSize = $this->fileAdapter->write(";\n");
756
- }
757
- }
758
-
759
- // Close result cursor
760
- $result->closeCursor();
761
-
762
- if (!$insertFirst) {
763
- $this->fileAdapter->write(";\n");
764
- }
765
- }
766
-
767
- /**
768
- * Parse data source name
769
- *
770
- * @param string $input Data source name
771
- * @return array List of host, port and socket
772
- */
773
- protected function parseDSN($input) {
774
- $data = explode(':', $input);
775
-
776
- // Set hostname
777
- $host = 'localhost';
778
- if (!empty($data[0])) {
779
- $host = $data[0];
780
- }
781
-
782
- // Set port and socket
783
- $port = $socket = null;
784
- if (!empty($data[1])) {
785
- if (is_numeric($data[1])) {
786
- $port = $data[1];
787
- } else {
788
- $socket = $data[1];
789
- }
790
- }
791
-
792
- return array(
793
- 'host' => $host,
794
- 'port' => $port,
795
- 'socket' => $socket,
796
- );
797
- }
798
  }
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 2.2.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
47
  * @author Bobby Angelov <bobby@servmask.com>
48
  * @copyright 2014 Yani Iliev, Bobby Angelov
49
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
50
+ * @version GIT: 2.2.0
51
  * @link https://github.com/yani-/mysqldump-factory/
52
  */
53
  class MysqlDumpPDO implements MysqlDumpInterface
54
  {
55
+ protected $hostname = null;
56
 
57
+ protected $port = null;
58
 
59
+ protected $socket = null;
60
 
61
+ protected $username = null;
62
 
63
+ protected $password = null;
64
 
65
+ protected $database = null;
66
 
67
+ protected $fileName = 'dump.sql';
68
 
69
+ protected $fileAdapter = null;
70
 
71
+ protected $queryAdapter = null;
72
 
73
+ protected $connection = null;
74
 
75
+ protected $oldTablePrefix = null;
76
 
77
+ protected $newTablePrefix = null;
78
 
79
+ protected $oldReplaceValues = array();
80
 
81
+ protected $newReplaceValues = array();
82
 
83
+ protected $queryClauses = array();
84
 
85
+ protected $includeTables = array();
86
+
87
+ protected $excludeTables = array();
88
+
89
+ protected $noTableData = false;
90
+
91
+ protected $addDropTable = false;
92
+
93
+ /**
94
+ * Define MySQL credentials for the current connection
95
+ *
96
+ * @param string $hostname MySQL Hostname
97
+ * @param string $username MySQL Username
98
+ * @param string $password MySQL Password
99
+ * @param string $database MySQL Database
100
+ * @return void
101
+ */
102
+ public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '')
103
+ {
104
+ $dsn = $this->parseDSN($hostname);
105
+
106
+ // Set MySQL credentials
107
+ $this->hostname = $dsn['host'];
108
+ $this->port = $dsn['port'];
109
+ $this->socket = $dsn['socket'];
110
+ $this->username = $username;
111
+ $this->password = $password;
112
+ $this->database = $database;
113
+
114
+ // Set Query Adapter
115
+ $this->queryAdapter = new MysqlQueryAdapter('mysql');
116
+ }
117
+
118
+ /**
119
+ * Export database into a file
120
+ *
121
+ * @return void
122
+ */
123
+ public function export()
124
+ {
125
+ // Set File Adapter
126
+ $this->fileAdapter = new MysqlFileAdapter();
127
+
128
+ // Set output file
129
+ $this->fileAdapter->open($this->getFileName());
130
+
131
+ // Write Headers Formatting dump file
132
+ $this->fileAdapter->write($this->getHeader());
133
+
134
+ // Listing all tables from database
135
+ $tables = array();
136
+ foreach ($this->listTables() as $table) {
137
+ if (count($this->getIncludeTables()) === 0 || in_array($table, $this->getIncludeTables())) {
138
+ $tables[] = $table;
139
+ }
140
+ }
141
+
142
+ // Export Tables
143
+ foreach ($tables as $table) {
144
+ if (in_array($table, $this->getExcludeTables())) {
145
+ continue;
146
+ }
147
+
148
+ $isTable = $this->getTableStructure($table);
149
+ if (true === $isTable) {
150
+ $this->listValues($table);
151
+ }
152
+ }
153
+
154
+ // Close File Adapter
155
+ $this->fileAdapter->close();
156
+ }
157
+
158
+ /**
159
+ * Set output file name
160
+ *
161
+ * @param string $fileName Name of the output file
162
+ * @return MysqlDumpPDO
163
+ */
164
+ public function setFileName($fileName)
165
+ {
166
+ $this->fileName = $fileName;
167
+
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * Get output file name
173
+ *
174
+ * @return string
175
+ */
176
+ public function getFileName()
177
+ {
178
+ return $this->fileName;
179
+ }
180
+
181
+ /**
182
+ * Set old table prefix
183
+ *
184
+ * @param string $prefix Name of the table prefix
185
+ * @return MysqlDumpPDO
186
+ */
187
+ public function setOldTablePrefix($prefix)
188
+ {
189
+ $this->oldTablePrefix = $prefix;
190
+
191
+ return $this;
192
+ }
193
+
194
+ /**
195
+ * Get old table prefix
196
+ *
197
+ * @return string
198
+ */
199
+ public function getOldTablePrefix()
200
+ {
201
+ return $this->oldTablePrefix;
202
+ }
203
+
204
+ /**
205
+ * Set new table prefix
206
+ *
207
+ * @param string $prefix Name of the table prefix
208
+ * @return MysqlDumpPDO
209
+ */
210
+ public function setNewTablePrefix($prefix)
211
+ {
212
+ $this->newTablePrefix = $prefix;
213
+
214
+ return $this;
215
+ }
216
+
217
+ /**
218
+ * Get new table prefix
219
+ *
220
+ * @return string
221
+ */
222
+ public function getNewTablePrefix()
223
+ {
224
+ return $this->newTablePrefix;
225
+ }
226
+
227
+ /**
228
+ * Set old replace values
229
+ *
230
+ * @param array $values List of values
231
+ * @return MysqlDumpPDO
232
+ */
233
+ public function setOldReplaceValues($values)
234
+ {
235
+ $this->oldReplaceValues = $values;
236
+
237
+ return $this;
238
+ }
239
+
240
+ /**
241
+ * Get old replace values
242
+ *
243
+ * @return array
244
+ */
245
+ public function getOldReplaceValues()
246
+ {
247
+ return $this->oldReplaceValues;
248
+ }
249
+
250
+ /**
251
+ * Set new replace values
252
+ *
253
+ * @param array $values List of values
254
+ * @return MysqlDumpPDO
255
+ */
256
+ public function setNewReplaceValues($values)
257
+ {
258
+ $this->newReplaceValues = $values;
259
+
260
+ return $this;
261
+ }
262
+
263
+ /**
264
+ * Get new replace values
265
+ *
266
+ * @return array
267
+ */
268
+ public function getNewReplaceValues()
269
+ {
270
+ return $this->newReplaceValues;
271
+ }
272
+
273
+ /**
274
+ * Set query clauses
275
+ *
276
+ * @param array $clauses List of SQL query clauses
277
+ * @return MysqlDumpPDO
278
+ */
279
+ public function setQueryClauses($clauses)
280
+ {
281
+ $this->queryClauses = $clauses;
282
+
283
+ return $this;
284
+ }
285
+
286
+ /**
287
+ * Get query clauses
288
+ *
289
+ * @return array
290
+ */
291
+ public function getQueryClauses()
292
+ {
293
+ return $this->queryClauses;
294
+ }
295
+
296
+ /**
297
+ * Set include tables
298
+ *
299
+ * @param array $tables List of tables
300
+ * @return MysqlDumpPDO
301
+ */
302
+ public function setIncludeTables($tables)
303
+ {
304
+ $this->includeTables = $tables;
305
+
306
+ return $this;
307
+ }
308
+
309
+ /**
310
+ * Get include tables
311
+ *
312
+ * @return array
313
+ */
314
+ public function getIncludeTables()
315
+ {
316
+ return $this->includeTables;
317
+ }
318
+
319
+ /**
320
+ * Set exclude tables
321
+ *
322
+ * @param array $tables List of tables
323
+ * @return MysqlDumpPDO
324
+ */
325
+ public function setExcludeTables($tables)
326
+ {
327
+ $this->excludeTables = $tables;
328
+
329
+ return $this;
330
+ }
331
+
332
+ /**
333
+ * Get exclude tables
334
+ *
335
+ * @return array
336
+ */
337
+ public function getExcludeTables()
338
+ {
339
+ return $this->excludeTables;
340
+ }
341
+
342
+ /**
343
+ * Set no table data flag
344
+ *
345
+ * @param bool $flag Do not export table data
346
+ * @return MysqlDumpPDO
347
+ */
348
+ public function setNoTableData($flag)
349
+ {
350
+ $this->noTableData = (bool) $flag;
351
+
352
+ return $this;
353
+ }
354
+
355
+ /**
356
+ * Get no table data flag
357
+ *
358
+ * @return bool
359
+ */
360
+ public function getNoTableData()
361
+ {
362
+ return $this->noTableData;
363
+ }
364
+
365
+ /**
366
+ * Set add drop table flag
367
+ *
368
+ * @param bool $flag Add drop table SQL clause
369
+ * @return MysqlDumpPDO
370
+ */
371
+ public function setAddDropTable($flag)
372
+ {
373
+ $this->addDropTable = (bool) $flag;
374
+
375
+ return $this;
376
+ }
377
+
378
+ /**
379
+ * Get add drop table flag
380
+ *
381
+ * @return bool
382
+ */
383
+ public function getAddDropTable()
384
+ {
385
+ return $this->addDropTable;
386
+ }
387
+
388
+ /**
389
+ * Flush database
390
+ *
391
+ * @return void
392
+ */
393
+ public function flush()
394
+ {
395
+ $deleteTables = array();
396
+ foreach ($this->listTables() as $table) {
397
+ $deleteTables[] = $this->queryAdapter->drop_table($table);
398
+ }
399
+
400
+ // Drop tables
401
+ foreach ($deleteTables as $delete) {
402
+ $this->getConnection()->query($delete);
403
+ }
404
+ }
405
+
406
+ /**
407
+ * Import database from file
408
+ *
409
+ * @param string $fileName Name of file
410
+ * @return bool
411
+ */
412
+ public function import($fileName)
413
+ {
414
+ $fileHandler = fopen($fileName, 'r');
415
+ if ($fileHandler) {
416
+ $query = null;
417
+
418
+ // Read database file line by line
419
+ while (($line = fgets($fileHandler)) !== false) {
420
+ // Replace create table prefix
421
+ $line = $this->replaceCreateTablePrefix($line);
422
+
423
+ // Replace insert into prefix
424
+ $line = $this->replaceInsertIntoPrefix($line);
425
+
426
+ // Replace table values
427
+ $line = $this->replaceTableValues($line);
428
+
429
+ $query .= $line;
430
+ if (preg_match('/;\s*$/', $line)) {
431
+ try {
432
+ // Run SQL query
433
+ $result = $this->getConnection()->query($query);
434
+ if ($result === false) {
435
+ throw new PDOException(var_export($this->getConnection()->errorinfo(), true));
436
+ }
437
+ } catch (PDOException $e) {
438
+ // Log the error
439
+ Ai1wm_Log::error(
440
+ sprintf(
441
+ 'Exception while importing: %s with query: %s',
442
+ $e->getMessage(),
443
+ $query
444
+ )
445
+ );
446
+ }
447
+
448
+ // Empty query
449
+ $query = null;
450
+ }
451
+ }
452
+
453
+ return true;
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Get list of tables
459
+ *
460
+ * @return array
461
+ */
462
+ public function listTables()
463
+ {
464
+ $tables = array();
465
+
466
+ try {
467
+ $query = $this->queryAdapter->show_tables_information_schema($this->database);
468
+ $result = $this->getConnection()->query($query);
469
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
470
+ if (isset($row['table_name'])) {
471
+ $tables[] = $row['table_name'];
472
+ }
473
+ }
474
+ } catch (Exception $e) {
475
+ $query = $this->queryAdapter->show_tables($this->database);
476
+ $result = $this->getConnection()->query($query);
477
+ while ($row = $result->fetch(PDO::FETCH_NUM)) {
478
+ if (isset($row[0])) {
479
+ $tables[] = $row[0];
480
+ }
481
+ }
482
+ }
483
+
484
+ return $tables;
485
+ }
486
+
487
+ /**
488
+ * Replace table values
489
+ *
490
+ * @param string $input Table value
491
+ * @return string
492
+ */
493
+ public function replaceTableValues($input)
494
+ {
495
+ $old = $this->getOldReplaceValues();
496
+ $new = $this->getNewReplaceValues();
497
+
498
+ $oldValues = array();
499
+ $newValues = array();
500
+
501
+ // Replace strings
502
+ for ($i = 0; $i < count($old); $i++) {
503
+ if (!empty($old[$i]) && ($old[$i] != $new[$i]) && !in_array($old[$i], $oldValues)) {
504
+ $oldValues[] = $old[$i];
505
+ $newValues[] = $new[$i];
506
+ }
507
+ }
508
+
509
+ // Replace table prefix
510
+ $oldValues[] = $this->getOldTablePrefix();
511
+ $newValues[] = $this->getNewTablePrefix();
512
+
513
+ // Replace table values
514
+ $input = str_replace($oldValues, $newValues, $input);
515
+
516
+ // Verify serialization
517
+ return MysqlUtility::pregReplace(
518
+ $input,
519
+ '/s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");/'
520
+ );
521
+ }
522
+
523
+ /**
524
+ * Replace table name prefix
525
+ *
526
+ * @param string $input Table name
527
+ * @return string
528
+ */
529
+ public function replaceTableNamePrefix($input)
530
+ {
531
+ $pattern = '/^(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)/i';
532
+ $replace = $this->getNewTablePrefix() . '\2';
533
+
534
+ return preg_replace($pattern, $replace, $input);
535
+ }
536
+
537
+ /**
538
+ * Replace create table prefix
539
+ *
540
+ * @param string $input SQL statement
541
+ * @return string
542
+ */
543
+ public function replaceCreateTablePrefix($input)
544
+ {
545
+ $pattern = '/^CREATE TABLE `(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)`/Ui';
546
+ $replace = 'CREATE TABLE `' . $this->getNewTablePrefix() . '\2`';
547
+
548
+ return preg_replace($pattern, $replace, $input);
549
+ }
550
+
551
+ /**
552
+ * Replace insert into prefix
553
+ *
554
+ * @param string $input SQL statement
555
+ * @return string
556
+ */
557
+ public function replaceInsertIntoPrefix($input)
558
+ {
559
+ $pattern = '/^INSERT INTO `(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)`/Ui';
560
+ $replace = 'INSERT INTO `' . $this->getNewTablePrefix() . '\2`';
561
+
562
+ return preg_replace($pattern, $replace, $input);
563
+ }
564
+
565
+ /**
566
+ * Strip table constraints
567
+ *
568
+ * @param string $input SQL statement
569
+ * @return string
570
+ */
571
+ public function stripTableConstraints($input)
572
+ {
573
+ $pattern = array(
574
+ '/\s+CONSTRAINT(.+),/i',
575
+ '/,\s+CONSTRAINT(.+)/i',
576
+ );
577
+ $replace = '';
578
+
579
+ return preg_replace($pattern, $replace, $input);
580
+ }
581
+
582
+ /**
583
+ * Get MySQL connection (lazy loading)
584
+ *
585
+ * @return PDO
586
+ */
587
+ public function getConnection()
588
+ {
589
+ if ($this->connection === null) {
590
+ try {
591
+ // Make connection (Socket)
592
+ $this->connection = $this->makeConnection();
593
+ } catch (Exception $e) {
594
+ try {
595
+ // Make connection (TCP)
596
+ $this->connection = $this->makeConnection(false);
597
+ } catch (Exception $e) {
598
+ throw new Exception('Unable to connect to MySQL database server: ' . $e->getMessage());
599
+ }
600
+ }
601
+ }
602
+
603
+ return $this->connection;
604
+ }
605
+
606
+ /**
607
+ * Make MySQL connection
608
+ *
609
+ * @param bool $useSocket Use socket or TCP connection
610
+ * @return PDO
611
+ */
612
+ protected function makeConnection($useSocket = true)
613
+ {
614
+ // Use Socket or TCP
615
+ $hostname = ($useSocket ? $this->hostname : gethostbyname($this->hostname));
616
+
617
+ // Use default or custom port
618
+ if ($this->port === 3306 || empty($this->port)) {
619
+ $dsn = sprintf('mysql:host=%s;dbname=%s', $hostname, $this->database);
620
+ } else if (!empty($this->socket)) {
621
+ $dsn = sprintf('mysql:host=%s;unix_socket=%s;dbname=%s', $hostname, $this->socket, $this->database);
622
+ } else {
623
+ $dsn = sprintf('mysql:host=%s;port=%s;dbname=%s', $hostname, $this->port, $this->database);
624
+ }
625
+
626
+ // Make connection
627
+ $connection = new PDO(
628
+ $dsn,
629
+ $this->username,
630
+ $this->password,
631
+ array(
632
+ PDO::ATTR_PERSISTENT => true,
633
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
634
+ )
635
+ );
636
+
637
+ // Set additional connection attributes
638
+ $connection->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
639
+ $connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
640
+
641
+ // Set default encoding
642
+ $query = $this->queryAdapter->set_names('utf8');
643
+ $connection->exec($query);
644
+
645
+ // Set foreign key
646
+ $query = $this->queryAdapter->set_foreign_key(0);
647
+ $connection->exec($query);
648
+
649
+ return $connection;
650
+ }
651
+
652
+ /**
653
+ * Returns header for dump file
654
+ *
655
+ * @return string
656
+ */
657
+ protected function getHeader()
658
+ {
659
+ // Some info about software, source and time
660
+ $header = "-- All In One WP Migration SQL Dump\n" .
661
+ "-- http://servmask.com/\n" .
662
+ "--\n" .
663
+ "-- Host: {$this->hostname}\n" .
664
+ "-- Generation Time: " . date('r') . "\n\n" .
665
+ "--\n" .
666
+ "-- Database: `{$this->database}`\n" .
667
+ "--\n\n";
668
+
669
+ return $header;
670
+ }
671
+
672
+ /**
673
+ * Table structure extractor
674
+ *
675
+ * @param string $tableName Name of table to export
676
+ * @return bool
677
+ */
678
+ protected function getTableStructure($tableName)
679
+ {
680
+ $query = $this->queryAdapter->show_create_table($tableName);
681
+ $result = $this->getConnection()->query($query);
682
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
683
+ if (isset($row['Create Table'])) {
684
+ // Replace table name prefix
685
+ $tableName = $this->replaceTableNamePrefix($tableName);
686
+
687
+ $this->fileAdapter->write("-- " .
688
+ "--------------------------------------------------------" .
689
+ "\n\n" .
690
+ "--\n" .
691
+ "-- Table structure for table `$tableName`\n--\n\n");
692
+
693
+ if ($this->getAddDropTable()) {
694
+ $this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
695
+ }
696
+
697
+ // Replace create table prefix
698
+ $createTable = $this->replaceCreateTablePrefix($row['Create Table']);
699
+
700
+ // Strip table constraints
701
+ $createTable = $this->stripTableConstraints($createTable);
702
+
703
+ $this->fileAdapter->write($createTable . ";\n\n");
704
+
705
+ return true;
706
+ }
707
+ }
708
+ }
709
+
710
+ /**
711
+ * Table rows extractor
712
+ *
713
+ * @param string $tableName Name of table to export
714
+ * @return void
715
+ */
716
+ protected function listValues($tableName)
717
+ {
718
+ // Set query
719
+ $query = "SELECT * FROM `$tableName` ";
720
+
721
+ // Apply additional query clauses
722
+ $clauses = $this->getQueryClauses();
723
+ if (isset($clauses[$tableName]) && ($queryClause = $clauses[$tableName])) {
724
+ $query .= $queryClause;
725
+ }
726
+
727
+ // No table data
728
+ if ($this->getNoTableData() && !isset($clauses[$tableName])) {
729
+ return;
730
+ }
731
+
732
+ // Replace table name prefix
733
+ $tableName = $this->replaceTableNamePrefix($tableName);
734
+
735
+ $this->fileAdapter->write(
736
+ "--\n" .
737
+ "-- Dumping data for table `$tableName`\n" .
738
+ "--\n\n"
739
+ );
740
+
741
+ // Generate insert statements
742
+ $result = $this->getConnection()->query($query);
743
+ while ($row = $result->fetch(PDO::FETCH_NUM)) {
744
+ $items = array();
745
+ foreach ($row as $value) {
746
+ $items[] = is_null($value) ? 'NULL' : $this->getConnection()->quote($this->replaceTableValues($value));
747
+ }
748
+
749
+ // Set table values
750
+ $tableValues = implode(',', $items);
751
+
752
+ // Write insert statements
753
+ $this->fileAdapter->write("INSERT INTO `$tableName` VALUES ($tableValues);\n");
754
+ }
755
+
756
+ // Close result cursor
757
+ $result->closeCursor();
758
+ }
759
+
760
+ /**
761
+ * Parse data source name
762
+ *
763
+ * @param string $input Data source name
764
+ * @return array List of host, port and socket
765
+ */
766
+ protected function parseDSN($input) {
767
+ $data = explode(':', $input);
768
+
769
+ // Set hostname
770
+ $host = 'localhost';
771
+ if (!empty($data[0])) {
772
+ $host = $data[0];
773
+ }
774
+
775
+ // Set port and socket
776
+ $port = $socket = null;
777
+ if (!empty($data[1])) {
778
+ if (is_numeric($data[1])) {
779
+ $port = $data[1];
780
+ } else {
781
+ $socket = $data[1];
782
+ }
783
+ }
784
+
785
+ return array(
786
+ 'host' => $host,
787
+ 'port' => $port,
788
+ 'socket' => $socket,
789
+ );
790
+ }
 
 
 
 
 
 
 
791
  }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpSQL.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.9.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -47,692 +47,687 @@ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlUtility.php';
47
  * @author Bobby Angelov <bobby@servmask.com>
48
  * @copyright 2014 Yani Iliev, Bobby Angelov
49
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
50
- * @version GIT: 1.9.0
51
  * @link https://github.com/yani-/mysqldump-factory/
52
  */
53
  class MysqlDumpSQL implements MysqlDumpInterface
54
  {
55
- protected $hostname = null;
56
 
57
- protected $username = null;
58
 
59
- protected $password = null;
60
 
61
- protected $database = null;
62
 
63
- protected $fileName = 'dump.sql';
64
 
65
- protected $fileAdapter = null;
66
 
67
- protected $queryAdapter = null;
68
 
69
- protected $connection = null;
70
-
71
- protected $oldTablePrefix = null;
72
 
73
- protected $newTablePrefix = null;
74
-
75
- protected $oldReplaceValues = array();
76
-
77
- protected $newReplaceValues = array();
78
-
79
- protected $queryClauses = array();
80
-
81
- protected $includeTables = array();
82
-
83
- protected $excludeTables = array();
84
-
85
- protected $noTableData = false;
86
-
87
- protected $addDropTable = false;
88
-
89
- protected $extendedInsert = true;
90
-
91
- /**
92
- * Define MySQL credentials for the current connection
93
- *
94
- * @param string $hostname MySQL Hostname
95
- * @param string $username MySQL Username
96
- * @param string $password MySQL Password
97
- * @param string $database MySQL Database
98
- * @return void
99
- */
100
- public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '')
101
- {
102
- // Set MySQL credentials
103
- $this->hostname = $hostname;
104
- $this->username = $username;
105
- $this->password = $password;
106
- $this->database = $database;
107
-
108
- // Set Query Adapter
109
- $this->queryAdapter = new MysqlQueryAdapter('mysql');
110
- }
111
-
112
- /**
113
- * Export database into a file
114
- *
115
- * @return void
116
- */
117
- public function export()
118
- {
119
- // Set File Adapter
120
- $this->fileAdapter = new MysqlFileAdapter();
121
-
122
- // Set output file
123
- $this->fileAdapter->open($this->getFileName());
124
-
125
- // Write Headers Formatting dump file
126
- $this->fileAdapter->write($this->getHeader());
127
-
128
- // Listing all tables from database
129
- $tables = array();
130
- foreach ($this->listTables() as $table) {
131
- if (count($this->getIncludeTables()) === 0 || in_array($table, $this->getIncludeTables())) {
132
- $tables[] = $table;
133
- }
134
- }
135
-
136
- // Export Tables
137
- foreach ($tables as $table) {
138
- if (in_array($table, $this->getExcludeTables())) {
139
- continue;
140
- }
141
-
142
- $isTable = $this->getTableStructure($table);
143
- if (true === $isTable) {
144
- $this->listValues($table);
145
- }
146
- }
147
- }
148
-
149
- /**
150
- * Set output file name
151
- *
152
- * @param string $fileName Name of the output file
153
- * @return MysqlDumpSQL
154
- */
155
- public function setFileName($fileName)
156
- {
157
- $this->fileName = $fileName;
158
-
159
- return $this;
160
- }
161
-
162
- /**
163
- * Get output file name
164
- *
165
- * @return string
166
- */
167
- public function getFileName()
168
- {
169
- return $this->fileName;
170
- }
171
-
172
- /**
173
- * Set old table prefix
174
- *
175
- * @param string $prefix Name of the table prefix
176
- * @return MysqlDumpSQL
177
- */
178
- public function setOldTablePrefix($prefix)
179
- {
180
- $this->oldTablePrefix = $prefix;
181
-
182
- return $this;
183
- }
184
-
185
- /**
186
- * Get old table prefix
187
- *
188
- * @return string
189
- */
190
- public function getOldTablePrefix()
191
- {
192
- return $this->oldTablePrefix;
193
- }
194
-
195
- /**
196
- * Set new table prefix
197
- *
198
- * @param string $prefix Name of the table prefix
199
- * @return MysqlDumpSQL
200
- */
201
- public function setNewTablePrefix($prefix)
202
- {
203
- $this->newTablePrefix = $prefix;
204
-
205
- return $this;
206
- }
207
-
208
- /**
209
- * Get new table prefix
210
- *
211
- * @return string
212
- */
213
- public function getNewTablePrefix()
214
- {
215
- return $this->newTablePrefix;
216
- }
217
-
218
- /**
219
- * Set old replace values
220
- *
221
- * @param array $values List of values
222
- * @return MysqlDumpPDO
223
- */
224
- public function setOldReplaceValues($values)
225
- {
226
- $this->oldReplaceValues = $values;
227
-
228
- return $this;
229
- }
230
-
231
- /**
232
- * Get old replace values
233
- *
234
- * @return array
235
- */
236
- public function getOldReplaceValues()
237
- {
238
- return $this->oldReplaceValues;
239
- }
240
-
241
- /**
242
- * Set new replace values
243
- *
244
- * @param array $values List of values
245
- * @return MysqlDumpPDO
246
- */
247
- public function setNewReplaceValues($values)
248
- {
249
- $this->newReplaceValues = $values;
250
-
251
- return $this;
252
- }
253
-
254
- /**
255
- * Get new replace values
256
- *
257
- * @return array
258
- */
259
- public function getNewReplaceValues()
260
- {
261
- return $this->newReplaceValues;
262
- }
263
-
264
- /**
265
- * Set query clauses
266
- *
267
- * @param array $clauses List of SQL query clauses
268
- * @return MysqlDumpSQL
269
- */
270
- public function setQueryClauses($clauses)
271
- {
272
- $this->queryClauses = $clauses;
273
-
274
- return $this;
275
- }
276
-
277
- /**
278
- * Get query clauses
279
- *
280
- * @return array
281
- */
282
- public function getQueryClauses()
283
- {
284
- return $this->queryClauses;
285
- }
286
-
287
- /**
288
- * Set include tables
289
- *
290
- * @param array $tables List of tables
291
- * @return MysqlDumpSQL
292
- */
293
- public function setIncludeTables($tables)
294
- {
295
- $this->includeTables = $tables;
296
-
297
- return $this;
298
- }
299
-
300
- /**
301
- * Get include tables
302
- *
303
- * @return array
304
- */
305
- public function getIncludeTables()
306
- {
307
- return $this->includeTables;
308
- }
309
-
310
- /**
311
- * Set exclude tables
312
- *
313
- * @param array $tables List of tables
314
- * @return MysqlDumpSQL
315
- */
316
- public function setExcludeTables($tables)
317
- {
318
- $this->excludeTables = $tables;
319
-
320
- return $this;
321
- }
322
-
323
- /**
324
- * Get exclude tables
325
- *
326
- * @return array
327
- */
328
- public function getExcludeTables()
329
- {
330
- return $this->excludeTables;
331
- }
332
-
333
- /**
334
- * Set no table data flag
335
- *
336
- * @param bool $flag Do not export table data
337
- * @return MysqlDumpSQL
338
- */
339
- public function setNoTableData($flag)
340
- {
341
- $this->noTableData = (bool) $flag;
342
-
343
- return $this;
344
- }
345
-
346
- /**
347
- * Get no table data flag
348
- *
349
- * @return bool
350
- */
351
- public function getNoTableData()
352
- {
353
- return $this->noTableData;
354
- }
355
-
356
- /**
357
- * Set add drop table flag
358
- *
359
- * @param bool $flag Add drop table SQL clause
360
- * @return MysqlDumpSQL
361
- */
362
- public function setAddDropTable($flag)
363
- {
364
- $this->addDropTable = (bool) $flag;
365
-
366
- return $this;
367
- }
368
-
369
- /**
370
- * Get add drop table flag
371
- *
372
- * @return bool
373
- */
374
- public function getAddDropTable()
375
- {
376
- return $this->addDropTable;
377
- }
378
-
379
- /**
380
- * Set extended insert flag
381
- *
382
- * @param bool $flag Add extended insert SQL clause
383
- * @return MysqlDumpSQL
384
- */
385
- public function setExtendedInsert($flag)
386
- {
387
- $this->extendedInsert = (bool) $flag;
388
-
389
- return $this;
390
- }
391
-
392
- /**
393
- * Get extended insert flag
394
- *
395
- * @return bool
396
- */
397
- public function getExtendedInsert()
398
- {
399
- return $this->extendedInsert;
400
- }
401
-
402
- /**
403
- * Flush database
404
- *
405
- * @return void
406
- */
407
- public function flush()
408
- {
409
- $query = $this->queryAdapter->show_tables($this->database);
410
- $result = mysql_unbuffered_query($query, $this->getConnection());
411
- $deleteTables = array();
412
- while ($row = mysql_fetch_assoc($result)) {
413
- // Drop table
414
- $deleteTables[] = $this->queryAdapter->drop_table($row['table_name']);
415
- }
416
- foreach ($deleteTables as $delete) {
417
- mysql_unbuffered_query($delete, $this->getConnection());
418
- }
419
- }
420
-
421
- /**
422
- * Import database from file
423
- *
424
- * @param string $fileName Name of file
425
- * @return bool
426
- */
427
- public function import($fileName)
428
- {
429
- $fileHandler = fopen($fileName, 'r');
430
- if ($fileHandler) {
431
- $query = null;
432
-
433
- // Read database file line by line
434
- while (($line = fgets($fileHandler)) !== false) {
435
- // Replace create table prefix
436
- $line = $this->replaceCreateTablePrefix($line);
437
-
438
- // Replace insert into prefix
439
- $line = $this->replaceInsertIntoPrefix($line);
440
-
441
- // Replace table values
442
- $line = $this->replaceTableValues($line);
443
-
444
- $query .= $line;
445
- if (preg_match('/;\s*$/', $line)) {
446
- // Run SQL query
447
- $result = mysql_unbuffered_query($query, $this->getConnection());
448
- if ($result) {
449
- $query = null;
450
- }
451
- }
452
- }
453
-
454
- return true;
455
- }
456
- }
457
-
458
- /**
459
- * Get list of tables
460
- *
461
- * @return array
462
- */
463
- public function listTables()
464
- {
465
- $tables = array();
466
-
467
- $query = $this->queryAdapter->show_tables($this->database);
468
- $result = mysql_unbuffered_query($query, $this->getConnection());
469
- while ($row = mysql_fetch_assoc($result)) {
470
- $tables[] = $row['table_name'];
471
- }
472
-
473
- return $tables;
474
- }
475
-
476
- /**
477
- * Replace table values
478
- *
479
- * @param string $input Table value
480
- * @return string
481
- */
482
- public function replaceTableValues($input)
483
- {
484
- $old = $this->getOldReplaceValues();
485
- $new = $this->getNewReplaceValues();
486
-
487
- $oldValues = array();
488
- $newValues = array();
489
-
490
- // Replace strings
491
- for ($i = 0; $i < count($old); $i++) {
492
- if (!empty($old[$i]) && ($old[$i] != $new[$i]) && !in_array($old[$i], $oldValues)) {
493
- $oldValues[] = '/\b' . preg_quote($old[$i], '/') . '\b/i';
494
- $newValues[] = $new[$i];
495
- }
496
- }
497
-
498
- // Replace table prefix
499
- $oldValues[] = '/\b' . preg_quote($this->getOldTablePrefix(), '/') . '/i';
500
- $newValues[] = $this->getNewTablePrefix();
501
-
502
- // Replace table values
503
- $input = preg_replace($oldValues, $newValues, $input);
504
-
505
- // Verify serialization
506
- return MysqlUtility::pregReplace(
507
- $input,
508
- '/s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");/'
509
- );
510
- }
511
-
512
- /**
513
- * Replace table name prefix
514
- *
515
- * @param string $input Table name
516
- * @return string
517
- */
518
- public function replaceTableNamePrefix($input)
519
- {
520
- $pattern = '/^(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)/i';
521
- $replace = $this->getNewTablePrefix() . '\2';
522
-
523
- return preg_replace($pattern, $replace, $input);
524
- }
525
-
526
- /**
527
- * Replace create table prefix
528
- *
529
- * @param string $input SQL statement
530
- * @return string
531
- */
532
- public function replaceCreateTablePrefix($input)
533
- {
534
- $pattern = '/^CREATE TABLE `(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)`/Ui';
535
- $replace = 'CREATE TABLE `' . $this->getNewTablePrefix() . '\2`';
536
-
537
- return preg_replace($pattern, $replace, $input);
538
- }
539
-
540
- /**
541
- * Replace insert into prefix
542
- *
543
- * @param string $input SQL statement
544
- * @return string
545
- */
546
- public function replaceInsertIntoPrefix($input)
547
- {
548
- $pattern = '/^INSERT INTO `(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)`/Ui';
549
- $replace = 'INSERT INTO `' . $this->getNewTablePrefix() . '\2`';
550
-
551
- return preg_replace($pattern, $replace, $input);
552
- }
553
-
554
- /**
555
- * Strip table constraints
556
- *
557
- * @param string $input SQL statement
558
- * @return string
559
- */
560
- public function stripTableConstraints($input)
561
- {
562
- $pattern = array(
563
- '/\s+CONSTRAINT(.+),/i',
564
- '/,\s+CONSTRAINT(.+)/i',
565
- );
566
- $replace = '';
567
-
568
- return preg_replace($pattern, $replace, $input);
569
- }
570
-
571
- /**
572
- * Get MySQL connection (lazy loading)
573
- *
574
- * @return resource
575
- */
576
- public function getConnection()
577
- {
578
- if ($this->connection === null) {
579
- // Make connection (Socket)
580
- $this->connection = $this->makeConnection();
581
-
582
- if ($this->connection === false) {
583
- // Make connection (TCP)
584
- $this->connection = $this->makeConnection(false);
585
-
586
- // Unable to connect to MySQL database server
587
- if ($this->connection === false) {
588
- throw new Exception('Unable to connect to MySQL database server: ' . mysql_error($this->connection));
589
- }
590
- }
591
- }
592
-
593
- return $this->connection;
594
- }
595
-
596
- /**
597
- * Make MySQL connection
598
- *
599
- * @param bool $useSocket Use socket or TCP connection
600
- * @return resource
601
- */
602
- protected function makeConnection($useSocket = true)
603
- {
604
- // Use Socket or TCP
605
- $hostname = ($useSocket ? $this->hostname : gethostbyname($this->hostname));
606
-
607
- // Make connection
608
- $connection = @mysql_pconnect($hostname, $this->username, $this->password);
609
-
610
- // Select database and set default encoding
611
- if ($connection) {
612
- if (mysql_select_db($this->database, $connection)) {
613
- $query = $this->queryAdapter->set_names('utf8');
614
- mysql_unbuffered_query($query, $connection);
615
- } else {
616
- throw new Exception('Could not select MySQL database: ' . mysql_error($connection));
617
- }
618
- }
619
-
620
- return $connection;
621
- }
622
-
623
- /**
624
- * Returns header for dump file
625
- *
626
- * @return string
627
- */
628
- protected function getHeader()
629
- {
630
- // Some info about software, source and time
631
- $header = "-- All In One WP Migration SQL Dump\n" .
632
- "-- http://servmask.com/\n" .
633
- "--\n" .
634
- "-- Host: {$this->hostname}\n" .
635
- "-- Generation Time: " . date('r') . "\n\n" .
636
- "--\n" .
637
- "-- Database: `{$this->database}`\n" .
638
- "--\n\n";
639
-
640
- return $header;
641
- }
642
-
643
- /**
644
- * Table structure extractor
645
- *
646
- * @param string $tableName Name of table to export
647
- * @return bool
648
- */
649
- protected function getTableStructure($tableName)
650
- {
651
- $query = $this->queryAdapter->show_create_table($tableName);
652
- $result = mysql_unbuffered_query($query, $this->getConnection());
653
- while ($row = mysql_fetch_assoc($result)) {
654
- if (isset($row['Create Table'])) {
655
- // Replace table name prefix
656
- $tableName = $this->replaceTableNamePrefix($tableName);
657
-
658
- $this->fileAdapter->write("-- " .
659
- "--------------------------------------------------------" .
660
- "\n\n" .
661
- "--\n" .
662
- "-- Table structure for table `$tableName`\n--\n\n");
663
-
664
- if ($this->getAddDropTable()) {
665
- $this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
666
- }
667
-
668
- // Replace create table prefix
669
- $createTable = $this->replaceCreateTablePrefix($row['Create Table']);
670
-
671
- // Strip table constraints
672
- $createTable = $this->stripTableConstraints($createTable);
673
-
674
- $this->fileAdapter->write($createTable . ";\n\n");
675
-
676
- return true;
677
- }
678
- }
679
- }
680
-
681
- /**
682
- * Table rows extractor
683
- *
684
- * @param string $tableName Name of table to export
685
- * @return void
686
- */
687
- protected function listValues($tableName)
688
- {
689
- $insertFirst = true;
690
- $lineSize = 0;
691
- $query = "SELECT * FROM `$tableName` ";
692
-
693
- // Apply additional query clauses
694
- $clauses = $this->getQueryClauses();
695
- if (isset($clauses[$tableName]) && ($queryClause = $clauses[$tableName])) {
696
- $query .= $queryClause;
697
- }
698
-
699
- // No table data
700
- if ($this->getNoTableData() && !isset($clauses[$tableName])) {
701
- return;
702
- }
703
-
704
- // Replace table name prefix
705
- $tableName = $this->replaceTableNamePrefix($tableName);
706
-
707
- $this->fileAdapter->write(
708
- "--\n" .
709
- "-- Dumping data for table `$tableName`\n" .
710
- "--\n\n"
711
- );
712
-
713
- // Generate insert statements
714
- $result = mysql_unbuffered_query($query, $this->getConnection());
715
- while ($row = mysql_fetch_row($result)) {
716
- $items = array();
717
- foreach ($row as $value) {
718
- $items[] = is_null($value) ? 'NULL' : "'" . mysql_real_escape_string($this->replaceTableValues($value)) . "'";
719
- }
720
-
721
- if ($insertFirst || !$this->getExtendedInsert()) {
722
- $lineSize += $this->fileAdapter->write("INSERT INTO `$tableName` VALUES (" . implode(',', $items) . ')');
723
- $insertFirst = false;
724
- } else {
725
- $lineSize += $this->fileAdapter->write(',(' . implode(',', $items) . ')');
726
- }
727
-
728
- if (($lineSize > MysqlDumpInterface::MAXLINESIZE) || !$this->getExtendedInsert()) {
729
- $insertFirst = true;
730
- $lineSize = $this->fileAdapter->write(";\n");
731
- }
732
- }
733
-
734
- if (!$insertFirst) {
735
- $this->fileAdapter->write(";\n");
736
- }
737
- }
738
  }
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 2.2.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
47
  * @author Bobby Angelov <bobby@servmask.com>
48
  * @copyright 2014 Yani Iliev, Bobby Angelov
49
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
50
+ * @version GIT: 2.2.0
51
  * @link https://github.com/yani-/mysqldump-factory/
52
  */
53
  class MysqlDumpSQL implements MysqlDumpInterface
54
  {
55
+ protected $hostname = null;
56
 
57
+ protected $username = null;
58
 
59
+ protected $password = null;
60
 
61
+ protected $database = null;
62
 
63
+ protected $fileName = 'dump.sql';
64
 
65
+ protected $fileAdapter = null;
66
 
67
+ protected $queryAdapter = null;
68
 
69
+ protected $connection = null;
70
+
71
+ protected $oldTablePrefix = null;
72
 
73
+ protected $newTablePrefix = null;
74
+
75
+ protected $oldReplaceValues = array();
76
+
77
+ protected $newReplaceValues = array();
78
+
79
+ protected $queryClauses = array();
80
+
81
+ protected $includeTables = array();
82
+
83
+ protected $excludeTables = array();
84
+
85
+ protected $noTableData = false;
86
+
87
+ protected $addDropTable = false;
88
+
89
+ /**
90
+ * Define MySQL credentials for the current connection
91
+ *
92
+ * @param string $hostname MySQL Hostname
93
+ * @param string $username MySQL Username
94
+ * @param string $password MySQL Password
95
+ * @param string $database MySQL Database
96
+ * @return void
97
+ */
98
+ public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '')
99
+ {
100
+ // Set MySQL credentials
101
+ $this->hostname = $hostname;
102
+ $this->username = $username;
103
+ $this->password = $password;
104
+ $this->database = $database;
105
+
106
+ // Set Query Adapter
107
+ $this->queryAdapter = new MysqlQueryAdapter('mysql');
108
+ }
109
+
110
+ /**
111
+ * Export database into a file
112
+ *
113
+ * @return void
114
+ */
115
+ public function export()
116
+ {
117
+ // Set File Adapter
118
+ $this->fileAdapter = new MysqlFileAdapter();
119
+
120
+ // Set output file
121
+ $this->fileAdapter->open($this->getFileName());
122
+
123
+ // Write Headers Formatting dump file
124
+ $this->fileAdapter->write($this->getHeader());
125
+
126
+ // Listing all tables from database
127
+ $tables = array();
128
+ foreach ($this->listTables() as $table) {
129
+ if (count($this->getIncludeTables()) === 0 || in_array($table, $this->getIncludeTables())) {
130
+ $tables[] = $table;
131
+ }
132
+ }
133
+
134
+ // Export Tables
135
+ foreach ($tables as $table) {
136
+ if (in_array($table, $this->getExcludeTables())) {
137
+ continue;
138
+ }
139
+
140
+ $isTable = $this->getTableStructure($table);
141
+ if (true === $isTable) {
142
+ $this->listValues($table);
143
+ }
144
+ }
145
+
146
+ // Close File Adapter
147
+ $this->fileAdapter->close();
148
+ }
149
+
150
+ /**
151
+ * Set output file name
152
+ *
153
+ * @param string $fileName Name of the output file
154
+ * @return MysqlDumpSQL
155
+ */
156
+ public function setFileName($fileName)
157
+ {
158
+ $this->fileName = $fileName;
159
+
160
+ return $this;
161
+ }
162
+
163
+ /**
164
+ * Get output file name
165
+ *
166
+ * @return string
167
+ */
168
+ public function getFileName()
169
+ {
170
+ return $this->fileName;
171
+ }
172
+
173
+ /**
174
+ * Set old table prefix
175
+ *
176
+ * @param string $prefix Name of the table prefix
177
+ * @return MysqlDumpSQL
178
+ */
179
+ public function setOldTablePrefix($prefix)
180
+ {
181
+ $this->oldTablePrefix = $prefix;
182
+
183
+ return $this;
184
+ }
185
+
186
+ /**
187
+ * Get old table prefix
188
+ *
189
+ * @return string
190
+ */
191
+ public function getOldTablePrefix()
192
+ {
193
+ return $this->oldTablePrefix;
194
+ }
195
+
196
+ /**
197
+ * Set new table prefix
198
+ *
199
+ * @param string $prefix Name of the table prefix
200
+ * @return MysqlDumpSQL
201
+ */
202
+ public function setNewTablePrefix($prefix)
203
+ {
204
+ $this->newTablePrefix = $prefix;
205
+
206
+ return $this;
207
+ }
208
+
209
+ /**
210
+ * Get new table prefix
211
+ *
212
+ * @return string
213
+ */
214
+ public function getNewTablePrefix()
215
+ {
216
+ return $this->newTablePrefix;
217
+ }
218
+
219
+ /**
220
+ * Set old replace values
221
+ *
222
+ * @param array $values List of values
223
+ * @return MysqlDumpPDO
224
+ */
225
+ public function setOldReplaceValues($values)
226
+ {
227
+ $this->oldReplaceValues = $values;
228
+
229
+ return $this;
230
+ }
231
+
232
+ /**
233
+ * Get old replace values
234
+ *
235
+ * @return array
236
+ */
237
+ public function getOldReplaceValues()
238
+ {
239
+ return $this->oldReplaceValues;
240
+ }
241
+
242
+ /**
243
+ * Set new replace values
244
+ *
245
+ * @param array $values List of values
246
+ * @return MysqlDumpPDO
247
+ */
248
+ public function setNewReplaceValues($values)
249
+ {
250
+ $this->newReplaceValues = $values;
251
+
252
+ return $this;
253
+ }
254
+
255
+ /**
256
+ * Get new replace values
257
+ *
258
+ * @return array
259
+ */
260
+ public function getNewReplaceValues()
261
+ {
262
+ return $this->newReplaceValues;
263
+ }
264
+
265
+ /**
266
+ * Set query clauses
267
+ *
268
+ * @param array $clauses List of SQL query clauses
269
+ * @return MysqlDumpSQL
270
+ */
271
+ public function setQueryClauses($clauses)
272
+ {
273
+ $this->queryClauses = $clauses;
274
+
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * Get query clauses
280
+ *
281
+ * @return array
282
+ */
283
+ public function getQueryClauses()
284
+ {
285
+ return $this->queryClauses;
286
+ }
287
+
288
+ /**
289
+ * Set include tables
290
+ *
291
+ * @param array $tables List of tables
292
+ * @return MysqlDumpSQL
293
+ */
294
+ public function setIncludeTables($tables)
295
+ {
296
+ $this->includeTables = $tables;
297
+
298
+ return $this;
299
+ }
300
+
301
+ /**
302
+ * Get include tables
303
+ *
304
+ * @return array
305
+ */
306
+ public function getIncludeTables()
307
+ {
308
+ return $this->includeTables;
309
+ }
310
+
311
+ /**
312
+ * Set exclude tables
313
+ *
314
+ * @param array $tables List of tables
315
+ * @return MysqlDumpSQL
316
+ */
317
+ public function setExcludeTables($tables)
318
+ {
319
+ $this->excludeTables = $tables;
320
+
321
+ return $this;
322
+ }
323
+
324
+ /**
325
+ * Get exclude tables
326
+ *
327
+ * @return array
328
+ */
329
+ public function getExcludeTables()
330
+ {
331
+ return $this->excludeTables;
332
+ }
333
+
334
+ /**
335
+ * Set no table data flag
336
+ *
337
+ * @param bool $flag Do not export table data
338
+ * @return MysqlDumpSQL
339
+ */
340
+ public function setNoTableData($flag)
341
+ {
342
+ $this->noTableData = (bool) $flag;
343
+
344
+ return $this;
345
+ }
346
+
347
+ /**
348
+ * Get no table data flag
349
+ *
350
+ * @return bool
351
+ */
352
+ public function getNoTableData()
353
+ {
354
+ return $this->noTableData;
355
+ }
356
+
357
+ /**
358
+ * Set add drop table flag
359
+ *
360
+ * @param bool $flag Add drop table SQL clause
361
+ * @return MysqlDumpSQL
362
+ */
363
+ public function setAddDropTable($flag)
364
+ {
365
+ $this->addDropTable = (bool) $flag;
366
+
367
+ return $this;
368
+ }
369
+
370
+ /**
371
+ * Get add drop table flag
372
+ *
373
+ * @return bool
374
+ */
375
+ public function getAddDropTable()
376
+ {
377
+ return $this->addDropTable;
378
+ }
379
+
380
+ /**
381
+ * Flush database
382
+ *
383
+ * @return void
384
+ */
385
+ public function flush()
386
+ {
387
+ $deleteTables = array();
388
+ foreach ($this->listTables() as $table) {
389
+ $deleteTables[] = $this->queryAdapter->drop_table($table);
390
+ }
391
+
392
+ // Drop tables
393
+ foreach ($deleteTables as $delete) {
394
+ mysql_unbuffered_query($delete, $this->getConnection());
395
+ }
396
+ }
397
+
398
+ /**
399
+ * Import database from file
400
+ *
401
+ * @param string $fileName Name of file
402
+ * @return bool
403
+ */
404
+ public function import($fileName)
405
+ {
406
+ $fileHandler = fopen($fileName, 'r');
407
+ if ($fileHandler) {
408
+ $query = null;
409
+
410
+ // Read database file line by line
411
+ while (($line = fgets($fileHandler)) !== false) {
412
+ // Replace create table prefix
413
+ $line = $this->replaceCreateTablePrefix($line);
414
+
415
+ // Replace insert into prefix
416
+ $line = $this->replaceInsertIntoPrefix($line);
417
+
418
+ // Replace table values
419
+ $line = $this->replaceTableValues($line);
420
+
421
+ $query .= $line;
422
+ if (preg_match('/;\s*$/', $line)) {
423
+ // Run SQL query
424
+ $result = mysql_unbuffered_query($query, $this->getConnection());
425
+ if ($result === false) {
426
+ // Log the error
427
+ Ai1wm_Log::error(
428
+ sprintf(
429
+ 'Exception while importing: %s with query: %s',
430
+ mysql_error($this->getConnection()),
431
+ $query
432
+ )
433
+ );
434
+ }
435
+
436
+ // Empty query
437
+ $query = null;
438
+ }
439
+ }
440
+
441
+ return true;
442
+ }
443
+ }
444
+
445
+ /**
446
+ * Get list of tables
447
+ *
448
+ * @return array
449
+ */
450
+ public function listTables()
451
+ {
452
+ $tables = array();
453
+
454
+ $query = $this->queryAdapter->show_tables_information_schema($this->database);
455
+ if (($result = mysql_unbuffered_query($query, $this->getConnection()))) {
456
+ while ($row = mysql_fetch_assoc($result)) {
457
+ if (isset($row['table_name'])) {
458
+ $tables[] = $row['table_name'];
459
+ }
460
+ }
461
+ } else {
462
+ $query = $this->queryAdapter->show_tables($this->database);
463
+ $result = mysql_unbuffered_query($query, $this->getConnection());
464
+ while ($row = mysql_fetch_row($result)) {
465
+ if (isset($row[0])) {
466
+ $tables[] = $row[0];
467
+ }
468
+ }
469
+ }
470
+
471
+ return $tables;
472
+ }
473
+
474
+ /**
475
+ * Replace table values
476
+ *
477
+ * @param string $input Table value
478
+ * @return string
479
+ */
480
+ public function replaceTableValues($input)
481
+ {
482
+ $old = $this->getOldReplaceValues();
483
+ $new = $this->getNewReplaceValues();
484
+
485
+ $oldValues = array();
486
+ $newValues = array();
487
+
488
+ // Replace strings
489
+ for ($i = 0; $i < count($old); $i++) {
490
+ if (!empty($old[$i]) && ($old[$i] != $new[$i]) && !in_array($old[$i], $oldValues)) {
491
+ $oldValues[] = $old[$i];
492
+ $newValues[] = $new[$i];
493
+ }
494
+ }
495
+
496
+ // Replace table prefix
497
+ $oldValues[] = $this->getOldTablePrefix();
498
+ $newValues[] = $this->getNewTablePrefix();
499
+
500
+ // Replace table values
501
+ $input = str_replace($oldValues, $newValues, $input);
502
+
503
+ // Verify serialization
504
+ return MysqlUtility::pregReplace(
505
+ $input,
506
+ '/s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");/'
507
+ );
508
+ }
509
+
510
+ /**
511
+ * Replace table name prefix
512
+ *
513
+ * @param string $input Table name
514
+ * @return string
515
+ */
516
+ public function replaceTableNamePrefix($input)
517
+ {
518
+ $pattern = '/^(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)/i';
519
+ $replace = $this->getNewTablePrefix() . '\2';
520
+
521
+ return preg_replace($pattern, $replace, $input);
522
+ }
523
+
524
+ /**
525
+ * Replace create table prefix
526
+ *
527
+ * @param string $input SQL statement
528
+ * @return string
529
+ */
530
+ public function replaceCreateTablePrefix($input)
531
+ {
532
+ $pattern = '/^CREATE TABLE `(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)`/Ui';
533
+ $replace = 'CREATE TABLE `' . $this->getNewTablePrefix() . '\2`';
534
+
535
+ return preg_replace($pattern, $replace, $input);
536
+ }
537
+
538
+ /**
539
+ * Replace insert into prefix
540
+ *
541
+ * @param string $input SQL statement
542
+ * @return string
543
+ */
544
+ public function replaceInsertIntoPrefix($input)
545
+ {
546
+ $pattern = '/^INSERT INTO `(' . preg_quote($this->getOldTablePrefix(), '/') . ')(.+)`/Ui';
547
+ $replace = 'INSERT INTO `' . $this->getNewTablePrefix() . '\2`';
548
+
549
+ return preg_replace($pattern, $replace, $input);
550
+ }
551
+
552
+ /**
553
+ * Strip table constraints
554
+ *
555
+ * @param string $input SQL statement
556
+ * @return string
557
+ */
558
+ public function stripTableConstraints($input)
559
+ {
560
+ $pattern = array(
561
+ '/\s+CONSTRAINT(.+),/i',
562
+ '/,\s+CONSTRAINT(.+)/i',
563
+ );
564
+ $replace = '';
565
+
566
+ return preg_replace($pattern, $replace, $input);
567
+ }
568
+
569
+ /**
570
+ * Get MySQL connection (lazy loading)
571
+ *
572
+ * @return resource
573
+ */
574
+ public function getConnection()
575
+ {
576
+ if ($this->connection === null) {
577
+ // Make connection (Socket)
578
+ $this->connection = $this->makeConnection();
579
+
580
+ if ($this->connection === false) {
581
+ // Make connection (TCP)
582
+ $this->connection = $this->makeConnection(false);
583
+
584
+ // Unable to connect to MySQL database server
585
+ if ($this->connection === false) {
586
+ throw new Exception('Unable to connect to MySQL database server: ' . mysql_error($this->connection));
587
+ }
588
+ }
589
+ }
590
+
591
+ return $this->connection;
592
+ }
593
+
594
+ /**
595
+ * Make MySQL connection
596
+ *
597
+ * @param bool $useSocket Use socket or TCP connection
598
+ * @return resource
599
+ */
600
+ protected function makeConnection($useSocket = true)
601
+ {
602
+ // Use Socket or TCP
603
+ $hostname = ($useSocket ? $this->hostname : gethostbyname($this->hostname));
604
+
605
+ // Make connection
606
+ $connection = @mysql_pconnect($hostname, $this->username, $this->password);
607
+
608
+ // Select database and set default encoding
609
+ if ($connection) {
610
+ if (mysql_select_db($this->database, $connection)) {
611
+ // Set default encoding
612
+ $query = $this->queryAdapter->set_names('utf8');
613
+ mysql_unbuffered_query($query, $connection);
614
+
615
+ // Set foreign key
616
+ $query = $this->queryAdapter->set_foreign_key(0);
617
+ mysql_unbuffered_query($query, $connection);
618
+ } else {
619
+ throw new Exception('Could not select MySQL database: ' . mysql_error($connection));
620
+ }
621
+ }
622
+
623
+ return $connection;
624
+ }
625
+
626
+ /**
627
+ * Returns header for dump file
628
+ *
629
+ * @return string
630
+ */
631
+ protected function getHeader()
632
+ {
633
+ // Some info about software, source and time
634
+ $header = "-- All In One WP Migration SQL Dump\n" .
635
+ "-- http://servmask.com/\n" .
636
+ "--\n" .
637
+ "-- Host: {$this->hostname}\n" .
638
+ "-- Generation Time: " . date('r') . "\n\n" .
639
+ "--\n" .
640
+ "-- Database: `{$this->database}`\n" .
641
+ "--\n\n";
642
+
643
+ return $header;
644
+ }
645
+
646
+ /**
647
+ * Table structure extractor
648
+ *
649
+ * @param string $tableName Name of table to export
650
+ * @return bool
651
+ */
652
+ protected function getTableStructure($tableName)
653
+ {
654
+ $query = $this->queryAdapter->show_create_table($tableName);
655
+ $result = mysql_unbuffered_query($query, $this->getConnection());
656
+ while ($row = mysql_fetch_assoc($result)) {
657
+ if (isset($row['Create Table'])) {
658
+ // Replace table name prefix
659
+ $tableName = $this->replaceTableNamePrefix($tableName);
660
+
661
+ $this->fileAdapter->write("-- " .
662
+ "--------------------------------------------------------" .
663
+ "\n\n" .
664
+ "--\n" .
665
+ "-- Table structure for table `$tableName`\n--\n\n");
666
+
667
+ if ($this->getAddDropTable()) {
668
+ $this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
669
+ }
670
+
671
+ // Replace create table prefix
672
+ $createTable = $this->replaceCreateTablePrefix($row['Create Table']);
673
+
674
+ // Strip table constraints
675
+ $createTable = $this->stripTableConstraints($createTable);
676
+
677
+ $this->fileAdapter->write($createTable . ";\n\n");
678
+
679
+ return true;
680
+ }
681
+ }
682
+ }
683
+
684
+ /**
685
+ * Table rows extractor
686
+ *
687
+ * @param string $tableName Name of table to export
688
+ * @return void
689
+ */
690
+ protected function listValues($tableName)
691
+ {
692
+ // Set query
693
+ $query = "SELECT * FROM `$tableName` ";
694
+
695
+ // Apply additional query clauses
696
+ $clauses = $this->getQueryClauses();
697
+ if (isset($clauses[$tableName]) && ($queryClause = $clauses[$tableName])) {
698
+ $query .= $queryClause;
699
+ }
700
+
701
+ // No table data
702
+ if ($this->getNoTableData() && !isset($clauses[$tableName])) {
703
+ return;
704
+ }
705
+
706
+ // Replace table name prefix
707
+ $tableName = $this->replaceTableNamePrefix($tableName);
708
+
709
+ $this->fileAdapter->write(
710
+ "--\n" .
711
+ "-- Dumping data for table `$tableName`\n" .
712
+ "--\n\n"
713
+ );
714
+
715
+ // Generate insert statements
716
+ $result = mysql_unbuffered_query($query, $this->getConnection());
717
+ while ($row = mysql_fetch_row($result)) {
718
+ $items = array();
719
+ foreach ($row as $value) {
720
+ $items[] = is_null($value) ? 'NULL' : "'" . mysql_real_escape_string($this->replaceTableValues($value)) . "'";
721
+ }
722
+
723
+ // Set table values
724
+ $tableValues = implode(',', $items);
725
+
726
+ // Write insert statements
727
+ $this->fileAdapter->write("INSERT INTO `$tableName` VALUES ($tableValues);\n");
728
+ }
729
+
730
+ // Close result cursor
731
+ mysql_free_result($result);
732
+ }
 
 
 
 
 
733
  }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlFileAdapter.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.9.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,33 +42,33 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.9.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlFileAdapter
49
  {
50
- protected $fileHandler = null;
51
 
52
- public function open($fileName)
53
- {
54
- $this->fileHandler = fopen($fileName, 'wb');
55
- if (false === $this->fileHandler) {
56
- throw new Exception('Output file is not writable', 2);
57
- }
58
- }
59
 
60
- public function write($str)
61
- {
62
- $bytesWritten = 0;
63
- if (false === ($bytesWritten = fwrite($this->fileHandler, $str))) {
64
- throw new Exception('Writting to file failed! Probably, there is no more free space left?', 4);
65
- }
66
 
67
- return $bytesWritten;
68
- }
69
 
70
- public function close()
71
- {
72
- return fclose($this->fileHandler);
73
- }
74
  }
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 2.2.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 2.2.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlFileAdapter
49
  {
50
+ protected $fileHandler = null;
51
 
52
+ public function open($fileName)
53
+ {
54
+ $this->fileHandler = fopen($fileName, 'wb');
55
+ if (false === $this->fileHandler) {
56
+ throw new Exception('Output file is not writable', 2);
57
+ }
58
+ }
59
 
60
+ public function write($str)
61
+ {
62
+ $bytesWritten = 0;
63
+ if (false === ($bytesWritten = fwrite($this->fileHandler, $str))) {
64
+ throw new Exception('Writting to file failed! Probably, there is no more free space left?', 4);
65
+ }
66
 
67
+ return $bytesWritten;
68
+ }
69
 
70
+ public function close()
71
+ {
72
+ return fclose($this->fileHandler);
73
+ }
74
  }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlQueryAdapter.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.9.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,68 +42,81 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.9.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlQueryAdapter
49
  {
50
- public function __construct($type)
51
- {
52
- $this->type = $type;
53
- }
54
-
55
- public function set_names($encoding = 'utf8')
56
- {
57
- return "SET NAMES '$encoding'";
58
- }
59
-
60
- public function show_create_table($tableName)
61
- {
62
- return "SHOW CREATE TABLE `$tableName`";
63
- }
64
-
65
- public function drop_table($tableName)
66
- {
67
- return "DROP TABLE IF EXISTS `$tableName`";
68
- }
69
-
70
- public function show_tables($databaseName)
71
- {
72
- return "SELECT TABLE_NAME AS table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = '$databaseName'";
73
- }
74
-
75
- public function show_views($databaseName)
76
- {
77
- return "SELECT VIEW_NAME AS view_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA='$databaseName'";
78
- }
79
-
80
- public function start_transaction()
81
- {
82
- return "SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; START TRANSACTION";
83
- }
84
-
85
- public function commit_transaction()
86
- {
87
- return "SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; START TRANSACTION";
88
- }
89
-
90
- public function lock_table($tableName)
91
- {
92
- return "LOCK TABLES `$tableName` READ LOCAL";
93
- }
94
-
95
- public function unlock_tables()
96
- {
97
- return "UNLOCK TABLES";
98
- }
99
-
100
- public function start_add_lock_table($tableName)
101
- {
102
- return "LOCK TABLES `$tableName` WRITE;\n";
103
- }
104
-
105
- public function end_add_lock_tables()
106
- {
107
- return "UNLOCK TABLES;\n";
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 2.2.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 2.2.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlQueryAdapter
49
  {
50
+ public function __construct($type)
51
+ {
52
+ $this->type = $type;
53
+ }
54
+
55
+ public function set_names($encoding = 'utf8')
56
+ {
57
+ return "SET NAMES '$encoding'";
58
+ }
59
+
60
+ public function set_foreign_key($enabled = 0)
61
+ {
62
+ return "SET FOREIGN_KEY_CHECKS = $enabled";
63
+ }
64
+
65
+ public function show_create_table($tableName)
66
+ {
67
+ return "SHOW CREATE TABLE `$tableName`";
68
+ }
69
+
70
+ public function drop_table($tableName)
71
+ {
72
+ return "DROP TABLE IF EXISTS `$tableName`";
73
+ }
74
+
75
+ public function show_tables($databaseName)
76
+ {
77
+ return "SHOW TABLES FROM `$databaseName`";
78
+ }
79
+
80
+ public function show_views($databaseName) {
81
+ return "SHOW FULL TABLES FROM `$databaseName` WHERE TABLE_TYPE = 'VIEW'";
82
+ }
83
+
84
+ public function show_tables_information_schema($databaseName) {
85
+ return "SELECT TABLE_NAME AS table_name FROM `INFORMATION_SCHEMA`.`TABLES` WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = '$databaseName'";
86
+ }
87
+
88
+ public function show_views_information_schema($databaseName)
89
+ {
90
+ return "SELECT VIEW_NAME AS view_name FROM `INFORMATION_SCHEMA`.`TABLES` WHERE TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA = '$databaseName'";
91
+ }
92
+
93
+ public function start_transaction()
94
+ {
95
+ return "START TRANSACTION";
96
+ }
97
+
98
+ public function commit_transaction()
99
+ {
100
+ return "COMMIT";
101
+ }
102
+
103
+ public function rollback_transaction()
104
+ {
105
+ return "ROLLBACK";
106
+ }
107
+
108
+ public function lock_table_read($tableName)
109
+ {
110
+ return "LOCK TABLES `$tableName` READ";
111
+ }
112
+
113
+ public function lock_table_write($tableName)
114
+ {
115
+ return "LOCK TABLES `$tableName` WRITE";
116
+ }
117
+
118
+ public function unlock_tables()
119
+ {
120
+ return "UNLOCK TABLES";
121
+ }
122
  }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlUtility.php CHANGED
@@ -29,7 +29,7 @@
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 1.9.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
@@ -42,58 +42,58 @@
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 1.9.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlUtility
49
  {
50
- /**
51
- * Find and replace input with pattern
52
- *
53
- * @param string $input Value
54
- * @param string $pattern Pattern
55
- * @return string
56
- */
57
- public static function pregReplace($input, $pattern) {
58
- // PHP doesn't garbage collect functions created by create_function()
59
- static $callback = null;
60
 
61
- if ($callback === null) {
62
- $callback = create_function(
63
- '$matches',
64
- "return isset(\$matches[3]) ? 's:' .
65
- strlen(MysqlUtility::unescapeMysql(\$matches[3])) .
66
- ':\"' .
67
- MysqlUtility::unescapeQuotes(\$matches[3]) .
68
- '\";' : \$matches[0];
69
- "
70
- );
71
- }
72
 
73
- return preg_replace_callback($pattern, $callback, $input);
74
- }
75
 
76
- /**
77
- * Unescape to avoid dump-text issues
78
- *
79
- * @param string $input Text
80
- * @return string
81
- */
82
- public static function unescapeMysql($input) {
83
- return str_replace(
84
- array('\\\\', '\\0', "\\n", "\\r", '\Z', "\'", '\"'),
85
- array('\\', '\0', "\n", "\r", "\x1a", "'", '"'),
86
- $input
87
- );
88
- }
89
 
90
- /**
91
- * Fix strange behaviour if you have escaped quotes in your replacement
92
- *
93
- * @param string $input Text
94
- * @return string
95
- */
96
- public static function unescapeQuotes($input) {
97
- return str_replace('\"', '"', $input);
98
- }
99
  }
29
  * @author Bobby Angelov <bobby@servmask.com>
30
  * @copyright 2014 Yani Iliev, Bobby Angelov
31
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
32
+ * @version GIT: 2.2.0
33
  * @link https://github.com/yani-/mysqldump-factory/
34
  */
35
 
42
  * @author Bobby Angelov <bobby@servmask.com>
43
  * @copyright 2014 Yani Iliev, Bobby Angelov
44
  * @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
45
+ * @version GIT: 2.2.0
46
  * @link https://github.com/yani-/mysqldump-factory/
47
  */
48
  class MysqlUtility
49
  {
50
+ /**
51
+ * Find and replace input with pattern
52
+ *
53
+ * @param string $input Value
54
+ * @param string $pattern Pattern
55
+ * @return string
56
+ */
57
+ public static function pregReplace($input, $pattern) {
58
+ // PHP doesn't garbage collect functions created by create_function()
59
+ static $callback = null;
60
 
61
+ if ($callback === null) {
62
+ $callback = create_function(
63
+ '$matches',
64
+ "return isset(\$matches[3]) ? 's:' .
65
+ strlen(MysqlUtility::unescapeMysql(\$matches[3])) .
66
+ ':\"' .
67
+ MysqlUtility::unescapeQuotes(\$matches[3]) .
68
+ '\";' : \$matches[0];
69
+ "
70
+ );
71
+ }
72
 
73
+ return preg_replace_callback($pattern, $callback, $input);
74
+ }
75
 
76
+ /**
77
+ * Unescape to avoid dump-text issues
78
+ *
79
+ * @param string $input Text
80
+ * @return string
81
+ */
82
+ public static function unescapeMysql($input) {
83
+ return str_replace(
84
+ array('\\\\', '\\0', "\\n", "\\r", '\Z', "\'", '\"'),
85
+ array('\\', '\0', "\n", "\r", "\x1a", "'", '"'),
86
+ $input
87
+ );
88
+ }
89
 
90
+ /**
91
+ * Fix strange behaviour if you have escaped quotes in your replacement
92
+ *
93
+ * @param string $input Text
94
+ * @return string
95
+ */
96
+ public static function unescapeQuotes($input) {
97
+ return str_replace('\"', '"', $input);
98
+ }
99
  }
lib/vendor/servmask/archiver/class-ai1wm-archiver.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ abstract class Ai1wm_Archiver {
27
+
28
+ /**
29
+ * Header block format of a file
30
+ *
31
+ * Field Name Offset Length Contents
32
+ * name 0 255 filename (no path, no slash)
33
+ * size 255 14 length of file contents
34
+ * mtime 269 12 last modification time
35
+ * prefix 281 4096 path name, no trailing slashes
36
+ *
37
+ * @type string
38
+ */
39
+ protected $block_format = array(
40
+ 'a255', // filename
41
+ 'a14', // length of file contents
42
+ 'a12', // last time modified
43
+ 'a4096' // path
44
+ );
45
+
46
+ /**
47
+ * Filename including path to the file
48
+ *
49
+ * @type string
50
+ */
51
+ protected $filename = null;
52
+
53
+ /**
54
+ * Handle to the file
55
+ *
56
+ * @type resource
57
+ */
58
+ protected $file_handle = null;
59
+
60
+ /**
61
+ * End Of File block string
62
+ *
63
+ * @type string
64
+ */
65
+ protected $eof = null;
66
+
67
+ /**
68
+ * Default constructor
69
+ *
70
+ * Initializes filename and end of file block
71
+ *
72
+ * @param string $filename Archive file
73
+ */
74
+ public function __construct( $filename, $write = false ) {
75
+ // initialize file
76
+ $this->filename = $filename;
77
+
78
+ // initialize end of file
79
+ $this->eof = pack( 'a4377', '' );
80
+
81
+ if ( $write ) {
82
+ $this->file_handle = $this->open_file_for_writing( $filename );
83
+ } else {
84
+ $this->file_handle = $this->open_file_for_reading( $filename );
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Open the archive for reading
90
+ *
91
+ * @param string $file File to open
92
+ *
93
+ * @return resource
94
+ * @throws \Ai1wm_Not_Accesible_Exception
95
+ */
96
+ protected function open_file_for_reading( $file ) {
97
+ return $this->open_file_in_mode( $file, 'rb' );
98
+ }
99
+
100
+ /**
101
+ * Open the archive for writing/appending
102
+ *
103
+ * @param string $file File to open
104
+ *
105
+ * @return resource
106
+ * @throws \Ai1wm_Not_Accesible_Exception
107
+ */
108
+ protected function open_file_for_writing( $file ) {
109
+ return $this->open_file_in_mode( $file, 'ab' );
110
+ }
111
+
112
+ /**
113
+ * Open the archive for writing and truncate the file if it exist
114
+ *
115
+ * @param string $file File to open
116
+ *
117
+ * @return resource
118
+ * @throws \Ai1wm_Not_Accesible_Exception
119
+ */
120
+ protected function open_file_for_overwriting( $file ) {
121
+ return $this->open_file_in_mode( $file, 'wb' );
122
+ }
123
+
124
+ /**
125
+ * Opens file in the passed mode
126
+ *
127
+ * @param string $file File to be opened
128
+ * @param string $mode Mode to openthe file in
129
+ *
130
+ * @return resource
131
+ * @throws \Ai1wm_Not_Accesible_Exception
132
+ */
133
+ protected function open_file_in_mode( $file, $mode ) {
134
+ // open the file for writing in binary mode
135
+ $file_handle = @fopen( $file, $mode );
136
+
137
+ // check if we have a handle
138
+ if ( false === $file_handle ) {
139
+ // we couldn't open the file
140
+ throw new Ai1wm_Not_Accesible_Exception(
141
+ sprintf(
142
+ __(
143
+ 'Unable to open %s<br /><br />' .
144
+ '<strong>Possible solutions</strong><br />' .
145
+ '1. Ensure that you have enough disk space on your server.<br />' .
146
+ '2. Ensure that file permissions are correctly set-up - 775 or 777 to <strong>%s</strong> ' .
147
+ 'directory and all files and folders that it contains.',
148
+ AI1WM_PLUGIN_NAME
149
+ ),
150
+ $file,
151
+ WP_CONTENT_DIR
152
+ )
153
+ );
154
+ }
155
+
156
+ return $file_handle;
157
+ }
158
+
159
+ /**
160
+ * Write data to a handle and check if the data has been written
161
+ *
162
+ * @param resource $handle File handle
163
+ * @param string $data Data to be written - binary
164
+ * @param string $file Filename that the file handle belongs to
165
+ *
166
+ * @throws \Ai1wm_Not_Writable_Exception
167
+ */
168
+ protected function write_to_handle( $handle, $data, $file ) {
169
+ $result = @fwrite( $handle, $data );
170
+ if ( false === $result || ( ! empty( $data ) && 0 === $result ) ) {
171
+ throw new Ai1wm_Not_Writable_Exception(
172
+ __(
173
+ 'Unable to write to ' . $file . '<br /><br />' .
174
+ '<strong>Ensure that you have enough disk space on your server.</strong>',
175
+ AI1WM_PLUGIN_NAME
176
+ )
177
+ );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Read data from a handle
183
+ *
184
+ * @param resource $handle File handle
185
+ * @param int size Length of data to be read in bytes
186
+ * @param string $file Filename that the file handle belongs to
187
+ *
188
+ * @return string Content that was read
189
+ * @throws \Ai1wm_Not_Readable_Exception
190
+ */
191
+ protected function read_from_handle( $handle, $size, $file ) {
192
+ $result = @fread( $handle, $size );
193
+ if ( false === $result ) {
194
+ throw new Ai1wm_Not_Readable_Exception( __( 'Unable to read from ' . $file, AI1WM_PLUGIN_NAME ) );
195
+ }
196
+
197
+ return $result;
198
+ }
199
+
200
+
201
+ /**
202
+ * Appends end of file block to the archive
203
+ *
204
+ * @throws \Ai1wm_Not_Writable_Exception
205
+ */
206
+ protected function append_eof() {
207
+ $this->write_to_handle( $this->file_handle, $this->eof, $this->filename );
208
+ }
209
+
210
+ /**
211
+ * Closes the archive file
212
+ *
213
+ * We either close the file or append the end of file block if complete argument is set to tru
214
+ *
215
+ * @param bool $complete Flag to append end of file block
216
+ *
217
+ * @throws \Ai1wm_Not_Accesible_Exception
218
+ * @throws \Ai1wm_Not_Writable_Exception
219
+ */
220
+ public function close( $complete = false ) {
221
+ // are we done appending to the file?
222
+ if ( true === $complete ) {
223
+ $this->append_eof();
224
+ }
225
+
226
+ // close the file
227
+ $result = fclose( $this->file_handle );
228
+
229
+ if ( false === $result ) {
230
+ // unable to close the file
231
+ throw new Ai1wm_Not_Accesible_Exception( __( 'Unable to close ' . $this->filename, AI1WM_PLUGIN_NAME ) );
232
+ }
233
+ }
234
+
235
+ }
lib/vendor/servmask/archiver/class-ai1wm-compressor.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Compressor extends Ai1wm_Archiver {
27
+
28
+ /**
29
+ * Overloaded constructor that opens the passed file for writing
30
+ *
31
+ * @param string $file File to use as archive
32
+ */
33
+ public function __construct( $file ) {
34
+ // call parent, to initialize variables
35
+ parent::__construct( $file, true );
36
+ }
37
+
38
+ /**
39
+ * Add a file to the archive
40
+ *
41
+ * @param string $file File to add to the archive
42
+ * @param string $new_filename Write the file with a different name
43
+ *
44
+ * @throws \Ai1wm_Not_Accesible_Exception
45
+ * @throws \Ai1wm_Not_Readable_Exception
46
+ * @throws \Ai1wm_Not_Writable_Exception
47
+ */
48
+ public function add_file( $file, $new_filename = '' ) {
49
+ // open the file for reading in binary mode
50
+ $handle = $this->open_file_for_reading( $file );
51
+
52
+ // get file block header of the file we are trying to archive
53
+ $block = $this->get_file_block( $file, $new_filename );
54
+
55
+ // write file block header to our archive file
56
+ $this->write_to_handle( $this->file_handle, $block, $this->filename );
57
+
58
+ // read the file in 512KB chunks
59
+ while ( false === feof( $handle ) ) {
60
+ $content = $this->read_from_handle( $handle, 512000, $file );
61
+ // write file contents
62
+ $this->write_to_handle(
63
+ $this->file_handle,
64
+ $content,
65
+ $this->filename
66
+ );
67
+ }
68
+ // close the handle
69
+ fclose( $handle );
70
+ }
71
+
72
+ /**
73
+ * Generate binary block header for a file
74
+ *
75
+ * @param string $file Filename to generate block header for
76
+ * @param string $new_filename Write the file with a different name
77
+ *
78
+ * @return string
79
+ * @throws \Ai1wm_Not_Accesible_Exception
80
+ */
81
+ private function get_file_block( $file, $new_filename = '' ) {
82
+ // get stats about the file
83
+ $stat = stat( $file );
84
+ if ( false === $stat ) {
85
+ // unable to get file data
86
+ throw new Ai1wm_Not_Accesible_Exception( __( 'Unable to get properties of file ' . $file, AI1WM_PLUGIN_NAME ) );
87
+ }
88
+
89
+ // get path details
90
+ $pathinfo = pathinfo( $file );
91
+
92
+ if ( ! empty( $new_filename ) ) {
93
+ // get path details
94
+ $pathinfo = pathinfo( $new_filename );
95
+ }
96
+
97
+ // filename of the file we are accessing
98
+ $name = $pathinfo['basename'];
99
+ // content length in bytes of the file
100
+ $length = $stat['7'];
101
+ // last time the file was modified
102
+ $date = $stat['9'];
103
+
104
+ // replace DIRECTORY_SEPARATOR with / in path, we want to always have /
105
+ $path = str_replace( DIRECTORY_SEPARATOR, "/", $pathinfo['dirname'] );
106
+
107
+ // concatenate block format parts
108
+ $format = implode( "", $this->block_format );
109
+
110
+ // pack file data into binary string
111
+ return pack( $format, $name, $length, $date, $path );
112
+ }
113
+ }
lib/vendor/servmask/archiver/class-ai1wm-extractor.php ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Extractor extends Ai1wm_Archiver {
27
+ /**
28
+ * Overloaded constructor that opens the passed file for reading
29
+ *
30
+ * @param string $file File to use as archive
31
+ */
32
+ public function __construct( $file ) {
33
+ // call parent, to initialize variables
34
+ parent::__construct( $file );
35
+ }
36
+
37
+ /**
38
+ * Extract files from archive to specified location
39
+ *
40
+ * @param string $location Location where the files should be extracted
41
+ * @param int $seek Location in the file to start exporting data from
42
+ */
43
+ public function extract_files( $location, $seek = 0 ) {
44
+
45
+ }
46
+
47
+ /**
48
+ * Get the number of files in an archive
49
+ *
50
+ * @return int Number of files found in the archive
51
+ * @throws \Ai1wm_Not_Accesible_Exception
52
+ * @throws \Ai1wm_Not_Readable_Exception
53
+ */
54
+ public function get_number_of_files() {
55
+ // files counter
56
+ $files_found = 0;
57
+
58
+ while ( $block = $this->read_from_handle( $this->file_handle, 4377, $this->filename ) ) {
59
+ // end block has been reached
60
+ if ( $block === $this->eof ) {
61
+ continue;
62
+ }
63
+
64
+ // get file data from the block
65
+ $data = $this->get_data_from_block( $block );
66
+
67
+ // we have a file, increment the counter
68
+ $files_found++;
69
+
70
+ // skip file content so we can move forward to the next file
71
+ $this->set_file_pointer( $this->file_handle, $data['size'], $this->filename );
72
+ }
73
+
74
+ return $files_found;
75
+ }
76
+
77
+ public function extract_one_file_to( $location, $exclude = array() ) {
78
+ if ( false === file_exists( $location ) ) {
79
+ throw new Ai1wm_Not_Readable_Exception( sprintf( __( '%s doesn\'t exist', AI1WM_PLUGIN_NAME ), $location ) );
80
+ }
81
+
82
+ $block = $this->read_from_handle( $this->file_handle, 4377, $this->filename );
83
+
84
+ if ( $block === $this->eof ) {
85
+ // we reached end of file, set the pointer to the end of the file so that feof returns true
86
+ @fseek( $this->file_handle, 1, SEEK_END );
87
+ @fgetc( $this->file_handle );
88
+ return;
89
+ }
90
+
91
+ // get file data from header block
92
+ $data = $this->get_data_from_block( $block );
93
+
94
+ // set filename
95
+ if ( $data['path'] === '.' ) {
96
+ $filename = $data['filename'];
97
+ } else {
98
+ $filename = $data['path'] . '/' . $data['filename'];
99
+ }
100
+
101
+ // should we skip this file?
102
+ if ( in_array( $filename, $exclude ) ) {
103
+ // we don't have a match, skip file content
104
+ $this->set_file_pointer( $this->file_handle, $data['size'], $this->filename );
105
+ return;
106
+ }
107
+
108
+ // we need to build the path for the file
109
+ $path = str_replace( '/', DIRECTORY_SEPARATOR, $data['path'] );
110
+
111
+ // append prepend extract location
112
+ $path = $location . DIRECTORY_SEPARATOR . $path;
113
+
114
+ // check if location doesn't exist, then create it
115
+ if ( false === file_exists( $path ) ) {
116
+ mkdir( $path, 0755, true );
117
+ }
118
+
119
+ $this->extract_to( $path . DIRECTORY_SEPARATOR . $data['filename'], $data );
120
+ }
121
+
122
+ /**
123
+ * Extract specific files from archive
124
+ *
125
+ * @param string $location Location where to extract files
126
+ * @param array $files Files to extract
127
+ */
128
+ public function extract_by_files_array( $location, $files = array() ) {
129
+ if ( false === file_exists( $location ) ) {
130
+ throw new Ai1wm_Not_Readable_Exception( sprintf( __( '%s doesn\'t exist', AI1WM_PLUGIN_NAME ), $location ) );
131
+ }
132
+
133
+ // we read until we reached the end of the file, or the files we were looking for were found
134
+ while (
135
+ ($block = $this->read_from_handle( $this->file_handle, 4377, $this->filename )) &&
136
+ ( count( $files ) > 0 )
137
+ ) {
138
+ // end block has been reached and we still have files to extract
139
+ // that means the files don't exist in the archive
140
+ if ( $block === $this->eof ) {
141
+ // we reached end of file, set the pointer to the end of the file so that feof returns true
142
+ @fseek( $this->file_handle, 1, SEEK_END );
143
+ @fgetc( $this->file_handle );
144
+ return;
145
+ }
146
+
147
+ $data = $this->get_data_from_block( $block );
148
+
149
+ // set filename
150
+ if ( $data['path'] === '.' ) {
151
+ $filename = $data['filename'];
152
+ } else {
153
+ $filename = $data['path'] . '/' . $data['filename'];
154
+ }
155
+
156
+ // do we have a match?
157
+ if ( in_array( $filename, $files ) ) {
158
+ // we have a match, let's extract the file and remove it from the array
159
+ $this->extract_to( $location . DIRECTORY_SEPARATOR . $data['filename'], $data );
160
+
161
+ // let's unset the file from the files array
162
+ $key = array_search( $data['filename'], $files );
163
+ unset( $files[$key] );
164
+ } else {
165
+ // we don't have a match, skip file content
166
+ $this->set_file_pointer( $this->file_handle, $data['size'], $this->filename );
167
+ }
168
+ }
169
+ }
170
+
171
+ public function set_file_pointer( $handle = null, $offset = 0, $file = '' ) {
172
+ // if null is used, we use the archive handle
173
+ if ( is_null( $handle ) ) {
174
+ $handle = $this->file_handle;
175
+ }
176
+
177
+ // if filename is empty, we use archive filename
178
+ if ( empty( $file ) ) {
179
+ $file = $this->filename;
180
+ }
181
+
182
+ // do we have offset to apply?
183
+ if ( $offset > 0 ) {
184
+ // set position to current location plus offset
185
+ $result = fseek( $handle, $offset, SEEK_CUR );
186
+
187
+ if ( -1 === $result ) {
188
+ throw new Ai1wm_Not_Accesible_Exception(
189
+ sprintf(
190
+ __( 'Unable to seek to offset %d on %s', AI1WM_PLUGIN_NAME ),
191
+ $offset,
192
+ $file
193
+ )
194
+ );
195
+ }
196
+ }
197
+ }
198
+
199
+ private function extract_to( $file, $data, $overwrite = true ) {
200
+ // local file handle
201
+ $handle = null;
202
+
203
+ // should the extract overwrite the file if it exists?
204
+ if ( $overwrite ) {
205
+ $handle = $this->open_file_for_overwriting( $file );
206
+ } else {
207
+ $handle = $this->open_file_for_writing( $file );
208
+ }
209
+
210
+ // is the filesize more than 0 bytes?
211
+ while ( $data['size'] > 0 ) {
212
+ // read the file in chunks of 512KB
213
+ $length = $data['size'] > 512000 ? 512000 : $data['size'];
214
+ // read the file in chunks of 512KB from archiver
215
+ $content = $this->read_from_handle( $this->file_handle, $length, $this->filename );
216
+ // remote the amount of bytes we read
217
+ $data['size'] -= $length;
218
+
219
+ // write file contents
220
+ $this->write_to_handle( $handle, $content, $file );
221
+ }
222
+
223
+ // close the handle
224
+ fclose( $handle );
225
+
226
+ // let's apply last modified date
227
+ $this->set_mtime_of_file( $file, $data['mtime'] );
228
+
229
+ // all files should chmoded to 755
230
+ $this->set_file_mode( $file, 0644 );
231
+ }
232
+
233
+ private function set_mtime_of_file( $file, $mtime ) {
234
+ $result = touch( $file, $mtime );
235
+
236
+ if ( false === $result ) {
237
+ throw new Ai1wm_Not_Accesible_Exception(
238
+ sprintf(
239
+ __( 'Unable to set last modified date of %s', AI1WM_PLUGIN_NAME ),
240
+ $file
241
+ )
242
+ );
243
+ }
244
+ }
245
+
246
+ private function set_file_mode( $file, $mode = 0644 ) {
247
+ $result = chmod( $file, $mode );
248
+
249
+ if ( false === $result ) {
250
+ throw new Ai1wm_Not_Accesible_Exception(
251
+ sprintf(
252
+ __( 'Unable to set mode to %o of %s', AI1WM_PLUGIN_NAME ),
253
+ $mode,
254
+ $file
255
+ )
256
+ );
257
+ }
258
+ }
259
+
260
+ private function get_data_from_block( $block ) {
261
+ // prepare our array keys to unpack
262
+ $format = array(
263
+ $this->block_format[0] . 'filename/',
264
+ $this->block_format[1] . 'size/',
265
+ $this->block_format[2] . 'mtime/',
266
+ $this->block_format[3] . 'path',
267
+ );
268
+ $format = implode( '', $format );
269
+
270
+ $data = unpack( $format, $block );
271
+
272
+ $data['filename'] = trim( $data['filename'] );
273
+ $data['size'] = trim( $data['size'] );
274
+ $data['mtime'] = trim( $data['mtime'] );
275
+ $data['path'] = trim( $data['path'] );
276
+
277
+ return $data;
278
+ }
279
+
280
+ /**
281
+ * Check if file has reached end of file
282
+ * Returns true if file has NOT reached eof, false otherwise
283
+ *
284
+ * @return bool
285
+ */
286
+ public function has_not_reached_eof() {
287
+ return ! feof( $this->file_handle );
288
+ }
289
+
290
+ public function get_file_pointer() {
291
+ $result = ftell( $this->file_handle );
292
+
293
+ if ( false === $result ) {
294
+ throw new Ai1wm_Not_Accesible_Exception(
295
+ sprintf(
296
+ __( 'Unable to get current pointer position of %s', AI1WM_PLUGIN_NAME ),
297
+ $this->filename
298
+ )
299
+ );
300
+ }
301
+
302
+ return $result;
303
+ }
304
+ }
lib/{model/service/class-ai1wm-service-plugins.php → vendor/servmask/cron/class-ai1wm-cron.php} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,69 +23,49 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- class Ai1wm_Service_Plugins implements Ai1wm_Service_Interface
27
- {
28
- protected $options = array();
29
-
30
- public function __construct( array $options = array() ) {
31
- $this->options = $options;
32
- }
33
-
34
- /**
35
- * Import plugins
36
  *
37
- * @return void
 
 
 
38
  */
39
- public function import() {
40
- $storage = StorageArea::getInstance();
41
-
42
- // Plugins directory
43
- $plugins_dir = WP_PLUGIN_DIR;
44
- if ( ! is_dir( $plugins_dir ) ) {
45
- mkdir( $plugins_dir );
46
  }
47
-
48
- // Backup plugin files
49
- $backup_plugins_to = $storage->makeDirectory();
50
-
51
- StorageUtility::copy( $plugins_dir, $backup_plugins_to->getName(), array( AI1WM_PLUGIN_NAME ) );
52
-
53
- // Flush plugin files
54
- StorageUtility::flush( $plugins_dir, array( AI1WM_PLUGIN_NAME ) );
55
-
56
- // Import plugin files
57
- StorageUtility::copy( $storage->getRootPath() . AI1WM_PLUGINS_NAME, $plugins_dir );
58
- }
59
-
60
- /**
61
- * Export plugins
62
- *
63
- * @return string
64
- */
65
- public function export() {
66
- return WP_PLUGIN_DIR;
67
  }
68
 
69
- /**
70
- * Get installed plugins
 
71
  *
72
- * @param array $exclude Exclude plugins
73
- * @return array
74
  */
75
- public function get_installed_plugins( $exclude = array( AI1WM_PLUGIN_NAME ) ) {
76
- if ( ! function_exists( 'get_plugins' ) ) {
77
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
 
78
  }
79
 
80
- $plugins = array();
81
- foreach ( get_plugins() as $key => $plugin ) {
82
- $directory = dirname( $key );
83
- if ( $directory !== '.' && ! in_array( $directory, $exclude ) ) {
84
- $plugins[] = $directory;
 
 
 
85
  }
86
  }
87
 
88
- return $plugins;
89
  }
90
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Cron {
27
 
28
+ /*
29
+ * Schedules a hook which will be executed by the WordPress
30
+ * actions core on a specific interval
 
 
 
 
 
 
 
31
  *
32
+ * @param string $hook Event hook
33
+ * @param string $recurrence How often the event should reoccur
34
+ * @param array $args Arguments to pass to the hook function(s)
35
+ * @return mixed
36
  */
37
+ public static function add( $hook, $recurrence, $args = array() ) {
38
+ $args = array_slice( func_get_args(), 2 );
39
+ $schedules = wp_get_schedules();
40
+ if ( isset( $schedules[$recurrence] ) && ( $current = $schedules[$recurrence] ) ) {
41
+ return wp_schedule_event( time() + $current['interval'], $recurrence, $hook, $args );
 
 
42
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
+ /*
46
+ * Un-schedules all previously-scheduled cron jobs using a particular
47
+ * hook name or a specific combination of hook name and arguments.
48
  *
49
+ * @param string $hook Event hook
50
+ * @return void
51
  */
52
+ public static function clear( $hook ) {
53
+ $crons = _get_cron_array();
54
+ if ( empty( $crons ) ) {
55
+ return;
56
  }
57
 
58
+ foreach ( $crons as $timestamp => $cron ) {
59
+ if ( ! empty( $cron[$hook] ) ) {
60
+ unset( $crons[$timestamp][$hook] );
61
+
62
+ // Unset empty timestamps
63
+ if ( empty( $crons[$timestamp] ) ) {
64
+ unset( $crons[$timestamp] );
65
+ }
66
  }
67
  }
68
 
69
+ return _set_cron_array( $crons );
70
  }
71
  }
lib/{model/service/class-ai1wm-service-media.php → vendor/servmask/filesystem/class-ai1wm-file.php} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,50 +23,45 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- class Ai1wm_Service_Media implements Ai1wm_Service_Interface
27
- {
28
- protected $options = array();
29
 
30
- public function __construct( array $options = array() ) {
31
- $this->options = $options;
32
- }
33
 
34
- /**
35
- * Import media
36
- *
37
- * @return void
38
- */
39
- public function import() {
40
- $storage = StorageArea::getInstance();
41
 
42
- // Media directory
43
- $upload_dir = wp_upload_dir();
44
- $upload_basedir = $upload_dir['basedir'];
45
- if ( ! is_dir( $upload_basedir ) ) {
46
- mkdir( $upload_basedir );
47
- }
48
 
49
- // Backup media files
50
- $backup_media_to = $storage->makeDirectory();
 
51
 
52
- StorageUtility::copy( $upload_basedir, $backup_media_to->getName() );
 
 
53
 
54
- // Flush media files
55
- StorageUtility::flush( $upload_basedir );
 
56
 
57
- // Import media files
58
- StorageUtility::copy( $storage->getRootPath() . AI1WM_MEDIA_NAME, $upload_basedir );
59
  }
60
 
61
- /**
62
- * Export media
63
- *
64
- * @return string
65
- */
66
- public function export() {
67
- $upload_dir = wp_upload_dir();
68
 
69
- return $upload_dir['basedir'];
 
70
  }
71
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_File {
27
 
28
+ protected $file = null;
 
 
29
 
30
+ protected $name = null;
31
+
32
+ protected $size = null;
33
 
34
+ protected $createdAt = null;
35
+
36
+ public function setFile($file) {
37
+ $this->file = $file;
38
+ }
 
 
39
 
40
+ public function getFile() {
41
+ return $this->file;
42
+ }
 
 
 
43
 
44
+ public function setName($name) {
45
+ $this->name = $name;
46
+ }
47
 
48
+ public function getName() {
49
+ return $this->name;
50
+ }
51
 
52
+ public function setSize($size) {
53
+ $this->size = $size;
54
+ }
55
 
56
+ public function getSize() {
57
+ return $this->size;
58
  }
59
 
60
+ public function setCreatedAt($createdAt) {
61
+ $this->createdAt = $createdAt;
62
+ }
 
 
 
 
63
 
64
+ public function getCreatedAt() {
65
+ return $this->createdAt;
66
  }
67
  }
lib/vendor/servmask/filter/class-ai1wm-recursive-exclude-filter.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Recursive_Exclude_Filter extends RecursiveFilterIterator {
27
+
28
+ protected $exclude = array();
29
+
30
+ public function __construct( RecursiveIterator $recursiveIterator, $exclude = array() ) {
31
+ $this->exclude = $exclude;
32
+ parent::__construct( $recursiveIterator );
33
+ }
34
+
35
+ public function accept() {
36
+ return ! in_array( $this->getInnerIterator()->getSubPathname(), $this->exclude );
37
+ }
38
+
39
+ public function getChildren() {
40
+ return new self( $this->getInnerIterator()->getChildren(), $this->exclude );
41
+ }
42
+ }
lib/{model/service/class-ai1wm-service-themes.php → vendor/servmask/iterator/class-ai1wm-recursive-directory-iterator.php} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Copyright (C) 2014 ServMask Inc.
4
  *
@@ -22,47 +23,28 @@
22
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
 
25
 
26
- class Ai1wm_Service_Themes implements Ai1wm_Service_Interface
27
- {
28
- protected $options = array();
29
 
30
- public function __construct( array $options = array() ) {
31
- $this->options = $options;
 
32
  }
33
 
34
- /**
35
- * Import themes
36
- *
37
- * @return void
38
- */
39
- public function import() {
40
- $storage = StorageArea::getInstance();
41
-
42
- // Themes directory
43
- $themes_dir = get_theme_root();
44
- if ( ! is_dir( $themes_dir ) ) {
45
- mkdir( $themes_dir );
46
- }
47
-
48
- // Backup themes files
49
- $backup_themes_to = $storage->makeDirectory();
50
-
51
- StorageUtility::copy( $themes_dir, $backup_themes_to->getName() );
52
-
53
- // Flush themes files
54
- StorageUtility::flush( $themes_dir );
55
 
56
- // Import themes files
57
- StorageUtility::copy( $storage->getRootPath() . AI1WM_THEMES_NAME, $themes_dir );
 
58
  }
59
 
60
- /**
61
- * Export themes
62
- *
63
- * @return string
64
- */
65
- public function export() {
66
- return get_theme_root();
67
  }
68
  }
1
  <?php
2
+
3
  /**
4
  * Copyright (C) 2014 ServMask Inc.
5
  *
23
  * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
24
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
25
  */
26
+ class Ai1wm_Recursive_Directory_Iterator extends RecursiveDirectoryIterator {
27
 
28
+ protected $exclude = array();
 
 
29
 
30
+ public function __construct( $path ) {
31
+ parent::__construct( $path );
32
+ $this->skipdots();
33
  }
34
 
35
+ public function rewind() {
36
+ parent::rewind();
37
+ $this->skipdots();
38
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ public function next() {
41
+ parent::next();
42
+ $this->skipdots();
43
  }
44
 
45
+ protected function skipdots() {
46
+ while ($this->isDot()) {
47
+ parent::next();
48
+ }
 
 
 
49
  }
50
  }
lib/vendor/storage-factory/storage-factory/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 Yani Iliev, Bobby Angelov
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/storage-factory/storage-factory/lib/StorageAbstract.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * StorageAbstract class
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category FileSystem
27
- * @package StorageFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @author Bobby Angelov <bobby@servmask.com>
30
- * @copyright 2014 Yani Iliev, Bobby Angelov
31
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 2.6.0
33
- * @link https://github.com/borislav-angelov/storage-factory/
34
- */
35
-
36
- /**
37
- * StorageAbstract class
38
- *
39
- * @category FileSystem
40
- * @package StorageFactory
41
- * @author Yani Iliev <yani@iliev.me>
42
- * @author Bobby Angelov <bobby@servmask.com>
43
- * @copyright 2014 Yani Iliev, Bobby Angelov
44
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 2.6.0
46
- * @link https://github.com/borislav-angelov/storage-factory/
47
- */
48
- abstract class StorageAbstract
49
- {
50
- /**
51
- * Get file/directory name
52
- *
53
- * @return string
54
- */
55
- abstract public function getName();
56
-
57
- /**
58
- * Get file/directory resource
59
- *
60
- * @return resource
61
- */
62
- abstract public function getResource();
63
-
64
- /**
65
- * Delete file/directory
66
- *
67
- * @return boolean
68
- */
69
- abstract public function delete();
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/storage-factory/storage-factory/lib/StorageArea.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * StorageArea class main file
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category FileSystem
27
- * @package StorageFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @author Bobby Angelov <bobby@servmask.com>
30
- * @copyright 2014 Yani Iliev, Bobby Angelov
31
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 2.6.0
33
- * @link https://github.com/borislav-angelov/storage-factory/
34
- */
35
-
36
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'StorageFile.php';
37
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'StorageDirectory.php';
38
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'StorageUtility.php';
39
-
40
- /**
41
- * StorageArea Main class
42
- *
43
- * @category FileSystem
44
- * @package StorageFactory
45
- * @author Yani Iliev <yani@iliev.me>
46
- * @author Bobby Angelov <bobby@servmask.com>
47
- * @copyright 2014 Yani Iliev, Bobby Angelov
48
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
49
- * @version GIT: 2.6.0
50
- * @link https://github.com/borislav-angelov/storage-factory/
51
- */
52
- class StorageArea
53
- {
54
- protected static $instance = null;
55
-
56
- public static function getInstance() {
57
- if (self::$instance === null) {
58
- self::$instance = new self;
59
- }
60
-
61
- return self::$instance;
62
- }
63
-
64
- private function __construct() {
65
- // Singleton
66
- }
67
-
68
-
69
- /**
70
- * Get storage absolute path
71
- *
72
- * @return string
73
- */
74
- public function getRootPath() {
75
- if (defined('AI1WM_STORAGE_PATH')) {
76
- if (!is_dir(AI1WM_STORAGE_PATH)) {
77
- @mkdir(AI1WM_STORAGE_PATH);
78
- }
79
-
80
- // Verify permissions
81
- if (StorageUtility::isAccessible(AI1WM_STORAGE_PATH)) {
82
- if (defined('AI1WM_STORAGE_INDEX')) {
83
- $index = AI1WM_STORAGE_PATH . DIRECTORY_SEPARATOR . AI1WM_STORAGE_INDEX;
84
- if (!is_file($index)) {
85
- @touch($index);
86
- }
87
- }
88
-
89
- return AI1WM_STORAGE_PATH . DIRECTORY_SEPARATOR;
90
- } else {
91
- throw new Exception('Storage directory is not accessible (read/write).');
92
- }
93
- } else {
94
- throw new Exception('AI1WM_STORAGE_PATH is not defined.');
95
- }
96
- }
97
-
98
- /**
99
- * Create a file with unique name
100
- *
101
- * @param string $name Custom file name
102
- * @return StorageFile StorageFile instance
103
- */
104
- public function makeFile($name = null) {
105
- return new StorageFile($name, $this->getRootPath());
106
- }
107
-
108
- /**
109
- * Create a directory with unique name
110
- *
111
- * @param string $name Custom directory name
112
- * @return StorageDirectory StorageDirectory instance
113
- */
114
- public function makeDirectory($name = null) {
115
- return new StorageDirectory($name, $this->getRootPath());
116
- }
117
-
118
- /**
119
- * Delete all files and directories in the storage
120
- *
121
- * @return boolean
122
- */
123
- public function flush() {
124
- if (defined('AI1WM_STORAGE_INDEX')) {
125
- return StorageUtility::flush($this->getRootPath(), array(AI1WM_STORAGE_INDEX));
126
- }
127
-
128
- return StorageUtility::flush($this->getRootPath());
129
- }
130
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/storage-factory/storage-factory/lib/StorageDirectory.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * StorageDirectory class
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category FileSystem
27
- * @package StorageFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @author Bobby Angelov <bobby@servmask.com>
30
- * @copyright 2014 Yani Iliev, Bobby Angelov
31
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 2.6.0
33
- * @link https://github.com/borislav-angelov/storage-factory/
34
- */
35
-
36
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'StorageAbstract.php';
37
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'StorageUtility.php';
38
-
39
- /**
40
- * StorageDirectory class
41
- *
42
- * @category FileSystem
43
- * @package StorageFactory
44
- * @author Yani Iliev <yani@iliev.me>
45
- * @author Bobby Angelov <bobby@servmask.com>
46
- * @copyright 2014 Yani Iliev, Bobby Angelov
47
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
48
- * @version GIT: 2.6.0
49
- * @link https://github.com/borislav-angelov/storage-factory/
50
- */
51
- class StorageDirectory extends StorageAbstract
52
- {
53
- protected $directory = null;
54
-
55
- /**
56
- * CTOR
57
- */
58
- public function __construct($name = null, $path = null) {
59
- if (empty($name)) {
60
- $this->directory = $path . DIRECTORY_SEPARATOR . uniqid() . DIRECTORY_SEPARATOR;
61
- } else {
62
- $this->directory = $path . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR;
63
- }
64
-
65
- // Create directory
66
- if (!is_dir($this->directory)) {
67
- mkdir($this->directory);
68
- }
69
- }
70
-
71
- /**
72
- * Get directory name
73
- *
74
- * @return string
75
- */
76
- public function getName() {
77
- return $this->directory;
78
- }
79
-
80
- /**
81
- * Get directory resource
82
- *
83
- * @return resource
84
- */
85
- public function getResource() {
86
- return opendir($this->directory);
87
- }
88
-
89
- /**
90
- * Delete directory
91
- *
92
- * @return boolean
93
- */
94
- public function delete() {
95
- // Remove child files and directories
96
- if (StorageUtility::flush($this->directory)) {
97
- return rmdir($this->directory);
98
- }
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/storage-factory/storage-factory/lib/StorageFile.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * StorageFile class
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category FileSystem
27
- * @package StorageFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @author Bobby Angelov <bobby@servmask.com>
30
- * @copyright 2014 Yani Iliev, Bobby Angelov
31
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 2.6.0
33
- * @link https://github.com/borislav-angelov/storage-factory/
34
- */
35
-
36
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'StorageAbstract.php';
37
-
38
- /**
39
- * StorageFile class
40
- *
41
- * @category FileSystem
42
- * @package StorageFactory
43
- * @author Yani Iliev <yani@iliev.me>
44
- * @author Bobby Angelov <bobby@servmask.com>
45
- * @copyright 2014 Yani Iliev, Bobby Angelov
46
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
47
- * @version GIT: 2.6.0
48
- * @link https://github.com/borislav-angelov/storage-factory/
49
- */
50
- class StorageFile extends StorageAbstract
51
- {
52
- protected $file = null;
53
-
54
- /**
55
- * CTOR
56
- */
57
- public function __construct($name = null, $path = null) {
58
- if (empty($name)) {
59
- $this->file = tempnam($path, null);
60
- } else {
61
- $this->file = $path . DIRECTORY_SEPARATOR . $name;
62
- }
63
- }
64
-
65
- /**
66
- * Get file name
67
- *
68
- * @return string
69
- */
70
- public function getName() {
71
- return $this->file;
72
- }
73
-
74
- /**
75
- * Get file resource
76
- *
77
- * @return resource
78
- */
79
- public function getResource() {
80
- return fopen($this->file, 'a+');
81
- }
82
-
83
- /**
84
- * Get file size
85
- *
86
- * @return integer
87
- */
88
- public function getSize() {
89
- return filesize($this->file);
90
- }
91
-
92
- /**
93
- * Delete file
94
- *
95
- * @return boolean
96
- */
97
- public function delete() {
98
- return unlink($this->file);
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/storage-factory/storage-factory/lib/StorageUtility.php DELETED
@@ -1,162 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * StorageUtility class
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category FileSystem
27
- * @package StorageFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @author Bobby Angelov <bobby@servmask.com>
30
- * @copyright 2014 Yani Iliev, Bobby Angelov
31
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
32
- * @version GIT: 2.6.0
33
- * @link https://github.com/borislav-angelov/storage-factory/
34
- */
35
-
36
- /**
37
- * StorageUtility class
38
- *
39
- * @category FileSystem
40
- * @package StorageFactory
41
- * @author Yani Iliev <yani@iliev.me>
42
- * @author Bobby Angelov <bobby@servmask.com>
43
- * @copyright 2014 Yani Iliev, Bobby Angelov
44
- * @license https://raw.github.com/borislav-angelov/storage-factory/master/LICENSE The MIT License (MIT)
45
- * @version GIT: 2.6.0
46
- * @link https://github.com/borislav-angelov/storage-factory/
47
- */
48
- class StorageUtility
49
- {
50
- /**
51
- * Is path accessible (read/write)
52
- *
53
- * @param string Absolute path
54
- * @return boolean
55
- */
56
- public static function isAccessible($path) {
57
- return is_readable($path) && is_writable($path);
58
- }
59
-
60
- /**
61
- * Recursive copy directory from source to destination path
62
- *
63
- * @param string $from From absolute path
64
- * @param string $to To absolute path
65
- * @param array $exclude Exclude files and directories
66
- * @return boolean
67
- */
68
- public static function copy($from, $to, $exclude = array()) {
69
- $iterator = new RecursiveIteratorIterator(
70
- new RecursiveDirectoryIterator($from),
71
- RecursiveIteratorIterator::SELF_FIRST
72
- );
73
-
74
- // Prepare filter pattern
75
- $filter_pattern = null;
76
- if (is_array($exclude)) {
77
- $filters = array();
78
- foreach ($exclude as $filter) {
79
- $filters[] = sprintf(
80
- '(%s(%s.*)?)',
81
- preg_quote($filter, '/'),
82
- preg_quote(DIRECTORY_SEPARATOR, '/')
83
- );
84
- }
85
-
86
- $filter_pattern = implode('|', $filters);
87
- }
88
-
89
- foreach ($iterator as $item) {
90
- // Skip dots
91
- if ($iterator->isDot()) {
92
- continue;
93
- }
94
-
95
- // Validate filter pattern
96
- if ($filter_pattern) {
97
- if (preg_match('/^' . $filter_pattern . '$/', $iterator->getSubPathName())) {
98
- continue;
99
- }
100
- }
101
-
102
- if ($item->isDir()) {
103
- mkdir($to . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
104
- } else {
105
- copy($item, $to . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
106
- }
107
- }
108
-
109
- return true;
110
- }
111
-
112
- /**
113
- * Recursive delete directory
114
- *
115
- * @param string $path Absolute path
116
- * @param array $exclude Exclude files and directories
117
- * @return boolean
118
- */
119
- public static function flush($path, $exclude = array()) {
120
- $iterator = new RecursiveIteratorIterator(
121
- new RecursiveDirectoryIterator($path),
122
- RecursiveIteratorIterator::CHILD_FIRST
123
- );
124
-
125
- // Prepare filter pattern
126
- $filter_pattern = null;
127
- if (is_array($exclude)) {
128
- $filters = array();
129
- foreach ($exclude as $filter) {
130
- $filters[] = sprintf(
131
- '(%s(%s.*)?)',
132
- preg_quote($filter, '/'),
133
- preg_quote(DIRECTORY_SEPARATOR, '/')
134
- );
135
- }
136
-
137
- $filter_pattern = implode('|', $filters);
138
- }
139
-
140
- foreach ($iterator as $item) {
141
- // Skip dots
142
- if ($iterator->isDot()) {
143
- continue;
144
- }
145
-
146
- // Validate filter pattern
147
- if ($filter_pattern) {
148
- if (preg_match('/^' . $filter_pattern . '$/', $iterator->getSubPathName())) {
149
- continue;
150
- }
151
- }
152
-
153
- if ($item->isDir()) {
154
- rmdir($path . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
155
- } else {
156
- unlink($path . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
157
- }
158
- }
159
-
160
- return true;
161
- }
162
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/zip-factory/zip-factory/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 Yani Iliev
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/zip-factory/zip-factory/lib/ArchiverInterface.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * Archiver interface file
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category Utilities
27
- * @package ZipFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @copyright 2014 Yani Iliev
30
- * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
- * @version GIT: 1.0.4
32
- * @link https://github.com/yani-/zip-factory/
33
- */
34
-
35
- /**
36
- * Archiver Interface
37
- *
38
- * @category Tests
39
- * @package ZipFactory
40
- * @author Yani Iliev <yani@iliev.me>
41
- * @copyright 2014 Yani Iliev
42
- * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
43
- * @link https://github.com/yani-/zip-factory/
44
- */
45
- interface ArchiverInterface
46
- {
47
- /**
48
- * Create instance of Zip or Pcl archiver
49
- *
50
- * @param string $file Path to file
51
- * @param boolean $write Open archive for write
52
- *
53
- * @return void
54
- */
55
- public function __construct($file, $write = false);
56
-
57
- /**
58
- * [addFile description]
59
- *
60
- * @param [type] $filepath [description]
61
- * @param [type] $entryname [description]
62
- * @param [type] $start [description]
63
- * @param [type] $length [description]
64
- *
65
- * @return null [description]
66
- */
67
- public function addFile(
68
- $filepath,
69
- $entryname = null,
70
- $start = null,
71
- $length = null
72
- );
73
-
74
- /**
75
- * [addDir description]
76
- *
77
- * @param [type] $path [description]
78
- * @param [type] $parent_dir [description]
79
- * @param array $include [description]
80
- *
81
- * @return null [description]
82
- */
83
- public function addDir($path, $parent_dir = null, $include = array());
84
-
85
- /**
86
- * [addFromString description]
87
- *
88
- * @param [type] $name [description]
89
- * @param [type] $content [description]
90
- *
91
- * @return null [description]
92
- */
93
- public function addFromString($name, $content);
94
-
95
- /**
96
- * [getArchive description]
97
- *
98
- * @return [type] [description]
99
- */
100
- public function getArchive();
101
-
102
- /**
103
- * [extractTo description]
104
- *
105
- * @param string $pathto Path to extract to
106
- * @param mixed $files Optional files parameter
107
- *
108
- * @return [type] [description]
109
- */
110
- public function extractTo($pathto, $files = null);
111
-
112
- /**
113
- * [close description]
114
- *
115
- * @return [type] [description]
116
- */
117
- public function close();
118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/zip-factory/zip-factory/lib/ArchiverPclZip.php DELETED
@@ -1,218 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * ArchiverPclZip class file
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category Utilities
27
- * @package ZipFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @copyright 2014 Yani Iliev
30
- * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
- * @version GIT: 1.2.0
32
- * @link https://github.com/yani-/zip-factory/
33
- */
34
-
35
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ArchiverInterface.php';
36
-
37
- if (function_exists('gzopen')) {
38
-
39
- if (!class_exists('PclZip')) {
40
- include_once dirname(__FILE__) .
41
- DIRECTORY_SEPARATOR .
42
- 'vendor' .
43
- DIRECTORY_SEPARATOR .
44
- 'pclzip-2-8-2' .
45
- DIRECTORY_SEPARATOR .
46
- 'pclzip.lib.php';
47
- }
48
-
49
- /**
50
- * ArchiverPclZip class
51
- *
52
- * @category Tests
53
- * @package ZipFactory
54
- * @author Yani Iliev <yani@iliev.me>
55
- * @copyright 2014 Yani Iliev
56
- * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
57
- * @link https://github.com/yani-/zip-factory/
58
- */
59
- class ArchiverPclZip implements ArchiverInterface
60
- {
61
- /**
62
- * [$archive description]
63
- * @var [type]
64
- */
65
- protected $archive = null;
66
-
67
- /**
68
- * [$archive description]
69
- * @var [type]
70
- */
71
- protected $pclzip = null;
72
-
73
- /**
74
- * Create instance of Pcl archiver
75
- *
76
- * @param string $file Path to file
77
- * @param boolean $write Open archive for write
78
- *
79
- * @return void
80
- */
81
- public function __construct($file, $write = false)
82
- {
83
- if (is_resource($file)) {
84
- $meta = stream_get_meta_data($file);
85
- $this->archive = $meta['uri'];
86
- $this->pclzip = new PclZip($this->archive);
87
- } else {
88
- $this->archive = $file;
89
- $this->pclzip = new PclZip($this->archive);
90
- }
91
- }
92
-
93
- /**
94
- * [addFile description]
95
- *
96
- * @param [type] $filepath [description]
97
- * @param [type] $entryname [description]
98
- * @param [type] $start [description]
99
- * @param [type] $length [description]
100
- *
101
- * @return null
102
- */
103
- public function addFile(
104
- $filepath,
105
- $entryname = null,
106
- $start = null,
107
- $length = null
108
- ) {
109
- if (is_resource($filepath)) {
110
- $meta = stream_get_meta_data($filepath);
111
- $filepath = $meta['uri'];
112
- }
113
- $this->pclzip->add(
114
- array(
115
- array(
116
- PCLZIP_ATT_FILE_NAME => $filepath,
117
- PCLZIP_ATT_FILE_NEW_FULL_NAME => $entryname
118
- )
119
- )
120
- );
121
- }
122
-
123
- /**
124
- * Add directory to archive
125
- *
126
- * @param string $path Path to directory
127
- * @param string $parent_dir Parent path name
128
- * @param array $include Include specific directories
129
- *
130
- * @return void
131
- */
132
- public function addDir($path, $parent_dir = null, $include = array())
133
- {
134
- // Prepare filter pattern
135
- $filter_pattern = null;
136
- if (is_array($include)) {
137
- $filters = array();
138
- foreach ($include as $filter) {
139
- $filters[] = $path . DIRECTORY_SEPARATOR . $filter;
140
- }
141
-
142
- $filter_pattern = implode(',', $filters);
143
- }
144
-
145
- // Validate filter pattern
146
- if ($filter_pattern) {
147
- $this->pclzip->add(
148
- $filter_pattern,
149
- PCLZIP_OPT_REMOVE_PATH,
150
- $path,
151
- PCLZIP_OPT_ADD_PATH,
152
- $parent_dir
153
- );
154
- } else {
155
- $this->pclzip->add(
156
- $path,
157
- PCLZIP_OPT_REMOVE_PATH,
158
- $path,
159
- PCLZIP_OPT_ADD_PATH,
160
- $parent_dir
161
- );
162
- }
163
- }
164
-
165
- /**
166
- * [addFromString description]
167
- *
168
- * @param [type] $name [description]
169
- * @param [type] $content [description]
170
- *
171
- * @return null [description]
172
- */
173
- public function addFromString($name, $content)
174
- {
175
- $this->pclzip->add(
176
- array(
177
- array(
178
- PCLZIP_ATT_FILE_NAME => $name,
179
- PCLZIP_ATT_FILE_CONTENT => $content
180
- )
181
- )
182
- );
183
- }
184
-
185
- /**
186
- * [getArchive description]
187
- *
188
- * @return [type] [description]
189
- */
190
- public function getArchive()
191
- {
192
- return $this->archive;
193
- }
194
-
195
- /**
196
- * [extractTo description]
197
- *
198
- * @param string $pathto Path to extract to
199
- * @param mixed $files Optional files parameter
200
- *
201
- * @return [type] [description]
202
- */
203
- public function extractTo($pathto, $files = null)
204
- {
205
- $this->pclzip->extract(PCLZIP_OPT_PATH, $pathto);
206
- }
207
-
208
- /**
209
- * [close description]
210
- *
211
- * @return [type] [description]
212
- */
213
- public function close()
214
- {
215
- // empty function - not needed for pclzip
216
- }
217
- }
218
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/zip-factory/zip-factory/lib/ArchiverZipArchive.php DELETED
@@ -1,223 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * ArchiverZipArchive class file
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category Utilities
27
- * @package ZipFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @copyright 2014 Yani Iliev
30
- * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
- * @version GIT: 1.2.0
32
- * @link https://github.com/yani-/zip-factory/
33
- */
34
-
35
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ArchiverInterface.php';
36
-
37
- if (class_exists('ZipArchive')) {
38
- /**
39
- * ArchiverZipArchive class
40
- *
41
- * @category Tests
42
- * @package ZipFactory
43
- * @author Yani Iliev <yani@iliev.me>
44
- * @copyright 2014 Yani Iliev
45
- * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
46
- * @link https://github.com/yani-/zip-factory/
47
- */
48
- class ArchiverZipArchive extends ZipArchive implements ArchiverInterface
49
- {
50
- /**
51
- * [$archive description]
52
- * @var [type]
53
- */
54
- protected $archive = null;
55
-
56
- /**
57
- * [$root_dir description]
58
- * @var [type]
59
- */
60
- protected $root_dir = null;
61
-
62
- /**
63
- * Create instance of Zip archiver
64
- *
65
- * @param string $file Path to file
66
- * @param boolean $write Open archive for write
67
- *
68
- * @return void
69
- */
70
- public function __construct($file, $write = false)
71
- {
72
- if (is_resource($file)) {
73
- $meta = stream_get_meta_data($file);
74
- $this->archive = $meta['uri'];
75
- } else {
76
- $this->archive = $file;
77
- }
78
-
79
- // Open Archive File for read/write
80
- if ($write) {
81
- if (($code = $this->open($this->archive, ZipArchive::CREATE | ZipArchive::OVERWRITE)) !== true) {
82
- throw new Exception('Archive file cound not be created. Return code: ' . $code);
83
- }
84
- } else {
85
- if (($code = $this->open($this->archive)) !== true) {
86
- throw new Exception('Archive file cound not be opened. Return code: ' . $code);
87
- }
88
- }
89
- }
90
-
91
- /**
92
- * [addFile description]
93
- *
94
- * @param [type] $filepath [description]
95
- * @param [type] $entryname [description]
96
- * @param [type] $start [description]
97
- * @param [type] $length [description]
98
- *
99
- * @return null [description]
100
- */
101
- public function addFile(
102
- $filepath,
103
- $entryname = null,
104
- $start = null,
105
- $length = null
106
- ) {
107
- if (is_resource($filepath)) {
108
- $meta = stream_get_meta_data($filepath);
109
- $filepath = $meta['uri'];
110
- }
111
- parent::addFile($filepath, $entryname, $start, $length);
112
- }
113
-
114
- /**
115
- * Add directory to archive
116
- *
117
- * @param string $path Path to directory
118
- * @param string $parent_dir Parent path name
119
- * @param array $include Include specific directories
120
- *
121
- * @return void
122
- */
123
- public function addDir($path, $parent_dir = null, $include = array())
124
- {
125
- // Use Recursive functions
126
- $iterator = new RecursiveIteratorIterator(
127
- new RecursiveDirectoryIterator($path),
128
- RecursiveIteratorIterator::SELF_FIRST
129
- );
130
-
131
- // Prepare filter pattern
132
- $filter_pattern = null;
133
- if (is_array($include)) {
134
- $filters = array();
135
- foreach ($include as $filter) {
136
- $filters[] = sprintf(
137
- '(%s(%s.*)?)',
138
- preg_quote( $filter, '/' ),
139
- preg_quote( DIRECTORY_SEPARATOR, '/' )
140
- );
141
- }
142
-
143
- $filter_pattern = implode( '|', $filters );
144
- }
145
-
146
- foreach ($iterator as $item) {
147
- // Skip dots
148
- if ($iterator->isDot()) {
149
- continue;
150
- }
151
-
152
- // Validate filter pattern
153
- if ($filter_pattern) {
154
- if (!preg_match('/^' . $filter_pattern . '$/', $iterator->getSubPathName())) {
155
- continue;
156
- }
157
- }
158
-
159
- // Add to archive
160
- if ($item->isDir()) {
161
- $this->addEmptyDir(
162
- $parent_dir .
163
- DIRECTORY_SEPARATOR .
164
- $iterator->getSubPathName()
165
- );
166
- } else {
167
- $this->addFile(
168
- $item->getPathname(),
169
- $parent_dir .
170
- DIRECTORY_SEPARATOR .
171
- $iterator->getSubPathName()
172
- );
173
- }
174
- }
175
- }
176
-
177
- /**
178
- * [addFromString description]
179
- *
180
- * @param [type] $name [description]
181
- * @param [type] $content [description]
182
- *
183
- * @return null [description]
184
- */
185
- public function addFromString($name, $content)
186
- {
187
- parent::addFromString($name, $content);
188
- }
189
-
190
- /**
191
- * [getArchive description]
192
- *
193
- * @return [type] [description]
194
- */
195
- public function getArchive()
196
- {
197
- return $this->archive;
198
- }
199
-
200
- /**
201
- * [extractTo description]
202
- *
203
- * @param string $pathto Path to extract to
204
- * @param mixed $files Optional files parameter
205
- *
206
- * @return [type] [description]
207
- */
208
- public function extractTo($pathto, $files = null)
209
- {
210
- parent::extractTo($pathto);
211
- }
212
-
213
- /**
214
- * [close description]
215
- *
216
- * @return [type] [description]
217
- */
218
- public function close()
219
- {
220
- parent::close();
221
- }
222
- }
223
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/zip-factory/zip-factory/lib/ZipFactory.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * Zip Factory main file
6
- *
7
- * PHP version 5
8
- *
9
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
10
- * a copy of this software and associated documentation files (the "Software"), to
11
- * deal in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- * of the Software, and to permit persons to whom the Software is furnished to do so,
14
- * subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- *
26
- * @category Utilities
27
- * @package ZipFactory
28
- * @author Yani Iliev <yani@iliev.me>
29
- * @copyright 2014 Yani Iliev
30
- * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
31
- * @version GIT: 1.2.0
32
- * @link https://github.com/yani-/zip-factory/
33
- */
34
-
35
- /**
36
- * ZipFactory class
37
- *
38
- * @category Tests
39
- * @package ZipFactory
40
- * @author Yani Iliev <yani@iliev.me>
41
- * @copyright 2014 Yani Iliev
42
- * @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
43
- * @link https://github.com/yani-/zip-factory/
44
- */
45
- class ZipFactory
46
- {
47
- /**
48
- * Create instance of Zip or Pcl archiver
49
- *
50
- * @param string $file Path to file
51
- * @param boolean $pclZip Use Pcl archiver library
52
- * @param boolean $write Open archive for write
53
- *
54
- * @return mixed
55
- */
56
- public static function makeZipArchiver($file, $pclZip = false, $write = false)
57
- {
58
- if ($pclZip) {
59
- include_once dirname(__FILE__) .
60
- DIRECTORY_SEPARATOR .
61
- 'ArchiverPclZip.php';
62
- return new ArchiverPclZip($file, $write);
63
- } else {
64
- include_once dirname(__FILE__) .
65
- DIRECTORY_SEPARATOR .
66
- 'ArchiverZipArchive.php';
67
- return new ArchiverZipArchive($file, $write);
68
- }
69
- }
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/gnu-lgpl.txt DELETED
@@ -1,504 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 2.1, February 1999
3
-
4
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6
- Everyone is permitted to copy and distribute verbatim copies
7
- of this license document, but changing it is not allowed.
8
-
9
- [This is the first released version of the Lesser GPL. It also counts
10
- as the successor of the GNU Library Public License, version 2, hence
11
- the version number 2.1.]
12
-
13
- Preamble
14
-
15
- The licenses for most software are designed to take away your
16
- freedom to share and change it. By contrast, the GNU General Public
17
- Licenses are intended to guarantee your freedom to share and change
18
- free software--to make sure the software is free for all its users.
19
-
20
- This license, the Lesser General Public License, applies to some
21
- specially designated software packages--typically libraries--of the
22
- Free Software Foundation and other authors who decide to use it. You
23
- can use it too, but we suggest you first think carefully about whether
24
- this license or the ordinary General Public License is the better
25
- strategy to use in any particular case, based on the explanations below.
26
-
27
- When we speak of free software, we are referring to freedom of use,
28
- not price. Our General Public Licenses are designed to make sure that
29
- you have the freedom to distribute copies of free software (and charge
30
- for this service if you wish); that you receive source code or can get
31
- it if you want it; that you can change the software and use pieces of
32
- it in new free programs; and that you are informed that you can do
33
- these things.
34
-
35
- To protect your rights, we need to make restrictions that forbid
36
- distributors to deny you these rights or to ask you to surrender these
37
- rights. These restrictions translate to certain responsibilities for
38
- you if you distribute copies of the library or if you modify it.
39
-
40
- For example, if you distribute copies of the library, whether gratis
41
- or for a fee, you must give the recipients all the rights that we gave
42
- you. You must make sure that they, too, receive or can get the source
43
- code. If you link other code with the library, you must provide
44
- complete object files to the recipients, so that they can relink them
45
- with the library after making changes to the library and recompiling
46
- it. And you must show them these terms so they know their rights.
47
-
48
- We protect your rights with a two-step method: (1) we copyright the
49
- library, and (2) we offer you this license, which gives you legal
50
- permission to copy, distribute and/or modify the library.
51
-
52
- To protect each distributor, we want to make it very clear that
53
- there is no warranty for the free library. Also, if the library is
54
- modified by someone else and passed on, the recipients should know
55
- that what they have is not the original version, so that the original
56
- author's reputation will not be affected by problems that might be
57
- introduced by others.
58
-
59
- Finally, software patents pose a constant threat to the existence of
60
- any free program. We wish to make sure that a company cannot
61
- effectively restrict the users of a free program by obtaining a
62
- restrictive license from a patent holder. Therefore, we insist that
63
- any patent license obtained for a version of the library must be
64
- consistent with the full freedom of use specified in this license.
65
-
66
- Most GNU software, including some libraries, is covered by the
67
- ordinary GNU General Public License. This license, the GNU Lesser
68
- General Public License, applies to certain designated libraries, and
69
- is quite different from the ordinary General Public License. We use
70
- this license for certain libraries in order to permit linking those
71
- libraries into non-free programs.
72
-
73
- When a program is linked with a library, whether statically or using
74
- a shared library, the combination of the two is legally speaking a
75
- combined work, a derivative of the original library. The ordinary
76
- General Public License therefore permits such linking only if the
77
- entire combination fits its criteria of freedom. The Lesser General
78
- Public License permits more lax criteria for linking other code with
79
- the library.
80
-
81
- We call this license the "Lesser" General Public License because it
82
- does Less to protect the user's freedom than the ordinary General
83
- Public License. It also provides other free software developers Less
84
- of an advantage over competing non-free programs. These disadvantages
85
- are the reason we use the ordinary General Public License for many
86
- libraries. However, the Lesser license provides advantages in certain
87
- special circumstances.
88
-
89
- For example, on rare occasions, there may be a special need to
90
- encourage the widest possible use of a certain library, so that it becomes
91
- a de-facto standard. To achieve this, non-free programs must be
92
- allowed to use the library. A more frequent case is that a free
93
- library does the same job as widely used non-free libraries. In this
94
- case, there is little to gain by limiting the free library to free
95
- software only, so we use the Lesser General Public License.
96
-
97
- In other cases, permission to use a particular library in non-free
98
- programs enables a greater number of people to use a large body of
99
- free software. For example, permission to use the GNU C Library in
100
- non-free programs enables many more people to use the whole GNU
101
- operating system, as well as its variant, the GNU/Linux operating
102
- system.
103
-
104
- Although the Lesser General Public License is Less protective of the
105
- users' freedom, it does ensure that the user of a program that is
106
- linked with the Library has the freedom and the wherewithal to run
107
- that program using a modified version of the Library.
108
-
109
- The precise terms and conditions for copying, distribution and
110
- modification follow. Pay close attention to the difference between a
111
- "work based on the library" and a "work that uses the library". The
112
- former contains code derived from the library, whereas the latter must
113
- be combined with the library in order to run.
114
-
115
- GNU LESSER GENERAL PUBLIC LICENSE
116
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
-
118
- 0. This License Agreement applies to any software library or other
119
- program which contains a notice placed by the copyright holder or
120
- other authorized party saying it may be distributed under the terms of
121
- this Lesser General Public License (also called "this License").
122
- Each licensee is addressed as "you".
123
-
124
- A "library" means a collection of software functions and/or data
125
- prepared so as to be conveniently linked with application programs
126
- (which use some of those functions and data) to form executables.
127
-
128
- The "Library", below, refers to any such software library or work
129
- which has been distributed under these terms. A "work based on the
130
- Library" means either the Library or any derivative work under
131
- copyright law: that is to say, a work containing the Library or a
132
- portion of it, either verbatim or with modifications and/or translated
133
- straightforwardly into another language. (Hereinafter, translation is
134
- included without limitation in the term "modification".)
135
-
136
- "Source code" for a work means the preferred form of the work for
137
- making modifications to it. For a library, complete source code means
138
- all the source code for all modules it contains, plus any associated
139
- interface definition files, plus the scripts used to control compilation
140
- and installation of the library.
141
-
142
- Activities other than copying, distribution and modification are not
143
- covered by this License; they are outside its scope. The act of
144
- running a program using the Library is not restricted, and output from
145
- such a program is covered only if its contents constitute a work based
146
- on the Library (independent of the use of the Library in a tool for
147
- writing it). Whether that is true depends on what the Library does
148
- and what the program that uses the Library does.
149
-
150
- 1. You may copy and distribute verbatim copies of the Library's
151
- complete source code as you receive it, in any medium, provided that
152
- you conspicuously and appropriately publish on each copy an
153
- appropriate copyright notice and disclaimer of warranty; keep intact
154
- all the notices that refer to this License and to the absence of any
155
- warranty; and distribute a copy of this License along with the
156
- Library.
157
-
158
- You may charge a fee for the physical act of transferring a copy,
159
- and you may at your option offer warranty protection in exchange for a
160
- fee.
161
-
162
- 2. You may modify your copy or copies of the Library or any portion
163
- of it, thus forming a work based on the Library, and copy and
164
- distribute such modifications or work under the terms of Section 1
165
- above, provided that you also meet all of these conditions:
166
-
167
- a) The modified work must itself be a software library.
168
-
169
- b) You must cause the files modified to carry prominent notices
170
- stating that you changed the files and the date of any change.
171
-
172
- c) You must cause the whole of the work to be licensed at no
173
- charge to all third parties under the terms of this License.
174
-
175
- d) If a facility in the modified Library refers to a function or a
176
- table of data to be supplied by an application program that uses
177
- the facility, other than as an argument passed when the facility
178
- is invoked, then you must make a good faith effort to ensure that,
179
- in the event an application does not supply such function or
180
- table, the facility still operates, and performs whatever part of
181
- its purpose remains meaningful.
182
-
183
- (For example, a function in a library to compute square roots has
184
- a purpose that is entirely well-defined independent of the
185
- application. Therefore, Subsection 2d requires that any
186
- application-supplied function or table used by this function must
187
- be optional: if the application does not supply it, the square
188
- root function must still compute square roots.)
189
-
190
- These requirements apply to the modified work as a whole. If
191
- identifiable sections of that work are not derived from the Library,
192
- and can be reasonably considered independent and separate works in
193
- themselves, then this License, and its terms, do not apply to those
194
- sections when you distribute them as separate works. But when you
195
- distribute the same sections as part of a whole which is a work based
196
- on the Library, the distribution of the whole must be on the terms of
197
- this License, whose permissions for other licensees extend to the
198
- entire whole, and thus to each and every part regardless of who wrote
199
- it.
200
-
201
- Thus, it is not the intent of this section to claim rights or contest
202
- your rights to work written entirely by you; rather, the intent is to
203
- exercise the right to control the distribution of derivative or
204
- collective works based on the Library.
205
-
206
- In addition, mere aggregation of another work not based on the Library
207
- with the Library (or with a work based on the Library) on a volume of
208
- a storage or distribution medium does not bring the other work under
209
- the scope of this License.
210
-
211
- 3. You may opt to apply the terms of the ordinary GNU General Public
212
- License instead of this License to a given copy of the Library. To do
213
- this, you must alter all the notices that refer to this License, so
214
- that they refer to the ordinary GNU General Public License, version 2,
215
- instead of to this License. (If a newer version than version 2 of the
216
- ordinary GNU General Public License has appeared, then you can specify
217
- that version instead if you wish.) Do not make any other change in
218
- these notices.
219
-
220
- Once this change is made in a given copy, it is irreversible for
221
- that copy, so the ordinary GNU General Public License applies to all
222
- subsequent copies and derivative works made from that copy.
223
-
224
- This option is useful when you wish to copy part of the code of
225
- the Library into a program that is not a library.
226
-
227
- 4. You may copy and distribute the Library (or a portion or
228
- derivative of it, under Section 2) in object code or executable form
229
- under the terms of Sections 1 and 2 above provided that you accompany
230
- it with the complete corresponding machine-readable source code, which
231
- must be distributed under the terms of Sections 1 and 2 above on a
232
- medium customarily used for software interchange.
233
-
234
- If distribution of object code is made by offering access to copy
235
- from a designated place, then offering equivalent access to copy the
236
- source code from the same place satisfies the requirement to
237
- distribute the source code, even though third parties are not
238
- compelled to copy the source along with the object code.
239
-
240
- 5. A program that contains no derivative of any portion of the
241
- Library, but is designed to work with the Library by being compiled or
242
- linked with it, is called a "work that uses the Library". Such a
243
- work, in isolation, is not a derivative work of the Library, and
244
- therefore falls outside the scope of this License.
245
-
246
- However, linking a "work that uses the Library" with the Library
247
- creates an executable that is a derivative of the Library (because it
248
- contains portions of the Library), rather than a "work that uses the
249
- library". The executable is therefore covered by this License.
250
- Section 6 states terms for distribution of such executables.
251
-
252
- When a "work that uses the Library" uses material from a header file
253
- that is part of the Library, the object code for the work may be a
254
- derivative work of the Library even though the source code is not.
255
- Whether this is true is especially significant if the work can be
256
- linked without the Library, or if the work is itself a library. The
257
- threshold for this to be true is not precisely defined by law.
258
-
259
- If such an object file uses only numerical parameters, data
260
- structure layouts and accessors, and small macros and small inline
261
- functions (ten lines or less in length), then the use of the object
262
- file is unrestricted, regardless of whether it is legally a derivative
263
- work. (Executables containing this object code plus portions of the
264
- Library will still fall under Section 6.)
265
-
266
- Otherwise, if the work is a derivative of the Library, you may
267
- distribute the object code for the work under the terms of Section 6.
268
- Any executables containing that work also fall under Section 6,
269
- whether or not they are linked directly with the Library itself.
270
-
271
- 6. As an exception to the Sections above, you may also combine or
272
- link a "work that uses the Library" with the Library to produce a
273
- work containing portions of the Library, and distribute that work
274
- under terms of your choice, provided that the terms permit
275
- modification of the work for the customer's own use and reverse
276
- engineering for debugging such modifications.
277
-
278
- You must give prominent notice with each copy of the work that the
279
- Library is used in it and that the Library and its use are covered by
280
- this License. You must supply a copy of this License. If the work
281
- during execution displays copyright notices, you must include the
282
- copyright notice for the Library among them, as well as a reference
283
- directing the user to the copy of this License. Also, you must do one
284
- of these things:
285
-
286
- a) Accompany the work with the complete corresponding
287
- machine-readable source code for the Library including whatever
288
- changes were used in the work (which must be distributed under
289
- Sections 1 and 2 above); and, if the work is an executable linked
290
- with the Library, with the complete machine-readable "work that
291
- uses the Library", as object code and/or source code, so that the
292
- user can modify the Library and then relink to produce a modified
293
- executable containing the modified Library. (It is understood
294
- that the user who changes the contents of definitions files in the
295
- Library will not necessarily be able to recompile the application
296
- to use the modified definitions.)
297
-
298
- b) Use a suitable shared library mechanism for linking with the
299
- Library. A suitable mechanism is one that (1) uses at run time a
300
- copy of the library already present on the user's computer system,
301
- rather than copying library functions into the executable, and (2)
302
- will operate properly with a modified version of the library, if
303
- the user installs one, as long as the modified version is
304
- interface-compatible with the version that the work was made with.
305
-
306
- c) Accompany the work with a written offer, valid for at
307
- least three years, to give the same user the materials
308
- specified in Subsection 6a, above, for a charge no more
309
- than the cost of performing this distribution.
310
-
311
- d) If distribution of the work is made by offering access to copy
312
- from a designated place, offer equivalent access to copy the above
313
- specified materials from the same place.
314
-
315
- e) Verify that the user has already received a copy of these
316
- materials or that you have already sent this user a copy.
317
-
318
- For an executable, the required form of the "work that uses the
319
- Library" must include any data and utility programs needed for
320
- reproducing the executable from it. However, as a special exception,
321
- the materials to be distributed need not include anything that is
322
- normally distributed (in either source or binary form) with the major
323
- components (compiler, kernel, and so on) of the operating system on
324
- which the executable runs, unless that component itself accompanies
325
- the executable.
326
-
327
- It may happen that this requirement contradicts the license
328
- restrictions of other proprietary libraries that do not normally
329
- accompany the operating system. Such a contradiction means you cannot
330
- use both them and the Library together in an executable that you
331
- distribute.
332
-
333
- 7. You may place library facilities that are a work based on the
334
- Library side-by-side in a single library together with other library
335
- facilities not covered by this License, and distribute such a combined
336
- library, provided that the separate distribution of the work based on
337
- the Library and of the other library facilities is otherwise
338
- permitted, and provided that you do these two things:
339
-
340
- a) Accompany the combined library with a copy of the same work
341
- based on the Library, uncombined with any other library
342
- facilities. This must be distributed under the terms of the
343
- Sections above.
344
-
345
- b) Give prominent notice with the combined library of the fact
346
- that part of it is a work based on the Library, and explaining
347
- where to find the accompanying uncombined form of the same work.
348
-
349
- 8. You may not copy, modify, sublicense, link with, or distribute
350
- the Library except as expressly provided under this License. Any
351
- attempt otherwise to copy, modify, sublicense, link with, or
352
- distribute the Library is void, and will automatically terminate your
353
- rights under this License. However, parties who have received copies,
354
- or rights, from you under this License will not have their licenses
355
- terminated so long as such parties remain in full compliance.
356
-
357
- 9. You are not required to accept this License, since you have not
358
- signed it. However, nothing else grants you permission to modify or
359
- distribute the Library or its derivative works. These actions are
360
- prohibited by law if you do not accept this License. Therefore, by
361
- modifying or distributing the Library (or any work based on the
362
- Library), you indicate your acceptance of this License to do so, and
363
- all its terms and conditions for copying, distributing or modifying
364
- the Library or works based on it.
365
-
366
- 10. Each time you redistribute the Library (or any work based on the
367
- Library), the recipient automatically receives a license from the
368
- original licensor to copy, distribute, link with or modify the Library
369
- subject to these terms and conditions. You may not impose any further
370
- restrictions on the recipients' exercise of the rights granted herein.
371
- You are not responsible for enforcing compliance by third parties with
372
- this License.
373
-
374
- 11. If, as a consequence of a court judgment or allegation of patent
375
- infringement or for any other reason (not limited to patent issues),
376
- conditions are imposed on you (whether by court order, agreement or
377
- otherwise) that contradict the conditions of this License, they do not
378
- excuse you from the conditions of this License. If you cannot
379
- distribute so as to satisfy simultaneously your obligations under this
380
- License and any other pertinent obligations, then as a consequence you
381
- may not distribute the Library at all. For example, if a patent
382
- license would not permit royalty-free redistribution of the Library by
383
- all those who receive copies directly or indirectly through you, then
384
- the only way you could satisfy both it and this License would be to
385
- refrain entirely from distribution of the Library.
386
-
387
- If any portion of this section is held invalid or unenforceable under any
388
- particular circumstance, the balance of the section is intended to apply,
389
- and the section as a whole is intended to apply in other circumstances.
390
-
391
- It is not the purpose of this section to induce you to infringe any
392
- patents or other property right claims or to contest validity of any
393
- such claims; this section has the sole purpose of protecting the
394
- integrity of the free software distribution system which is
395
- implemented by public license practices. Many people have made
396
- generous contributions to the wide range of software distributed
397
- through that system in reliance on consistent application of that
398
- system; it is up to the author/donor to decide if he or she is willing
399
- to distribute software through any other system and a licensee cannot
400
- impose that choice.
401
-
402
- This section is intended to make thoroughly clear what is believed to
403
- be a consequence of the rest of this License.
404
-
405
- 12. If the distribution and/or use of the Library is restricted in
406
- certain countries either by patents or by copyrighted interfaces, the
407
- original copyright holder who places the Library under this License may add
408
- an explicit geographical distribution limitation excluding those countries,
409
- so that distribution is permitted only in or among countries not thus
410
- excluded. In such case, this License incorporates the limitation as if
411
- written in the body of this License.
412
-
413
- 13. The Free Software Foundation may publish revised and/or new
414
- versions of the Lesser General Public License from time to time.
415
- Such new versions will be similar in spirit to the present version,
416
- but may differ in detail to address new problems or concerns.
417
-
418
- Each version is given a distinguishing version number. If the Library
419
- specifies a version number of this License which applies to it and
420
- "any later version", you have the option of following the terms and
421
- conditions either of that version or of any later version published by
422
- the Free Software Foundation. If the Library does not specify a
423
- license version number, you may choose any version ever published by
424
- the Free Software Foundation.
425
-
426
- 14. If you wish to incorporate parts of the Library into other free
427
- programs whose distribution conditions are incompatible with these,
428
- write to the author to ask for permission. For software which is
429
- copyrighted by the Free Software Foundation, write to the Free
430
- Software Foundation; we sometimes make exceptions for this. Our
431
- decision will be guided by the two goals of preserving the free status
432
- of all derivatives of our free software and of promoting the sharing
433
- and reuse of software generally.
434
-
435
- NO WARRANTY
436
-
437
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438
- WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439
- EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440
- OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441
- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444
- LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445
- THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
-
447
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448
- WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449
- AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450
- FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451
- CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452
- LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453
- RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454
- FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455
- SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456
- DAMAGES.
457
-
458
- END OF TERMS AND CONDITIONS
459
-
460
- How to Apply These Terms to Your New Libraries
461
-
462
- If you develop a new library, and you want it to be of the greatest
463
- possible use to the public, we recommend making it free software that
464
- everyone can redistribute and change. You can do so by permitting
465
- redistribution under these terms (or, alternatively, under the terms of the
466
- ordinary General Public License).
467
-
468
- To apply these terms, attach the following notices to the library. It is
469
- safest to attach them to the start of each source file to most effectively
470
- convey the exclusion of warranty; and each file should have at least the
471
- "copyright" line and a pointer to where the full notice is found.
472
-
473
- <one line to give the library's name and a brief idea of what it does.>
474
- Copyright (C) <year> <name of author>
475
-
476
- This library is free software; you can redistribute it and/or
477
- modify it under the terms of the GNU Lesser General Public
478
- License as published by the Free Software Foundation; either
479
- version 2.1 of the License, or (at your option) any later version.
480
-
481
- This library is distributed in the hope that it will be useful,
482
- but WITHOUT ANY WARRANTY; without even the implied warranty of
483
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484
- Lesser General Public License for more details.
485
-
486
- You should have received a copy of the GNU Lesser General Public
487
- License along with this library; if not, write to the Free Software
488
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
489
-
490
- Also add information on how to contact you by electronic and paper mail.
491
-
492
- You should also get your employer (if you work as a programmer) or your
493
- school, if any, to sign a "copyright disclaimer" for the library, if
494
- necessary. Here is a sample; alter the names:
495
-
496
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
497
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498
-
499
- <signature of Ty Coon>, 1 April 1990
500
- Ty Coon, President of Vice
501
-
502
- That's all there is to it!
503
-
504
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/pclzip.lib.php DELETED
@@ -1,5690 +0,0 @@
1
- <?php
2
- // --------------------------------------------------------------------------------
3
- // PhpConcept Library - Zip Module 2.8.2
4
- // --------------------------------------------------------------------------------
5
- // License GNU/LGPL - Vincent Blavet - August 2009
6
- // http://www.phpconcept.net
7
- // --------------------------------------------------------------------------------
8
- //
9
- // Presentation :
10
- // PclZip is a PHP library that manage ZIP archives.
11
- // So far tests show that archives generated by PclZip are readable by
12
- // WinZip application and other tools.
13
- //
14
- // Description :
15
- // See readme.txt and http://www.phpconcept.net
16
- //
17
- // Warning :
18
- // This library and the associated files are non commercial, non professional
19
- // work.
20
- // It should not have unexpected results. However if any damage is caused by
21
- // this software the author can not be responsible.
22
- // The use of this software is at the risk of the user.
23
- //
24
- // --------------------------------------------------------------------------------
25
- // $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
26
- // --------------------------------------------------------------------------------
27
-
28
- // ----- Constants
29
- if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
30
- define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
31
- }
32
-
33
- // ----- File list separator
34
- // In version 1.x of PclZip, the separator for file list is a space
35
- // (which is not a very smart choice, specifically for windows paths !).
36
- // A better separator should be a comma (,). This constant gives you the
37
- // abilty to change that.
38
- // However notice that changing this value, may have impact on existing
39
- // scripts, using space separated filenames.
40
- // Recommanded values for compatibility with older versions :
41
- //define( 'PCLZIP_SEPARATOR', ' ' );
42
- // Recommanded values for smart separation of filenames.
43
- if (!defined('PCLZIP_SEPARATOR')) {
44
- define( 'PCLZIP_SEPARATOR', ',' );
45
- }
46
-
47
- // ----- Error configuration
48
- // 0 : PclZip Class integrated error handling
49
- // 1 : PclError external library error handling. By enabling this
50
- // you must ensure that you have included PclError library.
51
- // [2,...] : reserved for futur use
52
- if (!defined('PCLZIP_ERROR_EXTERNAL')) {
53
- define( 'PCLZIP_ERROR_EXTERNAL', 0 );
54
- }
55
-
56
- // ----- Optional static temporary directory
57
- // By default temporary files are generated in the script current
58
- // path.
59
- // If defined :
60
- // - MUST BE terminated by a '/'.
61
- // - MUST be a valid, already created directory
62
- // Samples :
63
- // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
64
- // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
65
- if (!defined('PCLZIP_TEMPORARY_DIR')) {
66
- define( 'PCLZIP_TEMPORARY_DIR', '' );
67
- }
68
-
69
- // ----- Optional threshold ratio for use of temporary files
70
- // Pclzip sense the size of the file to add/extract and decide to
71
- // use or not temporary file. The algorythm is looking for
72
- // memory_limit of PHP and apply a ratio.
73
- // threshold = memory_limit * ratio.
74
- // Recommended values are under 0.5. Default 0.47.
75
- // Samples :
76
- // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
77
- if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
78
- define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
79
- }
80
-
81
- // --------------------------------------------------------------------------------
82
- // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
83
- // --------------------------------------------------------------------------------
84
-
85
- // ----- Global variables
86
- $g_pclzip_version = "2.8.2";
87
-
88
- // ----- Error codes
89
- // -1 : Unable to open file in binary write mode
90
- // -2 : Unable to open file in binary read mode
91
- // -3 : Invalid parameters
92
- // -4 : File does not exist
93
- // -5 : Filename is too long (max. 255)
94
- // -6 : Not a valid zip file
95
- // -7 : Invalid extracted file size
96
- // -8 : Unable to create directory
97
- // -9 : Invalid archive extension
98
- // -10 : Invalid archive format
99
- // -11 : Unable to delete file (unlink)
100
- // -12 : Unable to rename file (rename)
101
- // -13 : Invalid header checksum
102
- // -14 : Invalid archive size
103
- define( 'PCLZIP_ERR_USER_ABORTED', 2 );
104
- define( 'PCLZIP_ERR_NO_ERROR', 0 );
105
- define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
106
- define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
107
- define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
108
- define( 'PCLZIP_ERR_MISSING_FILE', -4 );
109
- define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
110
- define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
111
- define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
112
- define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
113
- define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
114
- define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
115
- define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
116
- define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
117
- define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
118
- define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
119
- define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
120
- define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
121
- define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
122
- define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
123
- define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
124
- define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
125
- define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
126
-
127
- // ----- Options values
128
- define( 'PCLZIP_OPT_PATH', 77001 );
129
- define( 'PCLZIP_OPT_ADD_PATH', 77002 );
130
- define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
131
- define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
132
- define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
133
- define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
134
- define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
135
- define( 'PCLZIP_OPT_BY_NAME', 77008 );
136
- define( 'PCLZIP_OPT_BY_INDEX', 77009 );
137
- define( 'PCLZIP_OPT_BY_EREG', 77010 );
138
- define( 'PCLZIP_OPT_BY_PREG', 77011 );
139
- define( 'PCLZIP_OPT_COMMENT', 77012 );
140
- define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
141
- define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
142
- define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
143
- define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
144
- define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
145
- // Having big trouble with crypt. Need to multiply 2 long int
146
- // which is not correctly supported by PHP ...
147
- //define( 'PCLZIP_OPT_CRYPT', 77018 );
148
- define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
149
- define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
150
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
151
- define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
152
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
153
- define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
154
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
155
-
156
- // ----- File description attributes
157
- define( 'PCLZIP_ATT_FILE_NAME', 79001 );
158
- define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
159
- define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
160
- define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
161
- define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
162
- define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
163
-
164
- // ----- Call backs values
165
- define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
166
- define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
167
- define( 'PCLZIP_CB_PRE_ADD', 78003 );
168
- define( 'PCLZIP_CB_POST_ADD', 78004 );
169
- /* For futur use
170
- define( 'PCLZIP_CB_PRE_LIST', 78005 );
171
- define( 'PCLZIP_CB_POST_LIST', 78006 );
172
- define( 'PCLZIP_CB_PRE_DELETE', 78007 );
173
- define( 'PCLZIP_CB_POST_DELETE', 78008 );
174
- */
175
-
176
- // --------------------------------------------------------------------------------
177
- // Class : PclZip
178
- // Description :
179
- // PclZip is the class that represent a Zip archive.
180
- // The public methods allow the manipulation of the archive.
181
- // Attributes :
182
- // Attributes must not be accessed directly.
183
- // Methods :
184
- // PclZip() : Object creator
185
- // create() : Creates the Zip archive
186
- // listContent() : List the content of the Zip archive
187
- // extract() : Extract the content of the archive
188
- // properties() : List the properties of the archive
189
- // --------------------------------------------------------------------------------
190
- class PclZip
191
- {
192
- // ----- Filename of the zip file
193
- var $zipname = '';
194
-
195
- // ----- File descriptor of the zip file
196
- var $zip_fd = 0;
197
-
198
- // ----- Internal error handling
199
- var $error_code = 1;
200
- var $error_string = '';
201
-
202
- // ----- Current status of the magic_quotes_runtime
203
- // This value store the php configuration for magic_quotes
204
- // The class can then disable the magic_quotes and reset it after
205
- var $magic_quotes_status;
206
-
207
- // --------------------------------------------------------------------------------
208
- // Function : PclZip()
209
- // Description :
210
- // Creates a PclZip object and set the name of the associated Zip archive
211
- // filename.
212
- // Note that no real action is taken, if the archive does not exist it is not
213
- // created. Use create() for that.
214
- // --------------------------------------------------------------------------------
215
- function PclZip($p_zipname)
216
- {
217
-
218
- // ----- Tests the zlib
219
- if (!function_exists('gzopen'))
220
- {
221
- die('Abort '.basename(__FILE__).' : Missing zlib extensions');
222
- }
223
-
224
- // ----- Set the attributes
225
- $this->zipname = $p_zipname;
226
- $this->zip_fd = 0;
227
- $this->magic_quotes_status = -1;
228
-
229
- // ----- Return
230
- return;
231
- }
232
- // --------------------------------------------------------------------------------
233
-
234
- // --------------------------------------------------------------------------------
235
- // Function :
236
- // create($p_filelist, $p_add_dir="", $p_remove_dir="")
237
- // create($p_filelist, $p_option, $p_option_value, ...)
238
- // Description :
239
- // This method supports two different synopsis. The first one is historical.
240
- // This method creates a Zip Archive. The Zip file is created in the
241
- // filesystem. The files and directories indicated in $p_filelist
242
- // are added in the archive. See the parameters description for the
243
- // supported format of $p_filelist.
244
- // When a directory is in the list, the directory and its content is added
245
- // in the archive.
246
- // In this synopsis, the function takes an optional variable list of
247
- // options. See bellow the supported options.
248
- // Parameters :
249
- // $p_filelist : An array containing file or directory names, or
250
- // a string containing one filename or one directory name, or
251
- // a string containing a list of filenames and/or directory
252
- // names separated by spaces.
253
- // $p_add_dir : A path to add before the real path of the archived file,
254
- // in order to have it memorized in the archive.
255
- // $p_remove_dir : A path to remove from the real path of the file to archive,
256
- // in order to have a shorter path memorized in the archive.
257
- // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
258
- // is removed first, before $p_add_dir is added.
259
- // Options :
260
- // PCLZIP_OPT_ADD_PATH :
261
- // PCLZIP_OPT_REMOVE_PATH :
262
- // PCLZIP_OPT_REMOVE_ALL_PATH :
263
- // PCLZIP_OPT_COMMENT :
264
- // PCLZIP_CB_PRE_ADD :
265
- // PCLZIP_CB_POST_ADD :
266
- // Return Values :
267
- // 0 on failure,
268
- // The list of the added files, with a status of the add action.
269
- // (see PclZip::listContent() for list entry format)
270
- // --------------------------------------------------------------------------------
271
- function create($p_filelist)
272
- {
273
- $v_result=1;
274
-
275
- // ----- Reset the error handler
276
- $this->privErrorReset();
277
-
278
- // ----- Set default values
279
- $v_options = array();
280
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
281
-
282
- // ----- Look for variable options arguments
283
- $v_size = func_num_args();
284
-
285
- // ----- Look for arguments
286
- if ($v_size > 1) {
287
- // ----- Get the arguments
288
- $v_arg_list = func_get_args();
289
-
290
- // ----- Remove from the options list the first argument
291
- array_shift($v_arg_list);
292
- $v_size--;
293
-
294
- // ----- Look for first arg
295
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
296
-
297
- // ----- Parse the options
298
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
299
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
300
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
301
- PCLZIP_OPT_ADD_PATH => 'optional',
302
- PCLZIP_CB_PRE_ADD => 'optional',
303
- PCLZIP_CB_POST_ADD => 'optional',
304
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
305
- PCLZIP_OPT_COMMENT => 'optional',
306
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
307
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
308
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
309
- //, PCLZIP_OPT_CRYPT => 'optional'
310
- ));
311
- if ($v_result != 1) {
312
- return 0;
313
- }
314
- }
315
-
316
- // ----- Look for 2 args
317
- // Here we need to support the first historic synopsis of the
318
- // method.
319
- else {
320
-
321
- // ----- Get the first argument
322
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
323
-
324
- // ----- Look for the optional second argument
325
- if ($v_size == 2) {
326
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
327
- }
328
- else if ($v_size > 2) {
329
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
330
- "Invalid number / type of arguments");
331
- return 0;
332
- }
333
- }
334
- }
335
-
336
- // ----- Look for default option values
337
- $this->privOptionDefaultThreshold($v_options);
338
-
339
- // ----- Init
340
- $v_string_list = array();
341
- $v_att_list = array();
342
- $v_filedescr_list = array();
343
- $p_result_list = array();
344
-
345
- // ----- Look if the $p_filelist is really an array
346
- if (is_array($p_filelist)) {
347
-
348
- // ----- Look if the first element is also an array
349
- // This will mean that this is a file description entry
350
- if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
351
- $v_att_list = $p_filelist;
352
- }
353
-
354
- // ----- The list is a list of string names
355
- else {
356
- $v_string_list = $p_filelist;
357
- }
358
- }
359
-
360
- // ----- Look if the $p_filelist is a string
361
- else if (is_string($p_filelist)) {
362
- // ----- Create a list from the string
363
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
364
- }
365
-
366
- // ----- Invalid variable type for $p_filelist
367
- else {
368
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
369
- return 0;
370
- }
371
-
372
- // ----- Reformat the string list
373
- if (sizeof($v_string_list) != 0) {
374
- foreach ($v_string_list as $v_string) {
375
- if ($v_string != '') {
376
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
377
- }
378
- else {
379
- }
380
- }
381
- }
382
-
383
- // ----- For each file in the list check the attributes
384
- $v_supported_attributes
385
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
386
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
387
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
388
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
389
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
390
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
391
- );
392
- foreach ($v_att_list as $v_entry) {
393
- $v_result = $this->privFileDescrParseAtt($v_entry,
394
- $v_filedescr_list[],
395
- $v_options,
396
- $v_supported_attributes);
397
- if ($v_result != 1) {
398
- return 0;
399
- }
400
- }
401
-
402
- // ----- Expand the filelist (expand directories)
403
- $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
404
- if ($v_result != 1) {
405
- return 0;
406
- }
407
-
408
- // ----- Call the create fct
409
- $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
410
- if ($v_result != 1) {
411
- return 0;
412
- }
413
-
414
- // ----- Return
415
- return $p_result_list;
416
- }
417
- // --------------------------------------------------------------------------------
418
-
419
- // --------------------------------------------------------------------------------
420
- // Function :
421
- // add($p_filelist, $p_add_dir="", $p_remove_dir="")
422
- // add($p_filelist, $p_option, $p_option_value, ...)
423
- // Description :
424
- // This method supports two synopsis. The first one is historical.
425
- // This methods add the list of files in an existing archive.
426
- // If a file with the same name already exists, it is added at the end of the
427
- // archive, the first one is still present.
428
- // If the archive does not exist, it is created.
429
- // Parameters :
430
- // $p_filelist : An array containing file or directory names, or
431
- // a string containing one filename or one directory name, or
432
- // a string containing a list of filenames and/or directory
433
- // names separated by spaces.
434
- // $p_add_dir : A path to add before the real path of the archived file,
435
- // in order to have it memorized in the archive.
436
- // $p_remove_dir : A path to remove from the real path of the file to archive,
437
- // in order to have a shorter path memorized in the archive.
438
- // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
439
- // is removed first, before $p_add_dir is added.
440
- // Options :
441
- // PCLZIP_OPT_ADD_PATH :
442
- // PCLZIP_OPT_REMOVE_PATH :
443
- // PCLZIP_OPT_REMOVE_ALL_PATH :
444
- // PCLZIP_OPT_COMMENT :
445
- // PCLZIP_OPT_ADD_COMMENT :
446
- // PCLZIP_OPT_PREPEND_COMMENT :
447
- // PCLZIP_CB_PRE_ADD :
448
- // PCLZIP_CB_POST_ADD :
449
- // Return Values :
450
- // 0 on failure,
451
- // The list of the added files, with a status of the add action.
452
- // (see PclZip::listContent() for list entry format)
453
- // --------------------------------------------------------------------------------
454
- function add($p_filelist)
455
- {
456
- $v_result=1;
457
-
458
- // ----- Reset the error handler
459
- $this->privErrorReset();
460
-
461
- // ----- Set default values
462
- $v_options = array();
463
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
464
-
465
- // ----- Look for variable options arguments
466
- $v_size = func_num_args();
467
-
468
- // ----- Look for arguments
469
- if ($v_size > 1) {
470
- // ----- Get the arguments
471
- $v_arg_list = func_get_args();
472
-
473
- // ----- Remove form the options list the first argument
474
- array_shift($v_arg_list);
475
- $v_size--;
476
-
477
- // ----- Look for first arg
478
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
479
-
480
- // ----- Parse the options
481
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
482
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
483
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
484
- PCLZIP_OPT_ADD_PATH => 'optional',
485
- PCLZIP_CB_PRE_ADD => 'optional',
486
- PCLZIP_CB_POST_ADD => 'optional',
487
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
488
- PCLZIP_OPT_COMMENT => 'optional',
489
- PCLZIP_OPT_ADD_COMMENT => 'optional',
490
- PCLZIP_OPT_PREPEND_COMMENT => 'optional',
491
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
492
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
493
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
494
- //, PCLZIP_OPT_CRYPT => 'optional'
495
- ));
496
- if ($v_result != 1) {
497
- return 0;
498
- }
499
- }
500
-
501
- // ----- Look for 2 args
502
- // Here we need to support the first historic synopsis of the
503
- // method.
504
- else {
505
-
506
- // ----- Get the first argument
507
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
508
-
509
- // ----- Look for the optional second argument
510
- if ($v_size == 2) {
511
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
512
- }
513
- else if ($v_size > 2) {
514
- // ----- Error log
515
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
516
-
517
- // ----- Return
518
- return 0;
519
- }
520
- }
521
- }
522
-
523
- // ----- Look for default option values
524
- $this->privOptionDefaultThreshold($v_options);
525
-
526
- // ----- Init
527
- $v_string_list = array();
528
- $v_att_list = array();
529
- $v_filedescr_list = array();
530
- $p_result_list = array();
531
-
532
- // ----- Look if the $p_filelist is really an array
533
- if (is_array($p_filelist)) {
534
-
535
- // ----- Look if the first element is also an array
536
- // This will mean that this is a file description entry
537
- if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
538
- $v_att_list = $p_filelist;
539
- }
540
-
541
- // ----- The list is a list of string names
542
- else {
543
- $v_string_list = $p_filelist;
544
- }
545
- }
546
-
547
- // ----- Look if the $p_filelist is a string
548
- else if (is_string($p_filelist)) {
549
- // ----- Create a list from the string
550
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
551
- }
552
-
553
- // ----- Invalid variable type for $p_filelist
554
- else {
555
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
556
- return 0;
557
- }
558
-
559
- // ----- Reformat the string list
560
- if (sizeof($v_string_list) != 0) {
561
- foreach ($v_string_list as $v_string) {
562
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
563
- }
564
- }
565
-
566
- // ----- For each file in the list check the attributes
567
- $v_supported_attributes
568
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
569
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
570
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
571
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
572
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
573
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
574
- );
575
- foreach ($v_att_list as $v_entry) {
576
- $v_result = $this->privFileDescrParseAtt($v_entry,
577
- $v_filedescr_list[],
578
- $v_options,
579
- $v_supported_attributes);
580
- if ($v_result != 1) {
581
- return 0;
582
- }
583
- }
584
-
585
- // ----- Expand the filelist (expand directories)
586
- $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
587
- if ($v_result != 1) {
588
- return 0;
589
- }
590
-
591
- // ----- Call the create fct
592
- $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
593
- if ($v_result != 1) {
594
- return 0;
595
- }
596
-
597
- // ----- Return
598
- return $p_result_list;
599
- }
600
- // --------------------------------------------------------------------------------
601
-
602
- // --------------------------------------------------------------------------------
603
- // Function : listContent()
604
- // Description :
605
- // This public method, gives the list of the files and directories, with their
606
- // properties.
607
- // The properties of each entries in the list are (used also in other functions) :
608
- // filename : Name of the file. For a create or add action it is the filename
609
- // given by the user. For an extract function it is the filename
610
- // of the extracted file.
611
- // stored_filename : Name of the file / directory stored in the archive.
612
- // size : Size of the stored file.
613
- // compressed_size : Size of the file's data compressed in the archive
614
- // (without the headers overhead)
615
- // mtime : Last known modification date of the file (UNIX timestamp)
616
- // comment : Comment associated with the file
617
- // folder : true | false
618
- // index : index of the file in the archive
619
- // status : status of the action (depending of the action) :
620
- // Values are :
621
- // ok : OK !
622
- // filtered : the file / dir is not extracted (filtered by user)
623
- // already_a_directory : the file can not be extracted because a
624
- // directory with the same name already exists
625
- // write_protected : the file can not be extracted because a file
626
- // with the same name already exists and is
627
- // write protected
628
- // newer_exist : the file was not extracted because a newer file exists
629
- // path_creation_fail : the file is not extracted because the folder
630
- // does not exist and can not be created
631
- // write_error : the file was not extracted because there was a
632
- // error while writing the file
633
- // read_error : the file was not extracted because there was a error
634
- // while reading the file
635
- // invalid_header : the file was not extracted because of an archive
636
- // format error (bad file header)
637
- // Note that each time a method can continue operating when there
638
- // is an action error on a file, the error is only logged in the file status.
639
- // Return Values :
640
- // 0 on an unrecoverable failure,
641
- // The list of the files in the archive.
642
- // --------------------------------------------------------------------------------
643
- function listContent()
644
- {
645
- $v_result=1;
646
-
647
- // ----- Reset the error handler
648
- $this->privErrorReset();
649
-
650
- // ----- Check archive
651
- if (!$this->privCheckFormat()) {
652
- return(0);
653
- }
654
-
655
- // ----- Call the extracting fct
656
- $p_list = array();
657
- if (($v_result = $this->privList($p_list)) != 1)
658
- {
659
- unset($p_list);
660
- return(0);
661
- }
662
-
663
- // ----- Return
664
- return $p_list;
665
- }
666
- // --------------------------------------------------------------------------------
667
-
668
- // --------------------------------------------------------------------------------
669
- // Function :
670
- // extract($p_path="./", $p_remove_path="")
671
- // extract([$p_option, $p_option_value, ...])
672
- // Description :
673
- // This method supports two synopsis. The first one is historical.
674
- // This method extract all the files / directories from the archive to the
675
- // folder indicated in $p_path.
676
- // If you want to ignore the 'root' part of path of the memorized files
677
- // you can indicate this in the optional $p_remove_path parameter.
678
- // By default, if a newer file with the same name already exists, the
679
- // file is not extracted.
680
- //
681
- // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
682
- // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
683
- // at the end of the path value of PCLZIP_OPT_PATH.
684
- // Parameters :
685
- // $p_path : Path where the files and directories are to be extracted
686
- // $p_remove_path : First part ('root' part) of the memorized path
687
- // (if any similar) to remove while extracting.
688
- // Options :
689
- // PCLZIP_OPT_PATH :
690
- // PCLZIP_OPT_ADD_PATH :
691
- // PCLZIP_OPT_REMOVE_PATH :
692
- // PCLZIP_OPT_REMOVE_ALL_PATH :
693
- // PCLZIP_CB_PRE_EXTRACT :
694
- // PCLZIP_CB_POST_EXTRACT :
695
- // Return Values :
696
- // 0 or a negative value on failure,
697
- // The list of the extracted files, with a status of the action.
698
- // (see PclZip::listContent() for list entry format)
699
- // --------------------------------------------------------------------------------
700
- function extract()
701
- {
702
- $v_result=1;
703
-
704
- // ----- Reset the error handler
705
- $this->privErrorReset();
706
-
707
- // ----- Check archive
708
- if (!$this->privCheckFormat()) {
709
- return(0);
710
- }
711
-
712
- // ----- Set default values
713
- $v_options = array();
714
- // $v_path = "./";
715
- $v_path = '';
716
- $v_remove_path = "";
717
- $v_remove_all_path = false;
718
-
719
- // ----- Look for variable options arguments
720
- $v_size = func_num_args();
721
-
722
- // ----- Default values for option
723
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
724
-
725
- // ----- Look for arguments
726
- if ($v_size > 0) {
727
- // ----- Get the arguments
728
- $v_arg_list = func_get_args();
729
-
730
- // ----- Look for first arg
731
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
732
-
733
- // ----- Parse the options
734
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
735
- array (PCLZIP_OPT_PATH => 'optional',
736
- PCLZIP_OPT_REMOVE_PATH => 'optional',
737
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
738
- PCLZIP_OPT_ADD_PATH => 'optional',
739
- PCLZIP_CB_PRE_EXTRACT => 'optional',
740
- PCLZIP_CB_POST_EXTRACT => 'optional',
741
- PCLZIP_OPT_SET_CHMOD => 'optional',
742
- PCLZIP_OPT_BY_NAME => 'optional',
743
- PCLZIP_OPT_BY_EREG => 'optional',
744
- PCLZIP_OPT_BY_PREG => 'optional',
745
- PCLZIP_OPT_BY_INDEX => 'optional',
746
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
747
- PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
748
- PCLZIP_OPT_REPLACE_NEWER => 'optional'
749
- ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
750
- ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
751
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
752
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
753
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
754
- ));
755
- if ($v_result != 1) {
756
- return 0;
757
- }
758
-
759
- // ----- Set the arguments
760
- if (isset($v_options[PCLZIP_OPT_PATH])) {
761
- $v_path = $v_options[PCLZIP_OPT_PATH];
762
- }
763
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
764
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
765
- }
766
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
767
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
768
- }
769
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
770
- // ----- Check for '/' in last path char
771
- if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
772
- $v_path .= '/';
773
- }
774
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
775
- }
776
- }
777
-
778
- // ----- Look for 2 args
779
- // Here we need to support the first historic synopsis of the
780
- // method.
781
- else {
782
-
783
- // ----- Get the first argument
784
- $v_path = $v_arg_list[0];
785
-
786
- // ----- Look for the optional second argument
787
- if ($v_size == 2) {
788
- $v_remove_path = $v_arg_list[1];
789
- }
790
- else if ($v_size > 2) {
791
- // ----- Error log
792
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
793
-
794
- // ----- Return
795
- return 0;
796
- }
797
- }
798
- }
799
-
800
- // ----- Look for default option values
801
- $this->privOptionDefaultThreshold($v_options);
802
-
803
- // ----- Trace
804
-
805
- // ----- Call the extracting fct
806
- $p_list = array();
807
- $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
808
- $v_remove_all_path, $v_options);
809
- if ($v_result < 1) {
810
- unset($p_list);
811
- return(0);
812
- }
813
-
814
- // ----- Return
815
- return $p_list;
816
- }
817
- // --------------------------------------------------------------------------------
818
-
819
-
820
- // --------------------------------------------------------------------------------
821
- // Function :
822
- // extractByIndex($p_index, $p_path="./", $p_remove_path="")
823
- // extractByIndex($p_index, [$p_option, $p_option_value, ...])
824
- // Description :
825
- // This method supports two synopsis. The first one is historical.
826
- // This method is doing a partial extract of the archive.
827
- // The extracted files or folders are identified by their index in the
828
- // archive (from 0 to n).
829
- // Note that if the index identify a folder, only the folder entry is
830
- // extracted, not all the files included in the archive.
831
- // Parameters :
832
- // $p_index : A single index (integer) or a string of indexes of files to
833
- // extract. The form of the string is "0,4-6,8-12" with only numbers
834
- // and '-' for range or ',' to separate ranges. No spaces or ';'
835
- // are allowed.
836
- // $p_path : Path where the files and directories are to be extracted
837
- // $p_remove_path : First part ('root' part) of the memorized path
838
- // (if any similar) to remove while extracting.
839
- // Options :
840
- // PCLZIP_OPT_PATH :
841
- // PCLZIP_OPT_ADD_PATH :
842
- // PCLZIP_OPT_REMOVE_PATH :
843
- // PCLZIP_OPT_REMOVE_ALL_PATH :
844
- // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
845
- // not as files.
846
- // The resulting content is in a new field 'content' in the file
847
- // structure.
848
- // This option must be used alone (any other options are ignored).
849
- // PCLZIP_CB_PRE_EXTRACT :
850
- // PCLZIP_CB_POST_EXTRACT :
851
- // Return Values :
852
- // 0 on failure,
853
- // The list of the extracted files, with a status of the action.
854
- // (see PclZip::listContent() for list entry format)
855
- // --------------------------------------------------------------------------------
856
- //function extractByIndex($p_index, options...)
857
- function extractByIndex($p_index)
858
- {
859
- $v_result=1;
860
-
861
- // ----- Reset the error handler
862
- $this->privErrorReset();
863
-
864
- // ----- Check archive
865
- if (!$this->privCheckFormat()) {
866
- return(0);
867
- }
868
-
869
- // ----- Set default values
870
- $v_options = array();
871
- // $v_path = "./";
872
- $v_path = '';
873
- $v_remove_path = "";
874
- $v_remove_all_path = false;
875
-
876
- // ----- Look for variable options arguments
877
- $v_size = func_num_args();
878
-
879
- // ----- Default values for option
880
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
881
-
882
- // ----- Look for arguments
883
- if ($v_size > 1) {
884
- // ----- Get the arguments
885
- $v_arg_list = func_get_args();
886
-
887
- // ----- Remove form the options list the first argument
888
- array_shift($v_arg_list);
889
- $v_size--;
890
-
891
- // ----- Look for first arg
892
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
893
-
894
- // ----- Parse the options
895
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
896
- array (PCLZIP_OPT_PATH => 'optional',
897
- PCLZIP_OPT_REMOVE_PATH => 'optional',
898
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
899
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
900
- PCLZIP_OPT_ADD_PATH => 'optional',
901
- PCLZIP_CB_PRE_EXTRACT => 'optional',
902
- PCLZIP_CB_POST_EXTRACT => 'optional',
903
- PCLZIP_OPT_SET_CHMOD => 'optional',
904
- PCLZIP_OPT_REPLACE_NEWER => 'optional'
905
- ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
906
- ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
907
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
908
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
909
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
910
- ));
911
- if ($v_result != 1) {
912
- return 0;
913
- }
914
-
915
- // ----- Set the arguments
916
- if (isset($v_options[PCLZIP_OPT_PATH])) {
917
- $v_path = $v_options[PCLZIP_OPT_PATH];
918
- }
919
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
920
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
921
- }
922
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
923
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
924
- }
925
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
926
- // ----- Check for '/' in last path char
927
- if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
928
- $v_path .= '/';
929
- }
930
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
931
- }
932
- if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
933
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
934
- }
935
- else {
936
- }
937
- }
938
-
939
- // ----- Look for 2 args
940
- // Here we need to support the first historic synopsis of the
941
- // method.
942
- else {
943
-
944
- // ----- Get the first argument
945
- $v_path = $v_arg_list[0];
946
-
947
- // ----- Look for the optional second argument
948
- if ($v_size == 2) {
949
- $v_remove_path = $v_arg_list[1];
950
- }
951
- else if ($v_size > 2) {
952
- // ----- Error log
953
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
954
-
955
- // ----- Return
956
- return 0;
957
- }
958
- }
959
- }
960
-
961
- // ----- Trace
962
-
963
- // ----- Trick
964
- // Here I want to reuse extractByRule(), so I need to parse the $p_index
965
- // with privParseOptions()
966
- $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
967
- $v_options_trick = array();
968
- $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
969
- array (PCLZIP_OPT_BY_INDEX => 'optional' ));
970
- if ($v_result != 1) {
971
- return 0;
972
- }
973
- $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
974
-
975
- // ----- Look for default option values
976
- $this->privOptionDefaultThreshold($v_options);
977
-
978
- // ----- Call the extracting fct
979
- if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
980
- return(0);
981
- }
982
-
983
- // ----- Return
984
- return $p_list;
985
- }
986
- // --------------------------------------------------------------------------------
987
-
988
- // --------------------------------------------------------------------------------
989
- // Function :
990
- // delete([$p_option, $p_option_value, ...])
991
- // Description :
992
- // This method removes files from the archive.
993
- // If no parameters are given, then all the archive is emptied.
994
- // Parameters :
995
- // None or optional arguments.
996
- // Options :
997
- // PCLZIP_OPT_BY_INDEX :
998
- // PCLZIP_OPT_BY_NAME :
999
- // PCLZIP_OPT_BY_EREG :
1000
- // PCLZIP_OPT_BY_PREG :
1001
- // Return Values :
1002
- // 0 on failure,
1003
- // The list of the files which are still present in the archive.
1004
- // (see PclZip::listContent() for list entry format)
1005
- // --------------------------------------------------------------------------------
1006
- function delete()
1007
- {
1008
- $v_result=1;
1009
-
1010
- // ----- Reset the error handler
1011
- $this->privErrorReset();
1012
-
1013
- // ----- Check archive
1014
- if (!$this->privCheckFormat()) {
1015
- return(0);
1016
- }
1017
-
1018
- // ----- Set default values
1019
- $v_options = array();
1020
-
1021
- // ----- Look for variable options arguments
1022
- $v_size = func_num_args();
1023
-
1024
- // ----- Look for arguments
1025
- if ($v_size > 0) {
1026
- // ----- Get the arguments
1027
- $v_arg_list = func_get_args();
1028
-
1029
- // ----- Parse the options
1030
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1031
- array (PCLZIP_OPT_BY_NAME => 'optional',
1032
- PCLZIP_OPT_BY_EREG => 'optional',
1033
- PCLZIP_OPT_BY_PREG => 'optional',
1034
- PCLZIP_OPT_BY_INDEX => 'optional' ));
1035
- if ($v_result != 1) {
1036
- return 0;
1037
- }
1038
- }
1039
-
1040
- // ----- Magic quotes trick
1041
- $this->privDisableMagicQuotes();
1042
-
1043
- // ----- Call the delete fct
1044
- $v_list = array();
1045
- if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
1046
- $this->privSwapBackMagicQuotes();
1047
- unset($v_list);
1048
- return(0);
1049
- }
1050
-
1051
- // ----- Magic quotes trick
1052
- $this->privSwapBackMagicQuotes();
1053
-
1054
- // ----- Return
1055
- return $v_list;
1056
- }
1057
- // --------------------------------------------------------------------------------
1058
-
1059
- // --------------------------------------------------------------------------------
1060
- // Function : deleteByIndex()
1061
- // Description :
1062
- // ***** Deprecated *****
1063
- // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
1064
- // --------------------------------------------------------------------------------
1065
- function deleteByIndex($p_index)
1066
- {
1067
-
1068
- $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
1069
-
1070
- // ----- Return
1071
- return $p_list;
1072
- }
1073
- // --------------------------------------------------------------------------------
1074
-
1075
- // --------------------------------------------------------------------------------
1076
- // Function : properties()
1077
- // Description :
1078
- // This method gives the properties of the archive.
1079
- // The properties are :
1080
- // nb : Number of files in the archive
1081
- // comment : Comment associated with the archive file
1082
- // status : not_exist, ok
1083
- // Parameters :
1084
- // None
1085
- // Return Values :
1086
- // 0 on failure,
1087
- // An array with the archive properties.
1088
- // --------------------------------------------------------------------------------
1089
- function properties()
1090
- {
1091
-
1092
- // ----- Reset the error handler
1093
- $this->privErrorReset();
1094
-
1095
- // ----- Magic quotes trick
1096
- $this->privDisableMagicQuotes();
1097
-
1098
- // ----- Check archive
1099
- if (!$this->privCheckFormat()) {
1100
- $this->privSwapBackMagicQuotes();
1101
- return(0);
1102
- }
1103
-
1104
- // ----- Default properties
1105
- $v_prop = array();
1106
- $v_prop['comment'] = '';
1107
- $v_prop['nb'] = 0;
1108
- $v_prop['status'] = 'not_exist';
1109
-
1110
- // ----- Look if file exists
1111
- if (@is_file($this->zipname))
1112
- {
1113
- // ----- Open the zip file
1114
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1115
- {
1116
- $this->privSwapBackMagicQuotes();
1117
-
1118
- // ----- Error log
1119
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1120
-
1121
- // ----- Return
1122
- return 0;
1123
- }
1124
-
1125
- // ----- Read the central directory informations
1126
- $v_central_dir = array();
1127
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1128
- {
1129
- $this->privSwapBackMagicQuotes();
1130
- return 0;
1131
- }
1132
-
1133
- // ----- Close the zip file
1134
- $this->privCloseFd();
1135
-
1136
- // ----- Set the user attributes
1137
- $v_prop['comment'] = $v_central_dir['comment'];
1138
- $v_prop['nb'] = $v_central_dir['entries'];
1139
- $v_prop['status'] = 'ok';
1140
- }
1141
-
1142
- // ----- Magic quotes trick
1143
- $this->privSwapBackMagicQuotes();
1144
-
1145
- // ----- Return
1146
- return $v_prop;
1147
- }
1148
- // --------------------------------------------------------------------------------
1149
-
1150
- // --------------------------------------------------------------------------------
1151
- // Function : duplicate()
1152
- // Description :
1153
- // This method creates an archive by copying the content of an other one. If
1154
- // the archive already exist, it is replaced by the new one without any warning.
1155
- // Parameters :
1156
- // $p_archive : The filename of a valid archive, or
1157
- // a valid PclZip object.
1158
- // Return Values :
1159
- // 1 on success.
1160
- // 0 or a negative value on error (error code).
1161
- // --------------------------------------------------------------------------------
1162
- function duplicate($p_archive)
1163
- {
1164
- $v_result = 1;
1165
-
1166
- // ----- Reset the error handler
1167
- $this->privErrorReset();
1168
-
1169
- // ----- Look if the $p_archive is a PclZip object
1170
- if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
1171
- {
1172
-
1173
- // ----- Duplicate the archive
1174
- $v_result = $this->privDuplicate($p_archive->zipname);
1175
- }
1176
-
1177
- // ----- Look if the $p_archive is a string (so a filename)
1178
- else if (is_string($p_archive))
1179
- {
1180
-
1181
- // ----- Check that $p_archive is a valid zip file
1182
- // TBC : Should also check the archive format
1183
- if (!is_file($p_archive)) {
1184
- // ----- Error log
1185
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1186
- $v_result = PCLZIP_ERR_MISSING_FILE;
1187
- }
1188
- else {
1189
- // ----- Duplicate the archive
1190
- $v_result = $this->privDuplicate($p_archive);
1191
- }
1192
- }
1193
-
1194
- // ----- Invalid variable
1195
- else
1196
- {
1197
- // ----- Error log
1198
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1199
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1200
- }
1201
-
1202
- // ----- Return
1203
- return $v_result;
1204
- }
1205
- // --------------------------------------------------------------------------------
1206
-
1207
- // --------------------------------------------------------------------------------
1208
- // Function : merge()
1209
- // Description :
1210
- // This method merge the $p_archive_to_add archive at the end of the current
1211
- // one ($this).
1212
- // If the archive ($this) does not exist, the merge becomes a duplicate.
1213
- // If the $p_archive_to_add archive does not exist, the merge is a success.
1214
- // Parameters :
1215
- // $p_archive_to_add : It can be directly the filename of a valid zip archive,
1216
- // or a PclZip object archive.
1217
- // Return Values :
1218
- // 1 on success,
1219
- // 0 or negative values on error (see below).
1220
- // --------------------------------------------------------------------------------
1221
- function merge($p_archive_to_add)
1222
- {
1223
- $v_result = 1;
1224
-
1225
- // ----- Reset the error handler
1226
- $this->privErrorReset();
1227
-
1228
- // ----- Check archive
1229
- if (!$this->privCheckFormat()) {
1230
- return(0);
1231
- }
1232
-
1233
- // ----- Look if the $p_archive_to_add is a PclZip object
1234
- if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
1235
- {
1236
-
1237
- // ----- Merge the archive
1238
- $v_result = $this->privMerge($p_archive_to_add);
1239
- }
1240
-
1241
- // ----- Look if the $p_archive_to_add is a string (so a filename)
1242
- else if (is_string($p_archive_to_add))
1243
- {
1244
-
1245
- // ----- Create a temporary archive
1246
- $v_object_archive = new PclZip($p_archive_to_add);
1247
-
1248
- // ----- Merge the archive
1249
- $v_result = $this->privMerge($v_object_archive);
1250
- }
1251
-
1252
- // ----- Invalid variable
1253
- else
1254
- {
1255
- // ----- Error log
1256
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1257
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1258
- }
1259
-
1260
- // ----- Return
1261
- return $v_result;
1262
- }
1263
- // --------------------------------------------------------------------------------
1264
-
1265
-
1266
-
1267
- // --------------------------------------------------------------------------------
1268
- // Function : errorCode()
1269
- // Description :
1270
- // Parameters :
1271
- // --------------------------------------------------------------------------------
1272
- function errorCode()
1273
- {
1274
- if (PCLZIP_ERROR_EXTERNAL == 1) {
1275
- return(PclErrorCode());
1276
- }
1277
- else {
1278
- return($this->error_code);
1279
- }
1280
- }
1281
- // --------------------------------------------------------------------------------
1282
-
1283
- // --------------------------------------------------------------------------------
1284
- // Function : errorName()
1285
- // Description :
1286
- // Parameters :
1287
- // --------------------------------------------------------------------------------
1288
- function errorName($p_with_code=false)
1289
- {
1290
- $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1291
- PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1292
- PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1293
- PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1294
- PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1295
- PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1296
- PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1297
- PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1298
- PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1299
- PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1300
- PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1301
- PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1302
- PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1303
- PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1304
- PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1305
- PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1306
- PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1307
- PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1308
- PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1309
- ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1310
- ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1311
- );
1312
-
1313
- if (isset($v_name[$this->error_code])) {
1314
- $v_value = $v_name[$this->error_code];
1315
- }
1316
- else {
1317
- $v_value = 'NoName';
1318
- }
1319
-
1320
- if ($p_with_code) {
1321
- return($v_value.' ('.$this->error_code.')');
1322
- }
1323
- else {
1324
- return($v_value);
1325
- }
1326
- }
1327
- // --------------------------------------------------------------------------------
1328
-
1329
- // --------------------------------------------------------------------------------
1330
- // Function : errorInfo()
1331
- // Description :
1332
- // Parameters :
1333
- // --------------------------------------------------------------------------------
1334
- function errorInfo($p_full=false)
1335
- {
1336
- if (PCLZIP_ERROR_EXTERNAL == 1) {
1337
- return(PclErrorString());
1338
- }
1339
- else {
1340
- if ($p_full) {
1341
- return($this->errorName(true)." : ".$this->error_string);
1342
- }
1343
- else {
1344
- return($this->error_string." [code ".$this->error_code."]");
1345
- }
1346
- }
1347
- }
1348
- // --------------------------------------------------------------------------------
1349
-
1350
-
1351
- // --------------------------------------------------------------------------------
1352
- // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
1353
- // ***** *****
1354
- // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
1355
- // --------------------------------------------------------------------------------
1356
-
1357
-
1358
-
1359
- // --------------------------------------------------------------------------------
1360
- // Function : privCheckFormat()
1361
- // Description :
1362
- // This method check that the archive exists and is a valid zip archive.
1363
- // Several level of check exists. (futur)
1364
- // Parameters :
1365
- // $p_level : Level of check. Default 0.
1366
- // 0 : Check the first bytes (magic codes) (default value))
1367
- // 1 : 0 + Check the central directory (futur)
1368
- // 2 : 1 + Check each file header (futur)
1369
- // Return Values :
1370
- // true on success,
1371
- // false on error, the error code is set.
1372
- // --------------------------------------------------------------------------------
1373
- function privCheckFormat($p_level=0)
1374
- {
1375
- $v_result = true;
1376
-
1377
- // ----- Reset the file system cache
1378
- clearstatcache();
1379
-
1380
- // ----- Reset the error handler
1381
- $this->privErrorReset();
1382
-
1383
- // ----- Look if the file exits
1384
- if (!is_file($this->zipname)) {
1385
- // ----- Error log
1386
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1387
- return(false);
1388
- }
1389
-
1390
- // ----- Check that the file is readeable
1391
- if (!is_readable($this->zipname)) {
1392
- // ----- Error log
1393
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1394
- return(false);
1395
- }
1396
-
1397
- // ----- Check the magic code
1398
- // TBC
1399
-
1400
- // ----- Check the central header
1401
- // TBC
1402
-
1403
- // ----- Check each file header
1404
- // TBC
1405
-
1406
- // ----- Return
1407
- return $v_result;
1408
- }
1409
- // --------------------------------------------------------------------------------
1410
-
1411
- // --------------------------------------------------------------------------------
1412
- // Function : privParseOptions()
1413
- // Description :
1414
- // This internal methods reads the variable list of arguments ($p_options_list,
1415
- // $p_size) and generate an array with the options and values ($v_result_list).
1416
- // $v_requested_options contains the options that can be present and those that
1417
- // must be present.
1418
- // $v_requested_options is an array, with the option value as key, and 'optional',
1419
- // or 'mandatory' as value.
1420
- // Parameters :
1421
- // See above.
1422
- // Return Values :
1423
- // 1 on success.
1424
- // 0 on failure.
1425
- // --------------------------------------------------------------------------------
1426
- function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1427
- {
1428
- $v_result=1;
1429
-
1430
- // ----- Read the options
1431
- $i=0;
1432
- while ($i<$p_size) {
1433
-
1434
- // ----- Check if the option is supported
1435
- if (!isset($v_requested_options[$p_options_list[$i]])) {
1436
- // ----- Error log
1437
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1438
-
1439
- // ----- Return
1440
- return PclZip::errorCode();
1441
- }
1442
-
1443
- // ----- Look for next option
1444
- switch ($p_options_list[$i]) {
1445
- // ----- Look for options that request a path value
1446
- case PCLZIP_OPT_PATH :
1447
- case PCLZIP_OPT_REMOVE_PATH :
1448
- case PCLZIP_OPT_ADD_PATH :
1449
- // ----- Check the number of parameters
1450
- if (($i+1) >= $p_size) {
1451
- // ----- Error log
1452
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1453
-
1454
- // ----- Return
1455
- return PclZip::errorCode();
1456
- }
1457
-
1458
- // ----- Get the value
1459
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1460
- $i++;
1461
- break;
1462
-
1463
- case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1464
- // ----- Check the number of parameters
1465
- if (($i+1) >= $p_size) {
1466
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1467
- return PclZip::errorCode();
1468
- }
1469
-
1470
- // ----- Check for incompatible options
1471
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1472
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1473
- return PclZip::errorCode();
1474
- }
1475
-
1476
- // ----- Check the value
1477
- $v_value = $p_options_list[$i+1];
1478
- if ((!is_integer($v_value)) || ($v_value<0)) {
1479
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1480
- return PclZip::errorCode();
1481
- }
1482
-
1483
- // ----- Get the value (and convert it in bytes)
1484
- $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1485
- $i++;
1486
- break;
1487
-
1488
- case PCLZIP_OPT_TEMP_FILE_ON :
1489
- // ----- Check for incompatible options
1490
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1491
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1492
- return PclZip::errorCode();
1493
- }
1494
-
1495
- $v_result_list[$p_options_list[$i]] = true;
1496
- break;
1497
-
1498
- case PCLZIP_OPT_TEMP_FILE_OFF :
1499
- // ----- Check for incompatible options
1500
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
1501
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1502
- return PclZip::errorCode();
1503
- }
1504
- // ----- Check for incompatible options
1505
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1506
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1507
- return PclZip::errorCode();
1508
- }
1509
-
1510
- $v_result_list[$p_options_list[$i]] = true;
1511
- break;
1512
-
1513
- case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1514
- // ----- Check the number of parameters
1515
- if (($i+1) >= $p_size) {
1516
- // ----- Error log
1517
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1518
-
1519
- // ----- Return
1520
- return PclZip::errorCode();
1521
- }
1522
-
1523
- // ----- Get the value
1524
- if ( is_string($p_options_list[$i+1])
1525
- && ($p_options_list[$i+1] != '')) {
1526
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1527
- $i++;
1528
- }
1529
- else {
1530
- }
1531
- break;
1532
-
1533
- // ----- Look for options that request an array of string for value
1534
- case PCLZIP_OPT_BY_NAME :
1535
- // ----- Check the number of parameters
1536
- if (($i+1) >= $p_size) {
1537
- // ----- Error log
1538
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1539
-
1540
- // ----- Return
1541
- return PclZip::errorCode();
1542
- }
1543
-
1544
- // ----- Get the value
1545
- if (is_string($p_options_list[$i+1])) {
1546
- $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1547
- }
1548
- else if (is_array($p_options_list[$i+1])) {
1549
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1550
- }
1551
- else {
1552
- // ----- Error log
1553
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1554
-
1555
- // ----- Return
1556
- return PclZip::errorCode();
1557
- }
1558
- $i++;
1559
- break;
1560
-
1561
- // ----- Look for options that request an EREG or PREG expression
1562
- case PCLZIP_OPT_BY_EREG :
1563
- // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
1564
- // to PCLZIP_OPT_BY_PREG
1565
- $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
1566
- case PCLZIP_OPT_BY_PREG :
1567
- //case PCLZIP_OPT_CRYPT :
1568
- // ----- Check the number of parameters
1569
- if (($i+1) >= $p_size) {
1570
- // ----- Error log
1571
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1572
-
1573
- // ----- Return
1574
- return PclZip::errorCode();
1575
- }
1576
-
1577
- // ----- Get the value
1578
- if (is_string($p_options_list[$i+1])) {
1579
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1580
- }
1581
- else {
1582
- // ----- Error log
1583
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1584
-
1585
- // ----- Return
1586
- return PclZip::errorCode();
1587
- }
1588
- $i++;
1589
- break;
1590
-
1591
- // ----- Look for options that takes a string
1592
- case PCLZIP_OPT_COMMENT :
1593
- case PCLZIP_OPT_ADD_COMMENT :
1594
- case PCLZIP_OPT_PREPEND_COMMENT :
1595
- // ----- Check the number of parameters
1596
- if (($i+1) >= $p_size) {
1597
- // ----- Error log
1598
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1599
- "Missing parameter value for option '"
1600
- .PclZipUtilOptionText($p_options_list[$i])
1601
- ."'");
1602
-
1603
- // ----- Return
1604
- return PclZip::errorCode();
1605
- }
1606
-
1607
- // ----- Get the value
1608
- if (is_string($p_options_list[$i+1])) {
1609
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1610
- }
1611
- else {
1612
- // ----- Error log
1613
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1614
- "Wrong parameter value for option '"
1615
- .PclZipUtilOptionText($p_options_list[$i])
1616
- ."'");
1617
-
1618
- // ----- Return
1619
- return PclZip::errorCode();
1620
- }
1621
- $i++;
1622
- break;
1623
-
1624
- // ----- Look for options that request an array of index
1625
- case PCLZIP_OPT_BY_INDEX :
1626
- // ----- Check the number of parameters
1627
- if (($i+1) >= $p_size) {
1628
- // ----- Error log
1629
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1630
-
1631
- // ----- Return
1632
- return PclZip::errorCode();
1633
- }
1634
-
1635
- // ----- Get the value
1636
- $v_work_list = array();
1637
- if (is_string($p_options_list[$i+1])) {
1638
-
1639
- // ----- Remove spaces
1640
- $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1641
-
1642
- // ----- Parse items
1643
- $v_work_list = explode(",", $p_options_list[$i+1]);
1644
- }
1645
- else if (is_integer($p_options_list[$i+1])) {
1646
- $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1647
- }
1648
- else if (is_array($p_options_list[$i+1])) {
1649
- $v_work_list = $p_options_list[$i+1];
1650
- }
1651
- else {
1652
- // ----- Error log
1653
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1654
-
1655
- // ----- Return
1656
- return PclZip::errorCode();
1657
- }
1658
-
1659
- // ----- Reduce the index list
1660
- // each index item in the list must be a couple with a start and
1661
- // an end value : [0,3], [5-5], [8-10], ...
1662
- // ----- Check the format of each item
1663
- $v_sort_flag=false;
1664
- $v_sort_value=0;
1665
- for ($j=0; $j<sizeof($v_work_list); $j++) {
1666
- // ----- Explode the item
1667
- $v_item_list = explode("-", $v_work_list[$j]);
1668
- $v_size_item_list = sizeof($v_item_list);
1669
-
1670
- // ----- TBC : Here we might check that each item is a
1671
- // real integer ...
1672
-
1673
- // ----- Look for single value
1674
- if ($v_size_item_list == 1) {
1675
- // ----- Set the option value
1676
- $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1677
- $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1678
- }
1679
- elseif ($v_size_item_list == 2) {
1680
- // ----- Set the option value
1681
- $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1682
- $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1683
- }
1684
- else {
1685
- // ----- Error log
1686
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1687
-
1688
- // ----- Return
1689
- return PclZip::errorCode();
1690
- }
1691
-
1692
-
1693
- // ----- Look for list sort
1694
- if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1695
- $v_sort_flag=true;
1696
-
1697
- // ----- TBC : An automatic sort should be writen ...
1698
- // ----- Error log
1699
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1700
-
1701
- // ----- Return
1702
- return PclZip::errorCode();
1703
- }
1704
- $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1705
- }
1706
-
1707
- // ----- Sort the items
1708
- if ($v_sort_flag) {
1709
- // TBC : To Be Completed
1710
- }
1711
-
1712
- // ----- Next option
1713
- $i++;
1714
- break;
1715
-
1716
- // ----- Look for options that request no value
1717
- case PCLZIP_OPT_REMOVE_ALL_PATH :
1718
- case PCLZIP_OPT_EXTRACT_AS_STRING :
1719
- case PCLZIP_OPT_NO_COMPRESSION :
1720
- case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
1721
- case PCLZIP_OPT_REPLACE_NEWER :
1722
- case PCLZIP_OPT_STOP_ON_ERROR :
1723
- $v_result_list[$p_options_list[$i]] = true;
1724
- break;
1725
-
1726
- // ----- Look for options that request an octal value
1727
- case PCLZIP_OPT_SET_CHMOD :
1728
- // ----- Check the number of parameters
1729
- if (($i+1) >= $p_size) {
1730
- // ----- Error log
1731
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1732
-
1733
- // ----- Return
1734
- return PclZip::errorCode();
1735
- }
1736
-
1737
- // ----- Get the value
1738
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1739
- $i++;
1740
- break;
1741
-
1742
- // ----- Look for options that request a call-back
1743
- case PCLZIP_CB_PRE_EXTRACT :
1744
- case PCLZIP_CB_POST_EXTRACT :
1745
- case PCLZIP_CB_PRE_ADD :
1746
- case PCLZIP_CB_POST_ADD :
1747
- /* for futur use
1748
- case PCLZIP_CB_PRE_DELETE :
1749
- case PCLZIP_CB_POST_DELETE :
1750
- case PCLZIP_CB_PRE_LIST :
1751
- case PCLZIP_CB_POST_LIST :
1752
- */
1753
- // ----- Check the number of parameters
1754
- if (($i+1) >= $p_size) {
1755
- // ----- Error log
1756
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1757
-
1758
- // ----- Return
1759
- return PclZip::errorCode();
1760
- }
1761
-
1762
- // ----- Get the value
1763
- $v_function_name = $p_options_list[$i+1];
1764
-
1765
- // ----- Check that the value is a valid existing function
1766
- if (!function_exists($v_function_name)) {
1767
- // ----- Error log
1768
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1769
-
1770
- // ----- Return
1771
- return PclZip::errorCode();
1772
- }
1773
-
1774
- // ----- Set the attribute
1775
- $v_result_list[$p_options_list[$i]] = $v_function_name;
1776
- $i++;
1777
- break;
1778
-
1779
- default :
1780
- // ----- Error log
1781
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1782
- "Unknown parameter '"
1783
- .$p_options_list[$i]."'");
1784
-
1785
- // ----- Return
1786
- return PclZip::errorCode();
1787
- }
1788
-
1789
- // ----- Next options
1790
- $i++;
1791
- }
1792
-
1793
- // ----- Look for mandatory options
1794
- if ($v_requested_options !== false) {
1795
- for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1796
- // ----- Look for mandatory option
1797
- if ($v_requested_options[$key] == 'mandatory') {
1798
- // ----- Look if present
1799
- if (!isset($v_result_list[$key])) {
1800
- // ----- Error log
1801
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1802
-
1803
- // ----- Return
1804
- return PclZip::errorCode();
1805
- }
1806
- }
1807
- }
1808
- }
1809
-
1810
- // ----- Look for default values
1811
- if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1812
-
1813
- }
1814
-
1815
- // ----- Return
1816
- return $v_result;
1817
- }
1818
- // --------------------------------------------------------------------------------
1819
-
1820
- // --------------------------------------------------------------------------------
1821
- // Function : privOptionDefaultThreshold()
1822
- // Description :
1823
- // Parameters :
1824
- // Return Values :
1825
- // --------------------------------------------------------------------------------
1826
- function privOptionDefaultThreshold(&$p_options)
1827
- {
1828
- $v_result=1;
1829
-
1830
- if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1831
- || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
1832
- return $v_result;
1833
- }
1834
-
1835
- // ----- Get 'memory_limit' configuration value
1836
- $v_memory_limit = ini_get('memory_limit');
1837
- $v_memory_limit = trim($v_memory_limit);
1838
- $last = strtolower(substr($v_memory_limit, -1));
1839
-
1840
- if($last == 'g')
1841
- //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1842
- $v_memory_limit = $v_memory_limit*1073741824;
1843
- if($last == 'm')
1844
- //$v_memory_limit = $v_memory_limit*1024*1024;
1845
- $v_memory_limit = $v_memory_limit*1048576;
1846
- if($last == 'k')
1847
- $v_memory_limit = $v_memory_limit*1024;
1848
-
1849
- $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1850
-
1851
-
1852
- // ----- Sanity check : No threshold if value lower than 1M
1853
- if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1854
- unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1855
- }
1856
-
1857
- // ----- Return
1858
- return $v_result;
1859
- }
1860
- // --------------------------------------------------------------------------------
1861
-
1862
- // --------------------------------------------------------------------------------
1863
- // Function : privFileDescrParseAtt()
1864
- // Description :
1865
- // Parameters :
1866
- // Return Values :
1867
- // 1 on success.
1868
- // 0 on failure.
1869
- // --------------------------------------------------------------------------------
1870
- function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1871
- {
1872
- $v_result=1;
1873
-
1874
- // ----- For each file in the list check the attributes
1875
- foreach ($p_file_list as $v_key => $v_value) {
1876
-
1877
- // ----- Check if the option is supported
1878
- if (!isset($v_requested_options[$v_key])) {
1879
- // ----- Error log
1880
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1881
-
1882
- // ----- Return
1883
- return PclZip::errorCode();
1884
- }
1885
-
1886
- // ----- Look for attribute
1887
- switch ($v_key) {
1888
- case PCLZIP_ATT_FILE_NAME :
1889
- if (!is_string($v_value)) {
1890
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1891
- return PclZip::errorCode();
1892
- }
1893
-
1894
- $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1895
-
1896
- if ($p_filedescr['filename'] == '') {
1897
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1898
- return PclZip::errorCode();
1899
- }
1900
-
1901
- break;
1902
-
1903
- case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1904
- if (!is_string($v_value)) {
1905
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1906
- return PclZip::errorCode();
1907
- }
1908
-
1909
- $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1910
-
1911
- if ($p_filedescr['new_short_name'] == '') {
1912
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1913
- return PclZip::errorCode();
1914
- }
1915
- break;
1916
-
1917
- case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1918
- if (!is_string($v_value)) {
1919
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1920
- return PclZip::errorCode();
1921
- }
1922
-
1923
- $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1924
-
1925
- if ($p_filedescr['new_full_name'] == '') {
1926
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1927
- return PclZip::errorCode();
1928
- }
1929
- break;
1930
-
1931
- // ----- Look for options that takes a string
1932
- case PCLZIP_ATT_FILE_COMMENT :
1933
- if (!is_string($v_value)) {
1934
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1935
- return PclZip::errorCode();
1936
- }
1937
-
1938
- $p_filedescr['comment'] = $v_value;
1939
- break;
1940
-
1941
- case PCLZIP_ATT_FILE_MTIME :
1942
- if (!is_integer($v_value)) {
1943
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1944
- return PclZip::errorCode();
1945
- }
1946
-
1947
- $p_filedescr['mtime'] = $v_value;
1948
- break;
1949
-
1950
- case PCLZIP_ATT_FILE_CONTENT :
1951
- $p_filedescr['content'] = $v_value;
1952
- break;
1953
-
1954
- default :
1955
- // ----- Error log
1956
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1957
- "Unknown parameter '".$v_key."'");
1958
-
1959
- // ----- Return
1960
- return PclZip::errorCode();
1961
- }
1962
-
1963
- // ----- Look for mandatory options
1964
- if ($v_requested_options !== false) {
1965
- for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1966
- // ----- Look for mandatory option
1967
- if ($v_requested_options[$key] == 'mandatory') {
1968
- // ----- Look if present
1969
- if (!isset($p_file_list[$key])) {
1970
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1971
- return PclZip::errorCode();
1972
- }
1973
- }
1974
- }
1975
- }
1976
-
1977
- // end foreach
1978
- }
1979
-
1980
- // ----- Return
1981
- return $v_result;
1982
- }
1983
- // --------------------------------------------------------------------------------
1984
-
1985
- // --------------------------------------------------------------------------------
1986
- // Function : privFileDescrExpand()
1987
- // Description :
1988
- // This method look for each item of the list to see if its a file, a folder
1989
- // or a string to be added as file. For any other type of files (link, other)
1990
- // just ignore the item.
1991
- // Then prepare the information that will be stored for that file.
1992
- // When its a folder, expand the folder with all the files that are in that
1993
- // folder (recursively).
1994
- // Parameters :
1995
- // Return Values :
1996
- // 1 on success.
1997
- // 0 on failure.
1998
- // --------------------------------------------------------------------------------
1999
- function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2000
- {
2001
- $v_result=1;
2002
-
2003
- // ----- Create a result list
2004
- $v_result_list = array();
2005
-
2006
- // ----- Look each entry
2007
- for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2008
-
2009
- // ----- Get filedescr
2010
- $v_descr = $p_filedescr_list[$i];
2011
-
2012
- // ----- Reduce the filename
2013
- $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2014
- $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2015
-
2016
- // ----- Look for real file or folder
2017
- if (file_exists($v_descr['filename'])) {
2018
- if (@is_file($v_descr['filename'])) {
2019
- $v_descr['type'] = 'file';
2020
- }
2021
- else if (@is_dir($v_descr['filename'])) {
2022
- $v_descr['type'] = 'folder';
2023
- }
2024
- else if (@is_link($v_descr['filename'])) {
2025
- // skip
2026
- continue;
2027
- }
2028
- else {
2029
- // skip
2030
- continue;
2031
- }
2032
- }
2033
-
2034
- // ----- Look for string added as file
2035
- else if (isset($v_descr['content'])) {
2036
- $v_descr['type'] = 'virtual_file';
2037
- }
2038
-
2039
- // ----- Missing file
2040
- else {
2041
- // ----- Error log
2042
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2043
-
2044
- // ----- Return
2045
- return PclZip::errorCode();
2046
- }
2047
-
2048
- // ----- Calculate the stored filename
2049
- $this->privCalculateStoredFilename($v_descr, $p_options);
2050
-
2051
- // ----- Add the descriptor in result list
2052
- $v_result_list[sizeof($v_result_list)] = $v_descr;
2053
-
2054
- // ----- Look for folder
2055
- if ($v_descr['type'] == 'folder') {
2056
- // ----- List of items in folder
2057
- $v_dirlist_descr = array();
2058
- $v_dirlist_nb = 0;
2059
- if ($v_folder_handler = @opendir($v_descr['filename'])) {
2060
- while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2061
-
2062
- // ----- Skip '.' and '..'
2063
- if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2064
- continue;
2065
- }
2066
-
2067
- // ----- Compose the full filename
2068
- $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2069
-
2070
- // ----- Look for different stored filename
2071
- // Because the name of the folder was changed, the name of the
2072
- // files/sub-folders also change
2073
- if (($v_descr['stored_filename'] != $v_descr['filename'])
2074
- && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2075
- if ($v_descr['stored_filename'] != '') {
2076
- $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2077
- }
2078
- else {
2079
- $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2080
- }
2081
- }
2082
-
2083
- $v_dirlist_nb++;
2084
- }
2085
-
2086
- @closedir($v_folder_handler);
2087
- }
2088
- else {
2089
- // TBC : unable to open folder in read mode
2090
- }
2091
-
2092
- // ----- Expand each element of the list
2093
- if ($v_dirlist_nb != 0) {
2094
- // ----- Expand
2095
- if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2096
- return $v_result;
2097
- }
2098
-
2099
- // ----- Concat the resulting list
2100
- $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2101
- }
2102
- else {
2103
- }
2104
-
2105
- // ----- Free local array
2106
- unset($v_dirlist_descr);
2107
- }
2108
- }
2109
-
2110
- // ----- Get the result list
2111
- $p_filedescr_list = $v_result_list;
2112
-
2113
- // ----- Return
2114
- return $v_result;
2115
- }
2116
- // --------------------------------------------------------------------------------
2117
-
2118
- // --------------------------------------------------------------------------------
2119
- // Function : privCreate()
2120
- // Description :
2121
- // Parameters :
2122
- // Return Values :
2123
- // --------------------------------------------------------------------------------
2124
- function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2125
- {
2126
- $v_result=1;
2127
- $v_list_detail = array();
2128
-
2129
- // ----- Magic quotes trick
2130
- $this->privDisableMagicQuotes();
2131
-
2132
- // ----- Open the file in write mode
2133
- if (($v_result = $this->privOpenFd('wb')) != 1)
2134
- {
2135
- // ----- Return
2136
- return $v_result;
2137
- }
2138
-
2139
- // ----- Add the list of files
2140
- $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
2141
-
2142
- // ----- Close
2143
- $this->privCloseFd();
2144
-
2145
- // ----- Magic quotes trick
2146
- $this->privSwapBackMagicQuotes();
2147
-
2148
- // ----- Return
2149
- return $v_result;
2150
- }
2151
- // --------------------------------------------------------------------------------
2152
-
2153
- // --------------------------------------------------------------------------------
2154
- // Function : privAdd()
2155
- // Description :
2156
- // Parameters :
2157
- // Return Values :
2158
- // --------------------------------------------------------------------------------
2159
- function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2160
- {
2161
- $v_result=1;
2162
- $v_list_detail = array();
2163
-
2164
- // ----- Look if the archive exists or is empty
2165
- if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2166
- {
2167
-
2168
- // ----- Do a create
2169
- $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2170
-
2171
- // ----- Return
2172
- return $v_result;
2173
- }
2174
- // ----- Magic quotes trick
2175
- $this->privDisableMagicQuotes();
2176
-
2177
- // ----- Open the zip file
2178
- if (($v_result=$this->privOpenFd('rb')) != 1)
2179
- {
2180
- // ----- Magic quotes trick
2181
- $this->privSwapBackMagicQuotes();
2182
-
2183
- // ----- Return
2184
- return $v_result;
2185
- }
2186
-
2187
- // ----- Read the central directory informations
2188
- $v_central_dir = array();
2189
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2190
- {
2191
- $this->privCloseFd();
2192
- $this->privSwapBackMagicQuotes();
2193
- return $v_result;
2194
- }
2195
-
2196
- // ----- Go to beginning of File
2197
- @rewind($this->zip_fd);
2198
-
2199
- // ----- Creates a temporay file
2200
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2201
-
2202
- // ----- Open the temporary file in write mode
2203
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2204
- {
2205
- $this->privCloseFd();
2206
- $this->privSwapBackMagicQuotes();
2207
-
2208
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2209
-
2210
- // ----- Return
2211
- return PclZip::errorCode();
2212
- }
2213
-
2214
- // ----- Copy the files from the archive to the temporary file
2215
- // TBC : Here I should better append the file and go back to erase the central dir
2216
- $v_size = $v_central_dir['offset'];
2217
- while ($v_size != 0)
2218
- {
2219
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2220
- $v_buffer = fread($this->zip_fd, $v_read_size);
2221
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2222
- $v_size -= $v_read_size;
2223
- }
2224
-
2225
- // ----- Swap the file descriptor
2226
- // Here is a trick : I swap the temporary fd with the zip fd, in order to use
2227
- // the following methods on the temporary fil and not the real archive
2228
- $v_swap = $this->zip_fd;
2229
- $this->zip_fd = $v_zip_temp_fd;
2230
- $v_zip_temp_fd = $v_swap;
2231
-
2232
- // ----- Add the files
2233
- $v_header_list = array();
2234
- if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2235
- {
2236
- fclose($v_zip_temp_fd);
2237
- $this->privCloseFd();
2238
- @unlink($v_zip_temp_name);
2239
- $this->privSwapBackMagicQuotes();
2240
-
2241
- // ----- Return
2242
- return $v_result;
2243
- }
2244
-
2245
- // ----- Store the offset of the central dir
2246
- $v_offset = @ftell($this->zip_fd);
2247
-
2248
- // ----- Copy the block of file headers from the old archive
2249
- $v_size = $v_central_dir['size'];
2250
- while ($v_size != 0)
2251
- {
2252
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2253
- $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2254
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2255
- $v_size -= $v_read_size;
2256
- }
2257
-
2258
- // ----- Create the Central Dir files header
2259
- for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2260
- {
2261
- // ----- Create the file header
2262
- if ($v_header_list[$i]['status'] == 'ok') {
2263
- if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2264
- fclose($v_zip_temp_fd);
2265
- $this->privCloseFd();
2266
- @unlink($v_zip_temp_name);
2267
- $this->privSwapBackMagicQuotes();
2268
-
2269
- // ----- Return
2270
- return $v_result;
2271
- }
2272
- $v_count++;
2273
- }
2274
-
2275
- // ----- Transform the header to a 'usable' info
2276
- $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2277
- }
2278
-
2279
- // ----- Zip file comment
2280
- $v_comment = $v_central_dir['comment'];
2281
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2282
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2283
- }
2284
- if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2285
- $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2286
- }
2287
- if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2288
- $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2289
- }
2290
-
2291
- // ----- Calculate the size of the central header
2292
- $v_size = @ftell($this->zip_fd)-$v_offset;
2293
-
2294
- // ----- Create the central dir footer
2295
- if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2296
- {
2297
- // ----- Reset the file list
2298
- unset($v_header_list);
2299
- $this->privSwapBackMagicQuotes();
2300
-
2301
- // ----- Return
2302
- return $v_result;
2303
- }
2304
-
2305
- // ----- Swap back the file descriptor
2306
- $v_swap = $this->zip_fd;
2307
- $this->zip_fd = $v_zip_temp_fd;
2308
- $v_zip_temp_fd = $v_swap;
2309
-
2310
- // ----- Close
2311
- $this->privCloseFd();
2312
-
2313
- // ----- Close the temporary file
2314
- @fclose($v_zip_temp_fd);
2315
-
2316
- // ----- Magic quotes trick
2317
- $this->privSwapBackMagicQuotes();
2318
-
2319
- // ----- Delete the zip file
2320
- // TBC : I should test the result ...
2321
- @unlink($this->zipname);
2322
-
2323
- // ----- Rename the temporary file
2324
- // TBC : I should test the result ...
2325
- //@rename($v_zip_temp_name, $this->zipname);
2326
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
2327
-
2328
- // ----- Return
2329
- return $v_result;
2330
- }
2331
- // --------------------------------------------------------------------------------
2332
-
2333
- // --------------------------------------------------------------------------------
2334
- // Function : privOpenFd()
2335
- // Description :
2336
- // Parameters :
2337
- // --------------------------------------------------------------------------------
2338
- function privOpenFd($p_mode)
2339
- {
2340
- $v_result=1;
2341
-
2342
- // ----- Look if already open
2343
- if ($this->zip_fd != 0)
2344
- {
2345
- // ----- Error log
2346
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2347
-
2348
- // ----- Return
2349
- return PclZip::errorCode();
2350
- }
2351
-
2352
- // ----- Open the zip file
2353
- if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2354
- {
2355
- // ----- Error log
2356
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2357
-
2358
- // ----- Return
2359
- return PclZip::errorCode();
2360
- }
2361
-
2362
- // ----- Return
2363
- return $v_result;
2364
- }
2365
- // --------------------------------------------------------------------------------
2366
-
2367
- // --------------------------------------------------------------------------------
2368
- // Function : privCloseFd()
2369
- // Description :
2370
- // Parameters :
2371
- // --------------------------------------------------------------------------------
2372
- function privCloseFd()
2373
- {
2374
- $v_result=1;
2375
-
2376
- if ($this->zip_fd != 0)
2377
- @fclose($this->zip_fd);
2378
- $this->zip_fd = 0;
2379
-
2380
- // ----- Return
2381
- return $v_result;
2382
- }
2383
- // --------------------------------------------------------------------------------
2384
-
2385
- // --------------------------------------------------------------------------------
2386
- // Function : privAddList()
2387
- // Description :
2388
- // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
2389
- // different from the real path of the file. This is usefull if you want to have PclTar
2390
- // running in any directory, and memorize relative path from an other directory.
2391
- // Parameters :
2392
- // $p_list : An array containing the file or directory names to add in the tar
2393
- // $p_result_list : list of added files with their properties (specially the status field)
2394
- // $p_add_dir : Path to add in the filename path archived
2395
- // $p_remove_dir : Path to remove in the filename path archived
2396
- // Return Values :
2397
- // --------------------------------------------------------------------------------
2398
- // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2399
- function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2400
- {
2401
- $v_result=1;
2402
-
2403
- // ----- Add the files
2404
- $v_header_list = array();
2405
- if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2406
- {
2407
- // ----- Return
2408
- return $v_result;
2409
- }
2410
-
2411
- // ----- Store the offset of the central dir
2412
- $v_offset = @ftell($this->zip_fd);
2413
-
2414
- // ----- Create the Central Dir files header
2415
- for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2416
- {
2417
- // ----- Create the file header
2418
- if ($v_header_list[$i]['status'] == 'ok') {
2419
- if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2420
- // ----- Return
2421
- return $v_result;
2422
- }
2423
- $v_count++;
2424
- }
2425
-
2426
- // ----- Transform the header to a 'usable' info
2427
- $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2428
- }
2429
-
2430
- // ----- Zip file comment
2431
- $v_comment = '';
2432
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2433
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2434
- }
2435
-
2436
- // ----- Calculate the size of the central header
2437
- $v_size = @ftell($this->zip_fd)-$v_offset;
2438
-
2439
- // ----- Create the central dir footer
2440
- if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2441
- {
2442
- // ----- Reset the file list
2443
- unset($v_header_list);
2444
-
2445
- // ----- Return
2446
- return $v_result;
2447
- }
2448
-
2449
- // ----- Return
2450
- return $v_result;
2451
- }
2452
- // --------------------------------------------------------------------------------
2453
-
2454
- // --------------------------------------------------------------------------------
2455
- // Function : privAddFileList()
2456
- // Description :
2457
- // Parameters :
2458
- // $p_filedescr_list : An array containing the file description
2459
- // or directory names to add in the zip
2460
- // $p_result_list : list of added files with their properties (specially the status field)
2461
- // Return Values :
2462
- // --------------------------------------------------------------------------------
2463
- function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2464
- {
2465
- $v_result=1;
2466
- $v_header = array();
2467
-
2468
- // ----- Recuperate the current number of elt in list
2469
- $v_nb = sizeof($p_result_list);
2470
-
2471
- // ----- Loop on the files
2472
- for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2473
- // ----- Format the filename
2474
- $p_filedescr_list[$j]['filename']
2475
- = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2476
-
2477
-
2478
- // ----- Skip empty file names
2479
- // TBC : Can this be possible ? not checked in DescrParseAtt ?
2480
- if ($p_filedescr_list[$j]['filename'] == "") {
2481
- continue;
2482
- }
2483
-
2484
- // ----- Check the filename
2485
- if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
2486
- && (!file_exists($p_filedescr_list[$j]['filename']))) {
2487
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2488
- return PclZip::errorCode();
2489
- }
2490
-
2491
- // ----- Look if it is a file or a dir with no all path remove option
2492
- // or a dir with all its path removed
2493
- // if ( (is_file($p_filedescr_list[$j]['filename']))
2494
- // || ( is_dir($p_filedescr_list[$j]['filename'])
2495
- if ( ($p_filedescr_list[$j]['type'] == 'file')
2496
- || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2497
- || ( ($p_filedescr_list[$j]['type'] == 'folder')
2498
- && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2499
- || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2500
- ) {
2501
-
2502
- // ----- Add the file
2503
- $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2504
- $p_options);
2505
- if ($v_result != 1) {
2506
- return $v_result;
2507
- }
2508
-
2509
- // ----- Store the file infos
2510
- $p_result_list[$v_nb++] = $v_header;
2511
- }
2512
- }
2513
-
2514
- // ----- Return
2515
- return $v_result;
2516
- }
2517
- // --------------------------------------------------------------------------------
2518
-
2519
- // --------------------------------------------------------------------------------
2520
- // Function : privAddFile()
2521
- // Description :
2522
- // Parameters :
2523
- // Return Values :
2524
- // --------------------------------------------------------------------------------
2525
- function privAddFile($p_filedescr, &$p_header, &$p_options)
2526
- {
2527
- $v_result=1;
2528
-
2529
- // ----- Working variable
2530
- $p_filename = $p_filedescr['filename'];
2531
-
2532
- // TBC : Already done in the fileAtt check ... ?
2533
- if ($p_filename == "") {
2534
- // ----- Error log
2535
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2536
-
2537
- // ----- Return
2538
- return PclZip::errorCode();
2539
- }
2540
-
2541
- // ----- Look for a stored different filename
2542
- /* TBC : Removed
2543
- if (isset($p_filedescr['stored_filename'])) {
2544
- $v_stored_filename = $p_filedescr['stored_filename'];
2545
- }
2546
- else {
2547
- $v_stored_filename = $p_filedescr['stored_filename'];
2548
- }
2549
- */
2550
-
2551
- // ----- Set the file properties
2552
- clearstatcache();
2553
- $p_header['version'] = 20;
2554
- $p_header['version_extracted'] = 10;
2555
- $p_header['flag'] = 0;
2556
- $p_header['compression'] = 0;
2557
- $p_header['crc'] = 0;
2558
- $p_header['compressed_size'] = 0;
2559
- $p_header['filename_len'] = strlen($p_filename);
2560
- $p_header['extra_len'] = 0;
2561
- $p_header['disk'] = 0;
2562
- $p_header['internal'] = 0;
2563
- $p_header['offset'] = 0;
2564
- $p_header['filename'] = $p_filename;
2565
- // TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
2566
- $p_header['stored_filename'] = $p_filedescr['stored_filename'];
2567
- $p_header['extra'] = '';
2568
- $p_header['status'] = 'ok';
2569
- $p_header['index'] = -1;
2570
-
2571
- // ----- Look for regular file
2572
- if ($p_filedescr['type']=='file') {
2573
- $p_header['external'] = 0x00000000;
2574
- $p_header['size'] = filesize($p_filename);
2575
- }
2576
-
2577
- // ----- Look for regular folder
2578
- else if ($p_filedescr['type']=='folder') {
2579
- $p_header['external'] = 0x00000010;
2580
- $p_header['mtime'] = filemtime($p_filename);
2581
- $p_header['size'] = filesize($p_filename);
2582
- }
2583
-
2584
- // ----- Look for virtual file
2585
- else if ($p_filedescr['type'] == 'virtual_file') {
2586
- $p_header['external'] = 0x00000000;
2587
- $p_header['size'] = strlen($p_filedescr['content']);
2588
- }
2589
-
2590
-
2591
- // ----- Look for filetime
2592
- if (isset($p_filedescr['mtime'])) {
2593
- $p_header['mtime'] = $p_filedescr['mtime'];
2594
- }
2595
- else if ($p_filedescr['type'] == 'virtual_file') {
2596
- $p_header['mtime'] = time();
2597
- }
2598
- else {
2599
- $p_header['mtime'] = filemtime($p_filename);
2600
- }
2601
-
2602
- // ------ Look for file comment
2603
- if (isset($p_filedescr['comment'])) {
2604
- $p_header['comment_len'] = strlen($p_filedescr['comment']);
2605
- $p_header['comment'] = $p_filedescr['comment'];
2606
- }
2607
- else {
2608
- $p_header['comment_len'] = 0;
2609
- $p_header['comment'] = '';
2610
- }
2611
-
2612
- // ----- Look for pre-add callback
2613
- if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2614
-
2615
- // ----- Generate a local information
2616
- $v_local_header = array();
2617
- $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2618
-
2619
- // ----- Call the callback
2620
- // Here I do not use call_user_func() because I need to send a reference to the
2621
- // header.
2622
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
2623
- $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2624
- if ($v_result == 0) {
2625
- // ----- Change the file status
2626
- $p_header['status'] = "skipped";
2627
- $v_result = 1;
2628
- }
2629
-
2630
- // ----- Update the informations
2631
- // Only some fields can be modified
2632
- if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2633
- $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2634
- }
2635
- }
2636
-
2637
- // ----- Look for empty stored filename
2638
- if ($p_header['stored_filename'] == "") {
2639
- $p_header['status'] = "filtered";
2640
- }
2641
-
2642
- // ----- Check the path length
2643
- if (strlen($p_header['stored_filename']) > 0xFF) {
2644
- $p_header['status'] = 'filename_too_long';
2645
- }
2646
-
2647
- // ----- Look if no error, or file not skipped
2648
- if ($p_header['status'] == 'ok') {
2649
-
2650
- // ----- Look for a file
2651
- if ($p_filedescr['type'] == 'file') {
2652
- // ----- Look for using temporary file to zip
2653
- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2654
- && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2655
- || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2656
- && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2657
- $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2658
- if ($v_result < PCLZIP_ERR_NO_ERROR) {
2659
- return $v_result;
2660
- }
2661
- }
2662
-
2663
- // ----- Use "in memory" zip algo
2664
- else {
2665
-
2666
- // ----- Open the source file
2667
- if (($v_file = @fopen($p_filename, "rb")) == 0) {
2668
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2669
- return PclZip::errorCode();
2670
- }
2671
-
2672
- // ----- Read the file content
2673
- $v_content = @fread($v_file, $p_header['size']);
2674
-
2675
- // ----- Close the file
2676
- @fclose($v_file);
2677
-
2678
- // ----- Calculate the CRC
2679
- $p_header['crc'] = @crc32($v_content);
2680
-
2681
- // ----- Look for no compression
2682
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2683
- // ----- Set header parameters
2684
- $p_header['compressed_size'] = $p_header['size'];
2685
- $p_header['compression'] = 0;
2686
- }
2687
-
2688
- // ----- Look for normal compression
2689
- else {
2690
- // ----- Compress the content
2691
- $v_content = @gzdeflate($v_content);
2692
-
2693
- // ----- Set header parameters
2694
- $p_header['compressed_size'] = strlen($v_content);
2695
- $p_header['compression'] = 8;
2696
- }
2697
-
2698
- // ----- Call the header generation
2699
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2700
- @fclose($v_file);
2701
- return $v_result;
2702
- }
2703
-
2704
- // ----- Write the compressed (or not) content
2705
- @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2706
-
2707
- }
2708
-
2709
- }
2710
-
2711
- // ----- Look for a virtual file (a file from string)
2712
- else if ($p_filedescr['type'] == 'virtual_file') {
2713
-
2714
- $v_content = $p_filedescr['content'];
2715
-
2716
- // ----- Calculate the CRC
2717
- $p_header['crc'] = @crc32($v_content);
2718
-
2719
- // ----- Look for no compression
2720
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2721
- // ----- Set header parameters
2722
- $p_header['compressed_size'] = $p_header['size'];
2723
- $p_header['compression'] = 0;
2724
- }
2725
-
2726
- // ----- Look for normal compression
2727
- else {
2728
- // ----- Compress the content
2729
- $v_content = @gzdeflate($v_content);
2730
-
2731
- // ----- Set header parameters
2732
- $p_header['compressed_size'] = strlen($v_content);
2733
- $p_header['compression'] = 8;
2734
- }
2735
-
2736
- // ----- Call the header generation
2737
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2738
- @fclose($v_file);
2739
- return $v_result;
2740
- }
2741
-
2742
- // ----- Write the compressed (or not) content
2743
- @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2744
- }
2745
-
2746
- // ----- Look for a directory
2747
- else if ($p_filedescr['type'] == 'folder') {
2748
- // ----- Look for directory last '/'
2749
- if (@substr($p_header['stored_filename'], -1) != '/') {
2750
- $p_header['stored_filename'] .= '/';
2751
- }
2752
-
2753
- // ----- Set the file properties
2754
- $p_header['size'] = 0;
2755
- //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
2756
- $p_header['external'] = 0x00000010; // Value for a folder : to be checked
2757
-
2758
- // ----- Call the header generation
2759
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2760
- {
2761
- return $v_result;
2762
- }
2763
- }
2764
- }
2765
-
2766
- // ----- Look for post-add callback
2767
- if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2768
-
2769
- // ----- Generate a local information
2770
- $v_local_header = array();
2771
- $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2772
-
2773
- // ----- Call the callback
2774
- // Here I do not use call_user_func() because I need to send a reference to the
2775
- // header.
2776
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
2777
- $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2778
- if ($v_result == 0) {
2779
- // ----- Ignored
2780
- $v_result = 1;
2781
- }
2782
-
2783
- // ----- Update the informations
2784
- // Nothing can be modified
2785
- }
2786
-
2787
- // ----- Return
2788
- return $v_result;
2789
- }
2790
- // --------------------------------------------------------------------------------
2791
-
2792
- // --------------------------------------------------------------------------------
2793
- // Function : privAddFileUsingTempFile()
2794
- // Description :
2795
- // Parameters :
2796
- // Return Values :
2797
- // --------------------------------------------------------------------------------
2798
- function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2799
- {
2800
- $v_result=PCLZIP_ERR_NO_ERROR;
2801
-
2802
- // ----- Working variable
2803
- $p_filename = $p_filedescr['filename'];
2804
-
2805
-
2806
- // ----- Open the source file
2807
- if (($v_file = @fopen($p_filename, "rb")) == 0) {
2808
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2809
- return PclZip::errorCode();
2810
- }
2811
-
2812
- // ----- Creates a compressed temporary file
2813
- $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2814
- if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2815
- fclose($v_file);
2816
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2817
- return PclZip::errorCode();
2818
- }
2819
-
2820
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2821
- $v_size = filesize($p_filename);
2822
- while ($v_size != 0) {
2823
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2824
- $v_buffer = @fread($v_file, $v_read_size);
2825
- //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2826
- @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2827
- $v_size -= $v_read_size;
2828
- }
2829
-
2830
- // ----- Close the file
2831
- @fclose($v_file);
2832
- @gzclose($v_file_compressed);
2833
-
2834
- // ----- Check the minimum file size
2835
- if (filesize($v_gzip_temp_name) < 18) {
2836
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2837
- return PclZip::errorCode();
2838
- }
2839
-
2840
- // ----- Extract the compressed attributes
2841
- if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2842
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2843
- return PclZip::errorCode();
2844
- }
2845
-
2846
- // ----- Read the gzip file header
2847
- $v_binary_data = @fread($v_file_compressed, 10);
2848
- $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
2849
-
2850
- // ----- Check some parameters
2851
- $v_data_header['os'] = bin2hex($v_data_header['os']);
2852
-
2853
- // ----- Read the gzip file footer
2854
- @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2855
- $v_binary_data = @fread($v_file_compressed, 8);
2856
- $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2857
-
2858
- // ----- Set the attributes
2859
- $p_header['compression'] = ord($v_data_header['cm']);
2860
- //$p_header['mtime'] = $v_data_header['mtime'];
2861
- $p_header['crc'] = $v_data_footer['crc'];
2862
- $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2863
-
2864
- // ----- Close the file
2865
- @fclose($v_file_compressed);
2866
-
2867
- // ----- Call the header generation
2868
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2869
- return $v_result;
2870
- }
2871
-
2872
- // ----- Add the compressed data
2873
- if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2874
- {
2875
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2876
- return PclZip::errorCode();
2877
- }
2878
-
2879
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2880
- fseek($v_file_compressed, 10);
2881
- $v_size = $p_header['compressed_size'];
2882
- while ($v_size != 0)
2883
- {
2884
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2885
- $v_buffer = @fread($v_file_compressed, $v_read_size);
2886
- //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2887
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2888
- $v_size -= $v_read_size;
2889
- }
2890
-
2891
- // ----- Close the file
2892
- @fclose($v_file_compressed);
2893
-
2894
- // ----- Unlink the temporary file
2895
- @unlink($v_gzip_temp_name);
2896
-
2897
- // ----- Return
2898
- return $v_result;
2899
- }
2900
- // --------------------------------------------------------------------------------
2901
-
2902
- // --------------------------------------------------------------------------------
2903
- // Function : privCalculateStoredFilename()
2904
- // Description :
2905
- // Based on file descriptor properties and global options, this method
2906
- // calculate the filename that will be stored in the archive.
2907
- // Parameters :
2908
- // Return Values :
2909
- // --------------------------------------------------------------------------------
2910
- function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2911
- {
2912
- $v_result=1;
2913
-
2914
- // ----- Working variables
2915
- $p_filename = $p_filedescr['filename'];
2916
- if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2917
- $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2918
- }
2919
- else {
2920
- $p_add_dir = '';
2921
- }
2922
- if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2923
- $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2924
- }
2925
- else {
2926
- $p_remove_dir = '';
2927
- }
2928
- if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2929
- $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2930
- }
2931
- else {
2932
- $p_remove_all_dir = 0;
2933
- }
2934
-
2935
-
2936
- // ----- Look for full name change
2937
- if (isset($p_filedescr['new_full_name'])) {
2938
- // ----- Remove drive letter if any
2939
- $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2940
- }
2941
-
2942
- // ----- Look for path and/or short name change
2943
- else {
2944
-
2945
- // ----- Look for short name change
2946
- // Its when we cahnge just the filename but not the path
2947
- if (isset($p_filedescr['new_short_name'])) {
2948
- $v_path_info = pathinfo($p_filename);
2949
- $v_dir = '';
2950
- if ($v_path_info['dirname'] != '') {
2951
- $v_dir = $v_path_info['dirname'].'/';
2952
- }
2953
- $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2954
- }
2955
- else {
2956
- // ----- Calculate the stored filename
2957
- $v_stored_filename = $p_filename;
2958
- }
2959
-
2960
- // ----- Look for all path to remove
2961
- if ($p_remove_all_dir) {
2962
- $v_stored_filename = basename($p_filename);
2963
- }
2964
- // ----- Look for partial path remove
2965
- else if ($p_remove_dir != "") {
2966
- if (substr($p_remove_dir, -1) != '/')
2967
- $p_remove_dir .= "/";
2968
-
2969
- if ( (substr($p_filename, 0, 2) == "./")
2970
- || (substr($p_remove_dir, 0, 2) == "./")) {
2971
-
2972
- if ( (substr($p_filename, 0, 2) == "./")
2973
- && (substr($p_remove_dir, 0, 2) != "./")) {
2974
- $p_remove_dir = "./".$p_remove_dir;
2975
- }
2976
- if ( (substr($p_filename, 0, 2) != "./")
2977
- && (substr($p_remove_dir, 0, 2) == "./")) {
2978
- $p_remove_dir = substr($p_remove_dir, 2);
2979
- }
2980
- }
2981
-
2982
- $v_compare = PclZipUtilPathInclusion($p_remove_dir,
2983
- $v_stored_filename);
2984
- if ($v_compare > 0) {
2985
- if ($v_compare == 2) {
2986
- $v_stored_filename = "";
2987
- }
2988
- else {
2989
- $v_stored_filename = substr($v_stored_filename,
2990
- strlen($p_remove_dir));
2991
- }
2992
- }
2993
- }
2994
-
2995
- // ----- Remove drive letter if any
2996
- $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
2997
-
2998
- // ----- Look for path to add
2999
- if ($p_add_dir != "") {
3000
- if (substr($p_add_dir, -1) == "/")
3001
- $v_stored_filename = $p_add_dir.$v_stored_filename;
3002
- else
3003
- $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3004
- }
3005
- }
3006
-
3007
- // ----- Filename (reduce the path of stored name)
3008
- $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
3009
- $p_filedescr['stored_filename'] = $v_stored_filename;
3010
-
3011
- // ----- Return
3012
- return $v_result;
3013
- }
3014
- // --------------------------------------------------------------------------------
3015
-
3016
- // --------------------------------------------------------------------------------
3017
- // Function : privWriteFileHeader()
3018
- // Description :
3019
- // Parameters :
3020
- // Return Values :
3021
- // --------------------------------------------------------------------------------
3022
- function privWriteFileHeader(&$p_header)
3023
- {
3024
- $v_result=1;
3025
-
3026
- // ----- Store the offset position of the file
3027
- $p_header['offset'] = ftell($this->zip_fd);
3028
-
3029
- // ----- Transform UNIX mtime to DOS format mdate/mtime
3030
- $v_date = getdate($p_header['mtime']);
3031
- $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3032
- $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3033
-
3034
- // ----- Packed data
3035
- $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3036
- $p_header['version_extracted'], $p_header['flag'],
3037
- $p_header['compression'], $v_mtime, $v_mdate,
3038
- $p_header['crc'], $p_header['compressed_size'],
3039
- $p_header['size'],
3040
- strlen($p_header['stored_filename']),
3041
- $p_header['extra_len']);
3042
-
3043
- // ----- Write the first 148 bytes of the header in the archive
3044
- fputs($this->zip_fd, $v_binary_data, 30);
3045
-
3046
- // ----- Write the variable fields
3047
- if (strlen($p_header['stored_filename']) != 0)
3048
- {
3049
- fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3050
- }
3051
- if ($p_header['extra_len'] != 0)
3052
- {
3053
- fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3054
- }
3055
-
3056
- // ----- Return
3057
- return $v_result;
3058
- }
3059
- // --------------------------------------------------------------------------------
3060
-
3061
- // --------------------------------------------------------------------------------
3062
- // Function : privWriteCentralFileHeader()
3063
- // Description :
3064
- // Parameters :
3065
- // Return Values :
3066
- // --------------------------------------------------------------------------------
3067
- function privWriteCentralFileHeader(&$p_header)
3068
- {
3069
- $v_result=1;
3070
-
3071
- // TBC
3072
- //for(reset($p_header); $key = key($p_header); next($p_header)) {
3073
- //}
3074
-
3075
- // ----- Transform UNIX mtime to DOS format mdate/mtime
3076
- $v_date = getdate($p_header['mtime']);
3077
- $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3078
- $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3079
-
3080
-
3081
- // ----- Packed data
3082
- $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3083
- $p_header['version'], $p_header['version_extracted'],
3084
- $p_header['flag'], $p_header['compression'],
3085
- $v_mtime, $v_mdate, $p_header['crc'],
3086
- $p_header['compressed_size'], $p_header['size'],
3087
- strlen($p_header['stored_filename']),
3088
- $p_header['extra_len'], $p_header['comment_len'],
3089
- $p_header['disk'], $p_header['internal'],
3090
- $p_header['external'], $p_header['offset']);
3091
-
3092
- // ----- Write the 42 bytes of the header in the zip file
3093
- fputs($this->zip_fd, $v_binary_data, 46);
3094
-
3095
- // ----- Write the variable fields
3096
- if (strlen($p_header['stored_filename']) != 0)
3097
- {
3098
- fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3099
- }
3100
- if ($p_header['extra_len'] != 0)
3101
- {
3102
- fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3103
- }
3104
- if ($p_header['comment_len'] != 0)
3105
- {
3106
- fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3107
- }
3108
-
3109
- // ----- Return
3110
- return $v_result;
3111
- }
3112
- // --------------------------------------------------------------------------------
3113
-
3114
- // --------------------------------------------------------------------------------
3115
- // Function : privWriteCentralHeader()
3116
- // Description :
3117
- // Parameters :
3118
- // Return Values :
3119
- // --------------------------------------------------------------------------------
3120
- function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3121
- {
3122
- $v_result=1;
3123
-
3124
- // ----- Packed data
3125
- $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3126
- $p_nb_entries, $p_size,
3127
- $p_offset, strlen($p_comment));
3128
-
3129
- // ----- Write the 22 bytes of the header in the zip file
3130
- fputs($this->zip_fd, $v_binary_data, 22);
3131
-
3132
- // ----- Write the variable fields
3133
- if (strlen($p_comment) != 0)
3134
- {
3135
- fputs($this->zip_fd, $p_comment, strlen($p_comment));
3136
- }
3137
-
3138
- // ----- Return
3139
- return $v_result;
3140
- }
3141
- // --------------------------------------------------------------------------------
3142
-
3143
- // --------------------------------------------------------------------------------
3144
- // Function : privList()
3145
- // Description :
3146
- // Parameters :
3147
- // Return Values :
3148
- // --------------------------------------------------------------------------------
3149
- function privList(&$p_list)
3150
- {
3151
- $v_result=1;
3152
-
3153
- // ----- Magic quotes trick
3154
- $this->privDisableMagicQuotes();
3155
-
3156
- // ----- Open the zip file
3157
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3158
- {
3159
- // ----- Magic quotes trick
3160
- $this->privSwapBackMagicQuotes();
3161
-
3162
- // ----- Error log
3163
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3164
-
3165
- // ----- Return
3166
- return PclZip::errorCode();
3167
- }
3168
-
3169
- // ----- Read the central directory informations
3170
- $v_central_dir = array();
3171
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3172
- {
3173
- $this->privSwapBackMagicQuotes();
3174
- return $v_result;
3175
- }
3176
-
3177
- // ----- Go to beginning of Central Dir
3178
- @rewind($this->zip_fd);
3179
- if (@fseek($this->zip_fd, $v_central_dir['offset']))
3180
- {
3181
- $this->privSwapBackMagicQuotes();
3182
-
3183
- // ----- Error log
3184
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3185
-
3186
- // ----- Return
3187
- return PclZip::errorCode();
3188
- }
3189
-
3190
- // ----- Read each entry
3191
- for ($i=0; $i<$v_central_dir['entries']; $i++)
3192
- {
3193
- // ----- Read the file header
3194
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3195
- {
3196
- $this->privSwapBackMagicQuotes();
3197
- return $v_result;
3198
- }
3199
- $v_header['index'] = $i;
3200
-
3201
- // ----- Get the only interesting attributes
3202
- $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3203
- unset($v_header);
3204
- }
3205
-
3206
- // ----- Close the zip file
3207
- $this->privCloseFd();
3208
-
3209
- // ----- Magic quotes trick
3210
- $this->privSwapBackMagicQuotes();
3211
-
3212
- // ----- Return
3213
- return $v_result;
3214
- }
3215
- // --------------------------------------------------------------------------------
3216
-
3217
- // --------------------------------------------------------------------------------
3218
- // Function : privConvertHeader2FileInfo()
3219
- // Description :
3220
- // This function takes the file informations from the central directory
3221
- // entries and extract the interesting parameters that will be given back.
3222
- // The resulting file infos are set in the array $p_info
3223
- // $p_info['filename'] : Filename with full path. Given by user (add),
3224
- // extracted in the filesystem (extract).
3225
- // $p_info['stored_filename'] : Stored filename in the archive.
3226
- // $p_info['size'] = Size of the file.
3227
- // $p_info['compressed_size'] = Compressed size of the file.
3228
- // $p_info['mtime'] = Last modification date of the file.
3229
- // $p_info['comment'] = Comment associated with the file.
3230
- // $p_info['folder'] = true/false : indicates if the entry is a folder or not.
3231
- // $p_info['status'] = status of the action on the file.
3232
- // $p_info['crc'] = CRC of the file content.
3233
- // Parameters :
3234
- // Return Values :
3235
- // --------------------------------------------------------------------------------
3236
- function privConvertHeader2FileInfo($p_header, &$p_info)
3237
- {
3238
- $v_result=1;
3239
-
3240
- // ----- Get the interesting attributes
3241
- $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
3242
- $p_info['filename'] = $v_temp_path;
3243
- $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
3244
- $p_info['stored_filename'] = $v_temp_path;
3245
- $p_info['size'] = $p_header['size'];
3246
- $p_info['compressed_size'] = $p_header['compressed_size'];
3247
- $p_info['mtime'] = $p_header['mtime'];
3248
- $p_info['comment'] = $p_header['comment'];
3249
- $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3250
- $p_info['index'] = $p_header['index'];
3251
- $p_info['status'] = $p_header['status'];
3252
- $p_info['crc'] = $p_header['crc'];
3253
-
3254
- // ----- Return
3255
- return $v_result;
3256
- }
3257
- // --------------------------------------------------------------------------------
3258
-
3259
- // --------------------------------------------------------------------------------
3260
- // Function : privExtractByRule()
3261
- // Description :
3262
- // Extract a file or directory depending of rules (by index, by name, ...)
3263
- // Parameters :
3264
- // $p_file_list : An array where will be placed the properties of each
3265
- // extracted file
3266
- // $p_path : Path to add while writing the extracted files
3267
- // $p_remove_path : Path to remove (from the file memorized path) while writing the
3268
- // extracted files. If the path does not match the file path,
3269
- // the file is extracted with its memorized path.
3270
- // $p_remove_path does not apply to 'list' mode.
3271
- // $p_path and $p_remove_path are commulative.
3272
- // Return Values :
3273
- // 1 on success,0 or less on error (see error code list)
3274
- // --------------------------------------------------------------------------------
3275
- function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3276
- {
3277
- $v_result=1;
3278
-
3279
- // ----- Magic quotes trick
3280
- $this->privDisableMagicQuotes();
3281
-
3282
- // ----- Check the path
3283
- if ( ($p_path == "")
3284
- || ( (substr($p_path, 0, 1) != "/")
3285
- && (substr($p_path, 0, 3) != "../")
3286
- && (substr($p_path,1,2)!=":/")))
3287
- $p_path = "./".$p_path;
3288
-
3289
- // ----- Reduce the path last (and duplicated) '/'
3290
- if (($p_path != "./") && ($p_path != "/"))
3291
- {
3292
- // ----- Look for the path end '/'
3293
- while (substr($p_path, -1) == "/")
3294
- {
3295
- $p_path = substr($p_path, 0, strlen($p_path)-1);
3296
- }
3297
- }
3298
-
3299
- // ----- Look for path to remove format (should end by /)
3300
- if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3301
- {
3302
- $p_remove_path .= '/';
3303
- }
3304
- $p_remove_path_size = strlen($p_remove_path);
3305
-
3306
- // ----- Open the zip file
3307
- if (($v_result = $this->privOpenFd('rb')) != 1)
3308
- {
3309
- $this->privSwapBackMagicQuotes();
3310
- return $v_result;
3311
- }
3312
-
3313
- // ----- Read the central directory informations
3314
- $v_central_dir = array();
3315
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3316
- {
3317
- // ----- Close the zip file
3318
- $this->privCloseFd();
3319
- $this->privSwapBackMagicQuotes();
3320
-
3321
- return $v_result;
3322
- }
3323
-
3324
- // ----- Start at beginning of Central Dir
3325
- $v_pos_entry = $v_central_dir['offset'];
3326
-
3327
- // ----- Read each entry
3328
- $j_start = 0;
3329
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3330
- {
3331
-
3332
- // ----- Read next Central dir entry
3333
- @rewind($this->zip_fd);
3334
- if (@fseek($this->zip_fd, $v_pos_entry))
3335
- {
3336
- // ----- Close the zip file
3337
- $this->privCloseFd();
3338
- $this->privSwapBackMagicQuotes();
3339
-
3340
- // ----- Error log
3341
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3342
-
3343
- // ----- Return
3344
- return PclZip::errorCode();
3345
- }
3346
-
3347
- // ----- Read the file header
3348
- $v_header = array();
3349
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3350
- {
3351
- // ----- Close the zip file
3352
- $this->privCloseFd();
3353
- $this->privSwapBackMagicQuotes();
3354
-
3355
- return $v_result;
3356
- }
3357
-
3358
- // ----- Store the index
3359
- $v_header['index'] = $i;
3360
-
3361
- // ----- Store the file position
3362
- $v_pos_entry = ftell($this->zip_fd);
3363
-
3364
- // ----- Look for the specific extract rules
3365
- $v_extract = false;
3366
-
3367
- // ----- Look for extract by name rule
3368
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
3369
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3370
-
3371
- // ----- Look if the filename is in the list
3372
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3373
-
3374
- // ----- Look for a directory
3375
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3376
-
3377
- // ----- Look if the directory is in the filename path
3378
- if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3379
- && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3380
- $v_extract = true;
3381
- }
3382
- }
3383
- // ----- Look for a filename
3384
- elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3385
- $v_extract = true;
3386
- }
3387
- }
3388
- }
3389
-
3390
- // ----- Look for extract by ereg rule
3391
- // ereg() is deprecated with PHP 5.3
3392
- /*
3393
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
3394
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3395
-
3396
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
3397
- $v_extract = true;
3398
- }
3399
- }
3400
- */
3401
-
3402
- // ----- Look for extract by preg rule
3403
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
3404
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3405
-
3406
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3407
- $v_extract = true;
3408
- }
3409
- }
3410
-
3411
- // ----- Look for extract by index rule
3412
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3413
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3414
-
3415
- // ----- Look if the index is in the list
3416
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3417
-
3418
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3419
- $v_extract = true;
3420
- }
3421
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3422
- $j_start = $j+1;
3423
- }
3424
-
3425
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3426
- break;
3427
- }
3428
- }
3429
- }
3430
-
3431
- // ----- Look for no rule, which means extract all the archive
3432
- else {
3433
- $v_extract = true;
3434
- }
3435
-
3436
- // ----- Check compression method
3437
- if ( ($v_extract)
3438
- && ( ($v_header['compression'] != 8)
3439
- && ($v_header['compression'] != 0))) {
3440
- $v_header['status'] = 'unsupported_compression';
3441
-
3442
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3443
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3444
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3445
-
3446
- $this->privSwapBackMagicQuotes();
3447
-
3448
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3449
- "Filename '".$v_header['stored_filename']."' is "
3450
- ."compressed by an unsupported compression "
3451
- ."method (".$v_header['compression'].") ");
3452
-
3453
- return PclZip::errorCode();
3454
- }
3455
- }
3456
-
3457
- // ----- Check encrypted files
3458
- if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3459
- $v_header['status'] = 'unsupported_encryption';
3460
-
3461
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3462
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3463
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3464
-
3465
- $this->privSwapBackMagicQuotes();
3466
-
3467
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3468
- "Unsupported encryption for "
3469
- ." filename '".$v_header['stored_filename']
3470
- ."'");
3471
-
3472
- return PclZip::errorCode();
3473
- }
3474
- }
3475
-
3476
- // ----- Look for real extraction
3477
- if (($v_extract) && ($v_header['status'] != 'ok')) {
3478
- $v_result = $this->privConvertHeader2FileInfo($v_header,
3479
- $p_file_list[$v_nb_extracted++]);
3480
- if ($v_result != 1) {
3481
- $this->privCloseFd();
3482
- $this->privSwapBackMagicQuotes();
3483
- return $v_result;
3484
- }
3485
-
3486
- $v_extract = false;
3487
- }
3488
-
3489
- // ----- Look for real extraction
3490
- if ($v_extract)
3491
- {
3492
-
3493
- // ----- Go to the file position
3494
- @rewind($this->zip_fd);
3495
- if (@fseek($this->zip_fd, $v_header['offset']))
3496
- {
3497
- // ----- Close the zip file
3498
- $this->privCloseFd();
3499
-
3500
- $this->privSwapBackMagicQuotes();
3501
-
3502
- // ----- Error log
3503
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3504
-
3505
- // ----- Return
3506
- return PclZip::errorCode();
3507
- }
3508
-
3509
- // ----- Look for extraction as string
3510
- if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3511
-
3512
- $v_string = '';
3513
-
3514
- // ----- Extracting the file
3515
- $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3516
- if ($v_result1 < 1) {
3517
- $this->privCloseFd();
3518
- $this->privSwapBackMagicQuotes();
3519
- return $v_result1;
3520
- }
3521
-
3522
- // ----- Get the only interesting attributes
3523
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3524
- {
3525
- // ----- Close the zip file
3526
- $this->privCloseFd();
3527
- $this->privSwapBackMagicQuotes();
3528
-
3529
- return $v_result;
3530
- }
3531
-
3532
- // ----- Set the file content
3533
- $p_file_list[$v_nb_extracted]['content'] = $v_string;
3534
-
3535
- // ----- Next extracted file
3536
- $v_nb_extracted++;
3537
-
3538
- // ----- Look for user callback abort
3539
- if ($v_result1 == 2) {
3540
- break;
3541
- }
3542
- }
3543
- // ----- Look for extraction in standard output
3544
- elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3545
- && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3546
- // ----- Extracting the file in standard output
3547
- $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3548
- if ($v_result1 < 1) {
3549
- $this->privCloseFd();
3550
- $this->privSwapBackMagicQuotes();
3551
- return $v_result1;
3552
- }
3553
-
3554
- // ----- Get the only interesting attributes
3555
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3556
- $this->privCloseFd();
3557
- $this->privSwapBackMagicQuotes();
3558
- return $v_result;
3559
- }
3560
-
3561
- // ----- Look for user callback abort
3562
- if ($v_result1 == 2) {
3563
- break;
3564
- }
3565
- }
3566
- // ----- Look for normal extraction
3567
- else {
3568
- // ----- Extracting the file
3569
- $v_result1 = $this->privExtractFile($v_header,
3570
- $p_path, $p_remove_path,
3571
- $p_remove_all_path,
3572
- $p_options);
3573
- if ($v_result1 < 1) {
3574
- $this->privCloseFd();
3575
- $this->privSwapBackMagicQuotes();
3576
- return $v_result1;
3577
- }
3578
-
3579
- // ----- Get the only interesting attributes
3580
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3581
- {
3582
- // ----- Close the zip file
3583
- $this->privCloseFd();
3584
- $this->privSwapBackMagicQuotes();
3585
-
3586
- return $v_result;
3587
- }
3588
-
3589
- // ----- Look for user callback abort
3590
- if ($v_result1 == 2) {
3591
- break;
3592
- }
3593
- }
3594
- }
3595
- }
3596
-
3597
- // ----- Close the zip file
3598
- $this->privCloseFd();
3599
- $this->privSwapBackMagicQuotes();
3600
-
3601
- // ----- Return
3602
- return $v_result;
3603
- }
3604
- // --------------------------------------------------------------------------------
3605
-
3606
- // --------------------------------------------------------------------------------
3607
- // Function : privExtractFile()
3608
- // Description :
3609
- // Parameters :
3610
- // Return Values :
3611
- //
3612
- // 1 : ... ?
3613
- // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
3614
- // --------------------------------------------------------------------------------
3615
- function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3616
- {
3617
- $v_result=1;
3618
-
3619
- // ----- Read the file header
3620
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3621
- {
3622
- // ----- Return
3623
- return $v_result;
3624
- }
3625
-
3626
-
3627
- // ----- Check that the file header is coherent with $p_entry info
3628
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3629
- // TBC
3630
- }
3631
-
3632
- // ----- Look for all path to remove
3633
- if ($p_remove_all_path == true) {
3634
- // ----- Look for folder entry that not need to be extracted
3635
- if (($p_entry['external']&0x00000010)==0x00000010) {
3636
-
3637
- $p_entry['status'] = "filtered";
3638
-
3639
- return $v_result;
3640
- }
3641
-
3642
- // ----- Get the basename of the path
3643
- $p_entry['filename'] = basename($p_entry['filename']);
3644
- }
3645
-
3646
- // ----- Look for path to remove
3647
- else if ($p_remove_path != "")
3648
- {
3649
- if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3650
- {
3651
-
3652
- // ----- Change the file status
3653
- $p_entry['status'] = "filtered";
3654
-
3655
- // ----- Return
3656
- return $v_result;
3657
- }
3658
-
3659
- $p_remove_path_size = strlen($p_remove_path);
3660
- if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3661
- {
3662
-
3663
- // ----- Remove the path
3664
- $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3665
-
3666
- }
3667
- }
3668
-
3669
- // ----- Add the path
3670
- if ($p_path != '') {
3671
- $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3672
- }
3673
-
3674
- // ----- Check a base_dir_restriction
3675
- if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3676
- $v_inclusion
3677
- = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3678
- $p_entry['filename']);
3679
- if ($v_inclusion == 0) {
3680
-
3681
- PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3682
- "Filename '".$p_entry['filename']."' is "
3683
- ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3684
-
3685
- return PclZip::errorCode();
3686
- }
3687
- }
3688
-
3689
- // ----- Look for pre-extract callback
3690
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3691
-
3692
- // ----- Generate a local information
3693
- $v_local_header = array();
3694
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3695
-
3696
- // ----- Call the callback
3697
- // Here I do not use call_user_func() because I need to send a reference to the
3698
- // header.
3699
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3700
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3701
- if ($v_result == 0) {
3702
- // ----- Change the file status
3703
- $p_entry['status'] = "skipped";
3704
- $v_result = 1;
3705
- }
3706
-
3707
- // ----- Look for abort result
3708
- if ($v_result == 2) {
3709
- // ----- This status is internal and will be changed in 'skipped'
3710
- $p_entry['status'] = "aborted";
3711
- $v_result = PCLZIP_ERR_USER_ABORTED;
3712
- }
3713
-
3714
- // ----- Update the informations
3715
- // Only some fields can be modified
3716
- $p_entry['filename'] = $v_local_header['filename'];
3717
- }
3718
-
3719
-
3720
- // ----- Look if extraction should be done
3721
- if ($p_entry['status'] == 'ok') {
3722
-
3723
- // ----- Look for specific actions while the file exist
3724
- if (file_exists($p_entry['filename']))
3725
- {
3726
-
3727
- // ----- Look if file is a directory
3728
- if (is_dir($p_entry['filename']))
3729
- {
3730
-
3731
- // ----- Change the file status
3732
- $p_entry['status'] = "already_a_directory";
3733
-
3734
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3735
- // For historical reason first PclZip implementation does not stop
3736
- // when this kind of error occurs.
3737
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3738
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3739
-
3740
- PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3741
- "Filename '".$p_entry['filename']."' is "
3742
- ."already used by an existing directory");
3743
-
3744
- return PclZip::errorCode();
3745
- }
3746
- }
3747
- // ----- Look if file is write protected
3748
- else if (!is_writeable($p_entry['filename']))
3749
- {
3750
-
3751
- // ----- Change the file status
3752
- $p_entry['status'] = "write_protected";
3753
-
3754
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3755
- // For historical reason first PclZip implementation does not stop
3756
- // when this kind of error occurs.
3757
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3758
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3759
-
3760
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3761
- "Filename '".$p_entry['filename']."' exists "
3762
- ."and is write protected");
3763
-
3764
- return PclZip::errorCode();
3765
- }
3766
- }
3767
-
3768
- // ----- Look if the extracted file is older
3769
- else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3770
- {
3771
- // ----- Change the file status
3772
- if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3773
- && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3774
- }
3775
- else {
3776
- $p_entry['status'] = "newer_exist";
3777
-
3778
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3779
- // For historical reason first PclZip implementation does not stop
3780
- // when this kind of error occurs.
3781
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3782
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3783
-
3784
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3785
- "Newer version of '".$p_entry['filename']."' exists "
3786
- ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3787
-
3788
- return PclZip::errorCode();
3789
- }
3790
- }
3791
- }
3792
- else {
3793
- }
3794
- }
3795
-
3796
- // ----- Check the directory availability and create it if necessary
3797
- else {
3798
- if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3799
- $v_dir_to_check = $p_entry['filename'];
3800
- else if (!strstr($p_entry['filename'], "/"))
3801
- $v_dir_to_check = "";
3802
- else
3803
- $v_dir_to_check = dirname($p_entry['filename']);
3804
-
3805
- if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3806
-
3807
- // ----- Change the file status
3808
- $p_entry['status'] = "path_creation_fail";
3809
-
3810
- // ----- Return
3811
- //return $v_result;
3812
- $v_result = 1;
3813
- }
3814
- }
3815
- }
3816
-
3817
- // ----- Look if extraction should be done
3818
- if ($p_entry['status'] == 'ok') {
3819
-
3820
- // ----- Do the extraction (if not a folder)
3821
- if (!(($p_entry['external']&0x00000010)==0x00000010))
3822
- {
3823
- // ----- Look for not compressed file
3824
- if ($p_entry['compression'] == 0) {
3825
-
3826
- // ----- Opening destination file
3827
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3828
- {
3829
-
3830
- // ----- Change the file status
3831
- $p_entry['status'] = "write_error";
3832
-
3833
- // ----- Return
3834
- return $v_result;
3835
- }
3836
-
3837
-
3838
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3839
- $v_size = $p_entry['compressed_size'];
3840
- while ($v_size != 0)
3841
- {
3842
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3843
- $v_buffer = @fread($this->zip_fd, $v_read_size);
3844
- /* Try to speed up the code
3845
- $v_binary_data = pack('a'.$v_read_size, $v_buffer);
3846
- @fwrite($v_dest_file, $v_binary_data, $v_read_size);
3847
- */
3848
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
3849
- $v_size -= $v_read_size;
3850
- }
3851
-
3852
- // ----- Closing the destination file
3853
- fclose($v_dest_file);
3854
-
3855
- // ----- Change the file mtime
3856
- touch($p_entry['filename'], $p_entry['mtime']);
3857
-
3858
-
3859
- }
3860
- else {
3861
- // ----- TBC
3862
- // Need to be finished
3863
- if (($p_entry['flag'] & 1) == 1) {
3864
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3865
- return PclZip::errorCode();
3866
- }
3867
-
3868
-
3869
- // ----- Look for using temporary file to unzip
3870
- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3871
- && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3872
- || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3873
- && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3874
- $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3875
- if ($v_result < PCLZIP_ERR_NO_ERROR) {
3876
- return $v_result;
3877
- }
3878
- }
3879
-
3880
- // ----- Look for extract in memory
3881
- else {
3882
-
3883
-
3884
- // ----- Read the compressed file in a buffer (one shot)
3885
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3886
-
3887
- // ----- Decompress the file
3888
- $v_file_content = @gzinflate($v_buffer);
3889
- unset($v_buffer);
3890
- if ($v_file_content === FALSE) {
3891
-
3892
- // ----- Change the file status
3893
- // TBC
3894
- $p_entry['status'] = "error";
3895
-
3896
- return $v_result;
3897
- }
3898
-
3899
- // ----- Opening destination file
3900
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3901
-
3902
- // ----- Change the file status
3903
- $p_entry['status'] = "write_error";
3904
-
3905
- return $v_result;
3906
- }
3907
-
3908
- // ----- Write the uncompressed data
3909
- @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3910
- unset($v_file_content);
3911
-
3912
- // ----- Closing the destination file
3913
- @fclose($v_dest_file);
3914
-
3915
- }
3916
-
3917
- // ----- Change the file mtime
3918
- @touch($p_entry['filename'], $p_entry['mtime']);
3919
- }
3920
-
3921
- // ----- Look for chmod option
3922
- if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3923
-
3924
- // ----- Change the mode of the file
3925
- @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3926
- }
3927
-
3928
- }
3929
- }
3930
-
3931
- // ----- Change abort status
3932
- if ($p_entry['status'] == "aborted") {
3933
- $p_entry['status'] = "skipped";
3934
- }
3935
-
3936
- // ----- Look for post-extract callback
3937
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3938
-
3939
- // ----- Generate a local information
3940
- $v_local_header = array();
3941
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3942
-
3943
- // ----- Call the callback
3944
- // Here I do not use call_user_func() because I need to send a reference to the
3945
- // header.
3946
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
3947
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3948
-
3949
- // ----- Look for abort result
3950
- if ($v_result == 2) {
3951
- $v_result = PCLZIP_ERR_USER_ABORTED;
3952
- }
3953
- }
3954
-
3955
- // ----- Return
3956
- return $v_result;
3957
- }
3958
- // --------------------------------------------------------------------------------
3959
-
3960
- // --------------------------------------------------------------------------------
3961
- // Function : privExtractFileUsingTempFile()
3962
- // Description :
3963
- // Parameters :
3964
- // Return Values :
3965
- // --------------------------------------------------------------------------------
3966
- function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3967
- {
3968
- $v_result=1;
3969
-
3970
- // ----- Creates a temporary file
3971
- $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3972
- if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3973
- fclose($v_file);
3974
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3975
- return PclZip::errorCode();
3976
- }
3977
-
3978
-
3979
- // ----- Write gz file format header
3980
- $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
3981
- @fwrite($v_dest_file, $v_binary_data, 10);
3982
-
3983
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3984
- $v_size = $p_entry['compressed_size'];
3985
- while ($v_size != 0)
3986
- {
3987
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3988
- $v_buffer = @fread($this->zip_fd, $v_read_size);
3989
- //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
3990
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
3991
- $v_size -= $v_read_size;
3992
- }
3993
-
3994
- // ----- Write gz file format footer
3995
- $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
3996
- @fwrite($v_dest_file, $v_binary_data, 8);
3997
-
3998
- // ----- Close the temporary file
3999
- @fclose($v_dest_file);
4000
-
4001
- // ----- Opening destination file
4002
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4003
- $p_entry['status'] = "write_error";
4004
- return $v_result;
4005
- }
4006
-
4007
- // ----- Open the temporary gz file
4008
- if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4009
- @fclose($v_dest_file);
4010
- $p_entry['status'] = "read_error";
4011
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4012
- return PclZip::errorCode();
4013
- }
4014
-
4015
-
4016
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4017
- $v_size = $p_entry['size'];
4018
- while ($v_size != 0) {
4019
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4020
- $v_buffer = @gzread($v_src_file, $v_read_size);
4021
- //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4022
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
4023
- $v_size -= $v_read_size;
4024
- }
4025
- @fclose($v_dest_file);
4026
- @gzclose($v_src_file);
4027
-
4028
- // ----- Delete the temporary file
4029
- @unlink($v_gzip_temp_name);
4030
-
4031
- // ----- Return
4032
- return $v_result;
4033
- }
4034
- // --------------------------------------------------------------------------------
4035
-
4036
- // --------------------------------------------------------------------------------
4037
- // Function : privExtractFileInOutput()
4038
- // Description :
4039
- // Parameters :
4040
- // Return Values :
4041
- // --------------------------------------------------------------------------------
4042
- function privExtractFileInOutput(&$p_entry, &$p_options)
4043
- {
4044
- $v_result=1;
4045
-
4046
- // ----- Read the file header
4047
- if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4048
- return $v_result;
4049
- }
4050
-
4051
-
4052
- // ----- Check that the file header is coherent with $p_entry info
4053
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4054
- // TBC
4055
- }
4056
-
4057
- // ----- Look for pre-extract callback
4058
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4059
-
4060
- // ----- Generate a local information
4061
- $v_local_header = array();
4062
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4063
-
4064
- // ----- Call the callback
4065
- // Here I do not use call_user_func() because I need to send a reference to the
4066
- // header.
4067
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4068
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4069
- if ($v_result == 0) {
4070
- // ----- Change the file status
4071
- $p_entry['status'] = "skipped";
4072
- $v_result = 1;
4073
- }
4074
-
4075
- // ----- Look for abort result
4076
- if ($v_result == 2) {
4077
- // ----- This status is internal and will be changed in 'skipped'
4078
- $p_entry['status'] = "aborted";
4079
- $v_result = PCLZIP_ERR_USER_ABORTED;
4080
- }
4081
-
4082
- // ----- Update the informations
4083
- // Only some fields can be modified
4084
- $p_entry['filename'] = $v_local_header['filename'];
4085
- }
4086
-
4087
- // ----- Trace
4088
-
4089
- // ----- Look if extraction should be done
4090
- if ($p_entry['status'] == 'ok') {
4091
-
4092
- // ----- Do the extraction (if not a folder)
4093
- if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4094
- // ----- Look for not compressed file
4095
- if ($p_entry['compressed_size'] == $p_entry['size']) {
4096
-
4097
- // ----- Read the file in a buffer (one shot)
4098
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4099
-
4100
- // ----- Send the file to the output
4101
- echo $v_buffer;
4102
- unset($v_buffer);
4103
- }
4104
- else {
4105
-
4106
- // ----- Read the compressed file in a buffer (one shot)
4107
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4108
-
4109
- // ----- Decompress the file
4110
- $v_file_content = gzinflate($v_buffer);
4111
- unset($v_buffer);
4112
-
4113
- // ----- Send the file to the output
4114
- echo $v_file_content;
4115
- unset($v_file_content);
4116
- }
4117
- }
4118
- }
4119
-
4120
- // ----- Change abort status
4121
- if ($p_entry['status'] == "aborted") {
4122
- $p_entry['status'] = "skipped";
4123
- }
4124
-
4125
- // ----- Look for post-extract callback
4126
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4127
-
4128
- // ----- Generate a local information
4129
- $v_local_header = array();
4130
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4131
-
4132
- // ----- Call the callback
4133
- // Here I do not use call_user_func() because I need to send a reference to the
4134
- // header.
4135
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4136
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4137
-
4138
- // ----- Look for abort result
4139
- if ($v_result == 2) {
4140
- $v_result = PCLZIP_ERR_USER_ABORTED;
4141
- }
4142
- }
4143
-
4144
- return $v_result;
4145
- }
4146
- // --------------------------------------------------------------------------------
4147
-
4148
- // --------------------------------------------------------------------------------
4149
- // Function : privExtractFileAsString()
4150
- // Description :
4151
- // Parameters :
4152
- // Return Values :
4153
- // --------------------------------------------------------------------------------
4154
- function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4155
- {
4156
- $v_result=1;
4157
-
4158
- // ----- Read the file header
4159
- $v_header = array();
4160
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4161
- {
4162
- // ----- Return
4163
- return $v_result;
4164
- }
4165
-
4166
-
4167
- // ----- Check that the file header is coherent with $p_entry info
4168
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4169
- // TBC
4170
- }
4171
-
4172
- // ----- Look for pre-extract callback
4173
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4174
-
4175
- // ----- Generate a local information
4176
- $v_local_header = array();
4177
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4178
-
4179
- // ----- Call the callback
4180
- // Here I do not use call_user_func() because I need to send a reference to the
4181
- // header.
4182
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4183
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4184
- if ($v_result == 0) {
4185
- // ----- Change the file status
4186
- $p_entry['status'] = "skipped";
4187
- $v_result = 1;
4188
- }
4189
-
4190
- // ----- Look for abort result
4191
- if ($v_result == 2) {
4192
- // ----- This status is internal and will be changed in 'skipped'
4193
- $p_entry['status'] = "aborted";
4194
- $v_result = PCLZIP_ERR_USER_ABORTED;
4195
- }
4196
-
4197
- // ----- Update the informations
4198
- // Only some fields can be modified
4199
- $p_entry['filename'] = $v_local_header['filename'];
4200
- }
4201
-
4202
-
4203
- // ----- Look if extraction should be done
4204
- if ($p_entry['status'] == 'ok') {
4205
-
4206
- // ----- Do the extraction (if not a folder)
4207
- if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4208
- // ----- Look for not compressed file
4209
- // if ($p_entry['compressed_size'] == $p_entry['size'])
4210
- if ($p_entry['compression'] == 0) {
4211
-
4212
- // ----- Reading the file
4213
- $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4214
- }
4215
- else {
4216
-
4217
- // ----- Reading the file
4218
- $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4219
-
4220
- // ----- Decompress the file
4221
- if (($p_string = @gzinflate($v_data)) === FALSE) {
4222
- // TBC
4223
- }
4224
- }
4225
-
4226
- // ----- Trace
4227
- }
4228
- else {
4229
- // TBC : error : can not extract a folder in a string
4230
- }
4231
-
4232
- }
4233
-
4234
- // ----- Change abort status
4235
- if ($p_entry['status'] == "aborted") {
4236
- $p_entry['status'] = "skipped";
4237
- }
4238
-
4239
- // ----- Look for post-extract callback
4240
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4241
-
4242
- // ----- Generate a local information
4243
- $v_local_header = array();
4244
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4245
-
4246
- // ----- Swap the content to header
4247
- $v_local_header['content'] = $p_string;
4248
- $p_string = '';
4249
-
4250
- // ----- Call the callback
4251
- // Here I do not use call_user_func() because I need to send a reference to the
4252
- // header.
4253
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4254
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4255
-
4256
- // ----- Swap back the content to header
4257
- $p_string = $v_local_header['content'];
4258
- unset($v_local_header['content']);
4259
-
4260
- // ----- Look for abort result
4261
- if ($v_result == 2) {
4262
- $v_result = PCLZIP_ERR_USER_ABORTED;
4263
- }
4264
- }
4265
-
4266
- // ----- Return
4267
- return $v_result;
4268
- }
4269
- // --------------------------------------------------------------------------------
4270
-
4271
- // --------------------------------------------------------------------------------
4272
- // Function : privReadFileHeader()
4273
- // Description :
4274
- // Parameters :
4275
- // Return Values :
4276
- // --------------------------------------------------------------------------------
4277
- function privReadFileHeader(&$p_header)
4278
- {
4279
- $v_result=1;
4280
-
4281
- // ----- Read the 4 bytes signature
4282
- $v_binary_data = @fread($this->zip_fd, 4);
4283
- $v_data = unpack('Vid', $v_binary_data);
4284
-
4285
- // ----- Check signature
4286
- if ($v_data['id'] != 0x04034b50)
4287
- {
4288
-
4289
- // ----- Error log
4290
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4291
-
4292
- // ----- Return
4293
- return PclZip::errorCode();
4294
- }
4295
-
4296
- // ----- Read the first 42 bytes of the header
4297
- $v_binary_data = fread($this->zip_fd, 26);
4298
-
4299
- // ----- Look for invalid block size
4300
- if (strlen($v_binary_data) != 26)
4301
- {
4302
- $p_header['filename'] = "";
4303
- $p_header['status'] = "invalid_header";
4304
-
4305
- // ----- Error log
4306
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4307
-
4308
- // ----- Return
4309
- return PclZip::errorCode();
4310
- }
4311
-
4312
- // ----- Extract the values
4313
- $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4314
-
4315
- // ----- Get filename
4316
- $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4317
-
4318
- // ----- Get extra_fields
4319
- if ($v_data['extra_len'] != 0) {
4320
- $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4321
- }
4322
- else {
4323
- $p_header['extra'] = '';
4324
- }
4325
-
4326
- // ----- Extract properties
4327
- $p_header['version_extracted'] = $v_data['version'];
4328
- $p_header['compression'] = $v_data['compression'];
4329
- $p_header['size'] = $v_data['size'];
4330
- $p_header['compressed_size'] = $v_data['compressed_size'];
4331
- $p_header['crc'] = $v_data['crc'];
4332
- $p_header['flag'] = $v_data['flag'];
4333
- $p_header['filename_len'] = $v_data['filename_len'];
4334
-
4335
- // ----- Recuperate date in UNIX format
4336
- $p_header['mdate'] = $v_data['mdate'];
4337
- $p_header['mtime'] = $v_data['mtime'];
4338
- if ($p_header['mdate'] && $p_header['mtime'])
4339
- {
4340
- // ----- Extract time
4341
- $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4342
- $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4343
- $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4344
-
4345
- // ----- Extract date
4346
- $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4347
- $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4348
- $v_day = $p_header['mdate'] & 0x001F;
4349
-
4350
- // ----- Get UNIX date format
4351
- $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4352
-
4353
- }
4354
- else
4355
- {
4356
- $p_header['mtime'] = time();
4357
- }
4358
-
4359
- // TBC
4360
- //for(reset($v_data); $key = key($v_data); next($v_data)) {
4361
- //}
4362
-
4363
- // ----- Set the stored filename
4364
- $p_header['stored_filename'] = $p_header['filename'];
4365
-
4366
- // ----- Set the status field
4367
- $p_header['status'] = "ok";
4368
-
4369
- // ----- Return
4370
- return $v_result;
4371
- }
4372
- // --------------------------------------------------------------------------------
4373
-
4374
- // --------------------------------------------------------------------------------
4375
- // Function : privReadCentralFileHeader()
4376
- // Description :
4377
- // Parameters :
4378
- // Return Values :
4379
- // --------------------------------------------------------------------------------
4380
- function privReadCentralFileHeader(&$p_header)
4381
- {
4382
- $v_result=1;
4383
-
4384
- // ----- Read the 4 bytes signature
4385
- $v_binary_data = @fread($this->zip_fd, 4);
4386
- $v_data = unpack('Vid', $v_binary_data);
4387
-
4388
- // ----- Check signature
4389
- if ($v_data['id'] != 0x02014b50)
4390
- {
4391
-
4392
- // ----- Error log
4393
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4394
-
4395
- // ----- Return
4396
- return PclZip::errorCode();
4397
- }
4398
-
4399
- // ----- Read the first 42 bytes of the header
4400
- $v_binary_data = fread($this->zip_fd, 42);
4401
-
4402
- // ----- Look for invalid block size
4403
- if (strlen($v_binary_data) != 42)
4404
- {
4405
- $p_header['filename'] = "";
4406
- $p_header['status'] = "invalid_header";
4407
-
4408
- // ----- Error log
4409
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4410
-
4411
- // ----- Return
4412
- return PclZip::errorCode();
4413
- }
4414
-
4415
- // ----- Extract the values
4416
- $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4417
-
4418
- // ----- Get filename
4419
- if ($p_header['filename_len'] != 0)
4420
- $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4421
- else
4422
- $p_header['filename'] = '';
4423
-
4424
- // ----- Get extra
4425
- if ($p_header['extra_len'] != 0)
4426
- $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4427
- else
4428
- $p_header['extra'] = '';
4429
-
4430
- // ----- Get comment
4431
- if ($p_header['comment_len'] != 0)
4432
- $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4433
- else
4434
- $p_header['comment'] = '';
4435
-
4436
- // ----- Extract properties
4437
-
4438
- // ----- Recuperate date in UNIX format
4439
- //if ($p_header['mdate'] && $p_header['mtime'])
4440
- // TBC : bug : this was ignoring time with 0/0/0
4441
- if (1)
4442
- {
4443
- // ----- Extract time
4444
- $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4445
- $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4446
- $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4447
-
4448
- // ----- Extract date
4449
- $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4450
- $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4451
- $v_day = $p_header['mdate'] & 0x001F;
4452
-
4453
- // ----- Get UNIX date format
4454
- $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4455
-
4456
- }
4457
- else
4458
- {
4459
- $p_header['mtime'] = time();
4460
- }
4461
-
4462
- // ----- Set the stored filename
4463
- $p_header['stored_filename'] = $p_header['filename'];
4464
-
4465
- // ----- Set default status to ok
4466
- $p_header['status'] = 'ok';
4467
-
4468
- // ----- Look if it is a directory
4469
- if (substr($p_header['filename'], -1) == '/') {
4470
- //$p_header['external'] = 0x41FF0010;
4471
- $p_header['external'] = 0x00000010;
4472
- }
4473
-
4474
-
4475
- // ----- Return
4476
- return $v_result;
4477
- }
4478
- // --------------------------------------------------------------------------------
4479
-
4480
- // --------------------------------------------------------------------------------
4481
- // Function : privCheckFileHeaders()
4482
- // Description :
4483
- // Parameters :
4484
- // Return Values :
4485
- // 1 on success,
4486
- // 0 on error;
4487
- // --------------------------------------------------------------------------------
4488
- function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4489
- {
4490
- $v_result=1;
4491
-
4492
- // ----- Check the static values
4493
- // TBC
4494
- if ($p_local_header['filename'] != $p_central_header['filename']) {
4495
- }
4496
- if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
4497
- }
4498
- if ($p_local_header['flag'] != $p_central_header['flag']) {
4499
- }
4500
- if ($p_local_header['compression'] != $p_central_header['compression']) {
4501
- }
4502
- if ($p_local_header['mtime'] != $p_central_header['mtime']) {
4503
- }
4504
- if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
4505
- }
4506
-
4507
- // ----- Look for flag bit 3
4508
- if (($p_local_header['flag'] & 8) == 8) {
4509
- $p_local_header['size'] = $p_central_header['size'];
4510
- $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4511
- $p_local_header['crc'] = $p_central_header['crc'];
4512
- }
4513
-
4514
- // ----- Return
4515
- return $v_result;
4516
- }
4517
- // --------------------------------------------------------------------------------
4518
-
4519
- // --------------------------------------------------------------------------------
4520
- // Function : privReadEndCentralDir()
4521
- // Description :
4522
- // Parameters :
4523
- // Return Values :
4524
- // --------------------------------------------------------------------------------
4525
- function privReadEndCentralDir(&$p_central_dir)
4526
- {
4527
- $v_result=1;
4528
-
4529
- // ----- Go to the end of the zip file
4530
- $v_size = filesize($this->zipname);
4531
- @fseek($this->zip_fd, $v_size);
4532
- if (@ftell($this->zip_fd) != $v_size)
4533
- {
4534
- // ----- Error log
4535
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4536
-
4537
- // ----- Return
4538
- return PclZip::errorCode();
4539
- }
4540
-
4541
- // ----- First try : look if this is an archive with no commentaries (most of the time)
4542
- // in this case the end of central dir is at 22 bytes of the file end
4543
- $v_found = 0;
4544
- if ($v_size > 26) {
4545
- @fseek($this->zip_fd, $v_size-22);
4546
- if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4547
- {
4548
- // ----- Error log
4549
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4550
-
4551
- // ----- Return
4552
- return PclZip::errorCode();
4553
- }
4554
-
4555
- // ----- Read for bytes
4556
- $v_binary_data = @fread($this->zip_fd, 4);
4557
- $v_data = @unpack('Vid', $v_binary_data);
4558
-
4559
- // ----- Check signature
4560
- if ($v_data['id'] == 0x06054b50) {
4561
- $v_found = 1;
4562
- }
4563
-
4564
- $v_pos = ftell($this->zip_fd);
4565
- }
4566
-
4567
- // ----- Go back to the maximum possible size of the Central Dir End Record
4568
- if (!$v_found) {
4569
- $v_maximum_size = 65557; // 0xFFFF + 22;
4570
- if ($v_maximum_size > $v_size)
4571
- $v_maximum_size = $v_size;
4572
- @fseek($this->zip_fd, $v_size-$v_maximum_size);
4573
- if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4574
- {
4575
- // ----- Error log
4576
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4577
-
4578
- // ----- Return
4579
- return PclZip::errorCode();
4580
- }
4581
-
4582
- // ----- Read byte per byte in order to find the signature
4583
- $v_pos = ftell($this->zip_fd);
4584
- $v_bytes = 0x00000000;
4585
- while ($v_pos < $v_size)
4586
- {
4587
- // ----- Read a byte
4588
- $v_byte = @fread($this->zip_fd, 1);
4589
-
4590
- // ----- Add the byte
4591
- //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4592
- // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
4593
- // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
4594
- $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4595
-
4596
- // ----- Compare the bytes
4597
- if ($v_bytes == 0x504b0506)
4598
- {
4599
- $v_pos++;
4600
- break;
4601
- }
4602
-
4603
- $v_pos++;
4604
- }
4605
-
4606
- // ----- Look if not found end of central dir
4607
- if ($v_pos == $v_size)
4608
- {
4609
-
4610
- // ----- Error log
4611
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4612
-
4613
- // ----- Return
4614
- return PclZip::errorCode();
4615
- }
4616
- }
4617
-
4618
- // ----- Read the first 18 bytes of the header
4619
- $v_binary_data = fread($this->zip_fd, 18);
4620
-
4621
- // ----- Look for invalid block size
4622
- if (strlen($v_binary_data) != 18)
4623
- {
4624
-
4625
- // ----- Error log
4626
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4627
-
4628
- // ----- Return
4629
- return PclZip::errorCode();
4630
- }
4631
-
4632
- // ----- Extract the values
4633
- $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4634
-
4635
- // ----- Check the global size
4636
- if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4637
-
4638
- // ----- Removed in release 2.2 see readme file
4639
- // The check of the file size is a little too strict.
4640
- // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
4641
- // While decrypted, zip has training 0 bytes
4642
- if (0) {
4643
- // ----- Error log
4644
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4645
- 'The central dir is not at the end of the archive.'
4646
- .' Some trailing bytes exists after the archive.');
4647
-
4648
- // ----- Return
4649
- return PclZip::errorCode();
4650
- }
4651
- }
4652
-
4653
- // ----- Get comment
4654
- if ($v_data['comment_size'] != 0) {
4655
- $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4656
- }
4657
- else
4658
- $p_central_dir['comment'] = '';
4659
-
4660
- $p_central_dir['entries'] = $v_data['entries'];
4661
- $p_central_dir['disk_entries'] = $v_data['disk_entries'];
4662
- $p_central_dir['offset'] = $v_data['offset'];
4663
- $p_central_dir['size'] = $v_data['size'];
4664
- $p_central_dir['disk'] = $v_data['disk'];
4665
- $p_central_dir['disk_start'] = $v_data['disk_start'];
4666
-
4667
- // TBC
4668
- //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4669
- //}
4670
-
4671
- // ----- Return
4672
- return $v_result;
4673
- }
4674
- // --------------------------------------------------------------------------------
4675
-
4676
- // --------------------------------------------------------------------------------
4677
- // Function : privDeleteByRule()
4678
- // Description :
4679
- // Parameters :
4680
- // Return Values :
4681
- // --------------------------------------------------------------------------------
4682
- function privDeleteByRule(&$p_result_list, &$p_options)
4683
- {
4684
- $v_result=1;
4685
- $v_list_detail = array();
4686
-
4687
- // ----- Open the zip file
4688
- if (($v_result=$this->privOpenFd('rb')) != 1)
4689
- {
4690
- // ----- Return
4691
- return $v_result;
4692
- }
4693
-
4694
- // ----- Read the central directory informations
4695
- $v_central_dir = array();
4696
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4697
- {
4698
- $this->privCloseFd();
4699
- return $v_result;
4700
- }
4701
-
4702
- // ----- Go to beginning of File
4703
- @rewind($this->zip_fd);
4704
-
4705
- // ----- Scan all the files
4706
- // ----- Start at beginning of Central Dir
4707
- $v_pos_entry = $v_central_dir['offset'];
4708
- @rewind($this->zip_fd);
4709
- if (@fseek($this->zip_fd, $v_pos_entry))
4710
- {
4711
- // ----- Close the zip file
4712
- $this->privCloseFd();
4713
-
4714
- // ----- Error log
4715
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4716
-
4717
- // ----- Return
4718
- return PclZip::errorCode();
4719
- }
4720
-
4721
- // ----- Read each entry
4722
- $v_header_list = array();
4723
- $j_start = 0;
4724
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4725
- {
4726
-
4727
- // ----- Read the file header
4728
- $v_header_list[$v_nb_extracted] = array();
4729
- if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4730
- {
4731
- // ----- Close the zip file
4732
- $this->privCloseFd();
4733
-
4734
- return $v_result;
4735
- }
4736
-
4737
-
4738
- // ----- Store the index
4739
- $v_header_list[$v_nb_extracted]['index'] = $i;
4740
-
4741
- // ----- Look for the specific extract rules
4742
- $v_found = false;
4743
-
4744
- // ----- Look for extract by name rule
4745
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
4746
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4747
-
4748
- // ----- Look if the filename is in the list
4749
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4750
-
4751
- // ----- Look for a directory
4752
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4753
-
4754
- // ----- Look if the directory is in the filename path
4755
- if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4756
- && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4757
- $v_found = true;
4758
- }
4759
- elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4760
- && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4761
- $v_found = true;
4762
- }
4763
- }
4764
- // ----- Look for a filename
4765
- elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4766
- $v_found = true;
4767
- }
4768
- }
4769
- }
4770
-
4771
- // ----- Look for extract by ereg rule
4772
- // ereg() is deprecated with PHP 5.3
4773
- /*
4774
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
4775
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4776
-
4777
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4778
- $v_found = true;
4779
- }
4780
- }
4781
- */
4782
-
4783
- // ----- Look for extract by preg rule
4784
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
4785
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4786
-
4787
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4788
- $v_found = true;
4789
- }
4790
- }
4791
-
4792
- // ----- Look for extract by index rule
4793
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4794
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4795
-
4796
- // ----- Look if the index is in the list
4797
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4798
-
4799
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4800
- $v_found = true;
4801
- }
4802
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4803
- $j_start = $j+1;
4804
- }
4805
-
4806
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4807
- break;
4808
- }
4809
- }
4810
- }
4811
- else {
4812
- $v_found = true;
4813
- }
4814
-
4815
- // ----- Look for deletion
4816
- if ($v_found)
4817
- {
4818
- unset($v_header_list[$v_nb_extracted]);
4819
- }
4820
- else
4821
- {
4822
- $v_nb_extracted++;
4823
- }
4824
- }
4825
-
4826
- // ----- Look if something need to be deleted
4827
- if ($v_nb_extracted > 0) {
4828
-
4829
- // ----- Creates a temporay file
4830
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4831
-
4832
- // ----- Creates a temporary zip archive
4833
- $v_temp_zip = new PclZip($v_zip_temp_name);
4834
-
4835
- // ----- Open the temporary zip file in write mode
4836
- if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4837
- $this->privCloseFd();
4838
-
4839
- // ----- Return
4840
- return $v_result;
4841
- }
4842
-
4843
- // ----- Look which file need to be kept
4844
- for ($i=0; $i<sizeof($v_header_list); $i++) {
4845
-
4846
- // ----- Calculate the position of the header
4847
- @rewind($this->zip_fd);
4848
- if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
4849
- // ----- Close the zip file
4850
- $this->privCloseFd();
4851
- $v_temp_zip->privCloseFd();
4852
- @unlink($v_zip_temp_name);
4853
-
4854
- // ----- Error log
4855
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4856
-
4857
- // ----- Return
4858
- return PclZip::errorCode();
4859
- }
4860
-
4861
- // ----- Read the file header
4862
- $v_local_header = array();
4863
- if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4864
- // ----- Close the zip file
4865
- $this->privCloseFd();
4866
- $v_temp_zip->privCloseFd();
4867
- @unlink($v_zip_temp_name);
4868
-
4869
- // ----- Return
4870
- return $v_result;
4871
- }
4872
-
4873
- // ----- Check that local file header is same as central file header
4874
- if ($this->privCheckFileHeaders($v_local_header,
4875
- $v_header_list[$i]) != 1) {
4876
- // TBC
4877
- }
4878
- unset($v_local_header);
4879
-
4880
- // ----- Write the file header
4881
- if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4882
- // ----- Close the zip file
4883
- $this->privCloseFd();
4884
- $v_temp_zip->privCloseFd();
4885
- @unlink($v_zip_temp_name);
4886
-
4887
- // ----- Return
4888
- return $v_result;
4889
- }
4890
-
4891
- // ----- Read/write the data block
4892
- if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4893
- // ----- Close the zip file
4894
- $this->privCloseFd();
4895
- $v_temp_zip->privCloseFd();
4896
- @unlink($v_zip_temp_name);
4897
-
4898
- // ----- Return
4899
- return $v_result;
4900
- }
4901
- }
4902
-
4903
- // ----- Store the offset of the central dir
4904
- $v_offset = @ftell($v_temp_zip->zip_fd);
4905
-
4906
- // ----- Re-Create the Central Dir files header
4907
- for ($i=0; $i<sizeof($v_header_list); $i++) {
4908
- // ----- Create the file header
4909
- if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4910
- $v_temp_zip->privCloseFd();
4911
- $this->privCloseFd();
4912
- @unlink($v_zip_temp_name);
4913
-
4914
- // ----- Return
4915
- return $v_result;
4916
- }
4917
-
4918
- // ----- Transform the header to a 'usable' info
4919
- $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4920
- }
4921
-
4922
-
4923
- // ----- Zip file comment
4924
- $v_comment = '';
4925
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4926
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4927
- }
4928
-
4929
- // ----- Calculate the size of the central header
4930
- $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4931
-
4932
- // ----- Create the central dir footer
4933
- if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4934
- // ----- Reset the file list
4935
- unset($v_header_list);
4936
- $v_temp_zip->privCloseFd();
4937
- $this->privCloseFd();
4938
- @unlink($v_zip_temp_name);
4939
-
4940
- // ----- Return
4941
- return $v_result;
4942
- }
4943
-
4944
- // ----- Close
4945
- $v_temp_zip->privCloseFd();
4946
- $this->privCloseFd();
4947
-
4948
- // ----- Delete the zip file
4949
- // TBC : I should test the result ...
4950
- @unlink($this->zipname);
4951
-
4952
- // ----- Rename the temporary file
4953
- // TBC : I should test the result ...
4954
- //@rename($v_zip_temp_name, $this->zipname);
4955
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
4956
-
4957
- // ----- Destroy the temporary archive
4958
- unset($v_temp_zip);
4959
- }
4960
-
4961
- // ----- Remove every files : reset the file
4962
- else if ($v_central_dir['entries'] != 0) {
4963
- $this->privCloseFd();
4964
-
4965
- if (($v_result = $this->privOpenFd('wb')) != 1) {
4966
- return $v_result;
4967
- }
4968
-
4969
- if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4970
- return $v_result;
4971
- }
4972
-
4973
- $this->privCloseFd();
4974
- }
4975
-
4976
- // ----- Return
4977
- return $v_result;
4978
- }
4979
- // --------------------------------------------------------------------------------
4980
-
4981
- // --------------------------------------------------------------------------------
4982
- // Function : privDirCheck()
4983
- // Description :
4984
- // Check if a directory exists, if not it creates it and all the parents directory
4985
- // which may be useful.
4986
- // Parameters :
4987
- // $p_dir : Directory path to check.
4988
- // Return Values :
4989
- // 1 : OK
4990
- // -1 : Unable to create directory
4991
- // --------------------------------------------------------------------------------
4992
- function privDirCheck($p_dir, $p_is_dir=false)
4993
- {
4994
- $v_result = 1;
4995
-
4996
-
4997
- // ----- Remove the final '/'
4998
- if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4999
- {
5000
- $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
5001
- }
5002
-
5003
- // ----- Check the directory availability
5004
- if ((is_dir($p_dir)) || ($p_dir == ""))
5005
- {
5006
- return 1;
5007
- }
5008
-
5009
- // ----- Extract parent directory
5010
- $p_parent_dir = dirname($p_dir);
5011
-
5012
- // ----- Just a check
5013
- if ($p_parent_dir != $p_dir)
5014
- {
5015
- // ----- Look for parent directory
5016
- if ($p_parent_dir != "")
5017
- {
5018
- if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5019
- {
5020
- return $v_result;
5021
- }
5022
- }
5023
- }
5024
-
5025
- // ----- Create the directory
5026
- if (!@mkdir($p_dir, 0777))
5027
- {
5028
- // ----- Error log
5029
- PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5030
-
5031
- // ----- Return
5032
- return PclZip::errorCode();
5033
- }
5034
-
5035
- // ----- Return
5036
- return $v_result;
5037
- }
5038
- // --------------------------------------------------------------------------------
5039
-
5040
- // --------------------------------------------------------------------------------
5041
- // Function : privMerge()
5042
- // Description :
5043
- // If $p_archive_to_add does not exist, the function exit with a success result.
5044
- // Parameters :
5045
- // Return Values :
5046
- // --------------------------------------------------------------------------------
5047
- function privMerge(&$p_archive_to_add)
5048
- {
5049
- $v_result=1;
5050
-
5051
- // ----- Look if the archive_to_add exists
5052
- if (!is_file($p_archive_to_add->zipname))
5053
- {
5054
-
5055
- // ----- Nothing to merge, so merge is a success
5056
- $v_result = 1;
5057
-
5058
- // ----- Return
5059
- return $v_result;
5060
- }
5061
-
5062
- // ----- Look if the archive exists
5063
- if (!is_file($this->zipname))
5064
- {
5065
-
5066
- // ----- Do a duplicate
5067
- $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5068
-
5069
- // ----- Return
5070
- return $v_result;
5071
- }
5072
-
5073
- // ----- Open the zip file
5074
- if (($v_result=$this->privOpenFd('rb')) != 1)
5075
- {
5076
- // ----- Return
5077
- return $v_result;
5078
- }
5079
-
5080
- // ----- Read the central directory informations
5081
- $v_central_dir = array();
5082
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5083
- {
5084
- $this->privCloseFd();
5085
- return $v_result;
5086
- }
5087
-
5088
- // ----- Go to beginning of File
5089
- @rewind($this->zip_fd);
5090
-
5091
- // ----- Open the archive_to_add file
5092
- if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5093
- {
5094
- $this->privCloseFd();
5095
-
5096
- // ----- Return
5097
- return $v_result;
5098
- }
5099
-
5100
- // ----- Read the central directory informations
5101
- $v_central_dir_to_add = array();
5102
- if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5103
- {
5104
- $this->privCloseFd();
5105
- $p_archive_to_add->privCloseFd();
5106
-
5107
- return $v_result;
5108
- }
5109
-
5110
- // ----- Go to beginning of File
5111
- @rewind($p_archive_to_add->zip_fd);
5112
-
5113
- // ----- Creates a temporay file
5114
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5115
-
5116
- // ----- Open the temporary file in write mode
5117
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5118
- {
5119
- $this->privCloseFd();
5120
- $p_archive_to_add->privCloseFd();
5121
-
5122
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5123
-
5124
- // ----- Return
5125
- return PclZip::errorCode();
5126
- }
5127
-
5128
- // ----- Copy the files from the archive to the temporary file
5129
- // TBC : Here I should better append the file and go back to erase the central dir
5130
- $v_size = $v_central_dir['offset'];
5131
- while ($v_size != 0)
5132
- {
5133
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5134
- $v_buffer = fread($this->zip_fd, $v_read_size);
5135
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5136
- $v_size -= $v_read_size;
5137
- }
5138
-
5139
- // ----- Copy the files from the archive_to_add into the temporary file
5140
- $v_size = $v_central_dir_to_add['offset'];
5141
- while ($v_size != 0)
5142
- {
5143
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5144
- $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5145
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5146
- $v_size -= $v_read_size;
5147
- }
5148
-
5149
- // ----- Store the offset of the central dir
5150
- $v_offset = @ftell($v_zip_temp_fd);
5151
-
5152
- // ----- Copy the block of file headers from the old archive
5153
- $v_size = $v_central_dir['size'];
5154
- while ($v_size != 0)
5155
- {
5156
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5157
- $v_buffer = @fread($this->zip_fd, $v_read_size);
5158
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5159
- $v_size -= $v_read_size;
5160
- }
5161
-
5162
- // ----- Copy the block of file headers from the archive_to_add
5163
- $v_size = $v_central_dir_to_add['size'];
5164
- while ($v_size != 0)
5165
- {
5166
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5167
- $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5168
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5169
- $v_size -= $v_read_size;
5170
- }
5171
-
5172
- // ----- Merge the file comments
5173
- $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5174
-
5175
- // ----- Calculate the size of the (new) central header
5176
- $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5177
-
5178
- // ----- Swap the file descriptor
5179
- // Here is a trick : I swap the temporary fd with the zip fd, in order to use
5180
- // the following methods on the temporary fil and not the real archive fd
5181
- $v_swap = $this->zip_fd;
5182
- $this->zip_fd = $v_zip_temp_fd;
5183
- $v_zip_temp_fd = $v_swap;
5184
-
5185
- // ----- Create the central dir footer
5186
- if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5187
- {
5188
- $this->privCloseFd();
5189
- $p_archive_to_add->privCloseFd();
5190
- @fclose($v_zip_temp_fd);
5191
- $this->zip_fd = null;
5192
-
5193
- // ----- Reset the file list
5194
- unset($v_header_list);
5195
-
5196
- // ----- Return
5197
- return $v_result;
5198
- }
5199
-
5200
- // ----- Swap back the file descriptor
5201
- $v_swap = $this->zip_fd;
5202
- $this->zip_fd = $v_zip_temp_fd;
5203
- $v_zip_temp_fd = $v_swap;
5204
-
5205
- // ----- Close
5206
- $this->privCloseFd();
5207
- $p_archive_to_add->privCloseFd();
5208
-
5209
- // ----- Close the temporary file
5210
- @fclose($v_zip_temp_fd);
5211
-
5212
- // ----- Delete the zip file
5213
- // TBC : I should test the result ...
5214
- @unlink($this->zipname);
5215
-
5216
- // ----- Rename the temporary file
5217
- // TBC : I should test the result ...
5218
- //@rename($v_zip_temp_name, $this->zipname);
5219
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
5220
-
5221
- // ----- Return
5222
- return $v_result;
5223
- }
5224
- // --------------------------------------------------------------------------------
5225
-
5226
- // --------------------------------------------------------------------------------
5227
- // Function : privDuplicate()
5228
- // Description :
5229
- // Parameters :
5230
- // Return Values :
5231
- // --------------------------------------------------------------------------------
5232
- function privDuplicate($p_archive_filename)
5233
- {
5234
- $v_result=1;
5235
-
5236
- // ----- Look if the $p_archive_filename exists
5237
- if (!is_file($p_archive_filename))
5238
- {
5239
-
5240
- // ----- Nothing to duplicate, so duplicate is a success.
5241
- $v_result = 1;
5242
-
5243
- // ----- Return
5244
- return $v_result;
5245
- }
5246
-
5247
- // ----- Open the zip file
5248
- if (($v_result=$this->privOpenFd('wb')) != 1)
5249
- {
5250
- // ----- Return
5251
- return $v_result;
5252
- }
5253
-
5254
- // ----- Open the temporary file in write mode
5255
- if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5256
- {
5257
- $this->privCloseFd();
5258
-
5259
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5260
-
5261
- // ----- Return
5262
- return PclZip::errorCode();
5263
- }
5264
-
5265
- // ----- Copy the files from the archive to the temporary file
5266
- // TBC : Here I should better append the file and go back to erase the central dir
5267
- $v_size = filesize($p_archive_filename);
5268
- while ($v_size != 0)
5269
- {
5270
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5271
- $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5272
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5273
- $v_size -= $v_read_size;
5274
- }
5275
-
5276
- // ----- Close
5277
- $this->privCloseFd();
5278
-
5279
- // ----- Close the temporary file
5280
- @fclose($v_zip_temp_fd);
5281
-
5282
- // ----- Return
5283
- return $v_result;
5284
- }
5285
- // --------------------------------------------------------------------------------
5286
-
5287
- // --------------------------------------------------------------------------------
5288
- // Function : privErrorLog()
5289
- // Description :
5290
- // Parameters :
5291
- // --------------------------------------------------------------------------------
5292
- function privErrorLog($p_error_code=0, $p_error_string='')
5293
- {
5294
- if (PCLZIP_ERROR_EXTERNAL == 1) {
5295
- PclError($p_error_code, $p_error_string);
5296
- }
5297
- else {
5298
- $this->error_code = $p_error_code;
5299
- $this->error_string = $p_error_string;
5300
- }
5301
- }
5302
- // --------------------------------------------------------------------------------
5303
-
5304
- // --------------------------------------------------------------------------------
5305
- // Function : privErrorReset()
5306
- // Description :
5307
- // Parameters :
5308
- // --------------------------------------------------------------------------------
5309
- function privErrorReset()
5310
- {
5311
- if (PCLZIP_ERROR_EXTERNAL == 1) {
5312
- PclErrorReset();
5313
- }
5314
- else {
5315
- $this->error_code = 0;
5316
- $this->error_string = '';
5317
- }
5318
- }
5319
- // --------------------------------------------------------------------------------
5320
-
5321
- // --------------------------------------------------------------------------------
5322
- // Function : privDisableMagicQuotes()
5323
- // Description :
5324
- // Parameters :
5325
- // Return Values :
5326
- // --------------------------------------------------------------------------------
5327
- function privDisableMagicQuotes()
5328
- {
5329
- $v_result=1;
5330
-
5331
- // ----- Look if function exists
5332
- if ( (!function_exists("get_magic_quotes_runtime"))
5333
- || (!function_exists("set_magic_quotes_runtime"))) {
5334
- return $v_result;
5335
- }
5336
-
5337
- // ----- Look if already done
5338
- if ($this->magic_quotes_status != -1) {
5339
- return $v_result;
5340
- }
5341
-
5342
- // ----- Get and memorize the magic_quote value
5343
- $this->magic_quotes_status = @get_magic_quotes_runtime();
5344
-
5345
- // ----- Disable magic_quotes
5346
- if ($this->magic_quotes_status == 1) {
5347
- @set_magic_quotes_runtime(0);
5348
- }
5349
-
5350
- // ----- Return
5351
- return $v_result;
5352
- }
5353
- // --------------------------------------------------------------------------------
5354
-
5355
- // --------------------------------------------------------------------------------
5356
- // Function : privSwapBackMagicQuotes()
5357
- // Description :
5358
- // Parameters :
5359
- // Return Values :
5360
- // --------------------------------------------------------------------------------
5361
- function privSwapBackMagicQuotes()
5362
- {
5363
- $v_result=1;
5364
-
5365
- // ----- Look if function exists
5366
- if ( (!function_exists("get_magic_quotes_runtime"))
5367
- || (!function_exists("set_magic_quotes_runtime"))) {
5368
- return $v_result;
5369
- }
5370
-
5371
- // ----- Look if something to do
5372
- if ($this->magic_quotes_status != -1) {
5373
- return $v_result;
5374
- }
5375
-
5376
- // ----- Swap back magic_quotes
5377
- if ($this->magic_quotes_status == 1) {
5378
- @set_magic_quotes_runtime($this->magic_quotes_status);
5379
- }
5380
-
5381
- // ----- Return
5382
- return $v_result;
5383
- }
5384
- // --------------------------------------------------------------------------------
5385
-
5386
- }
5387
- // End of class
5388
- // --------------------------------------------------------------------------------
5389
-
5390
- // --------------------------------------------------------------------------------
5391
- // Function : PclZipUtilPathReduction()
5392
- // Description :
5393
- // Parameters :
5394
- // Return Values :
5395
- // --------------------------------------------------------------------------------
5396
- function PclZipUtilPathReduction($p_dir)
5397
- {
5398
- $v_result = "";
5399
-
5400
- // ----- Look for not empty path
5401
- if ($p_dir != "") {
5402
- // ----- Explode path by directory names
5403
- $v_list = explode("/", $p_dir);
5404
-
5405
- // ----- Study directories from last to first
5406
- $v_skip = 0;
5407
- for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5408
- // ----- Look for current path
5409
- if ($v_list[$i] == ".") {
5410
- // ----- Ignore this directory
5411
- // Should be the first $i=0, but no check is done
5412
- }
5413
- else if ($v_list[$i] == "..") {
5414
- $v_skip++;
5415
- }
5416
- else if ($v_list[$i] == "") {
5417
- // ----- First '/' i.e. root slash
5418
- if ($i == 0) {
5419
- $v_result = "/".$v_result;
5420
- if ($v_skip > 0) {
5421
- // ----- It is an invalid path, so the path is not modified
5422
- // TBC
5423
- $v_result = $p_dir;
5424
- $v_skip = 0;
5425
- }
5426
- }
5427
- // ----- Last '/' i.e. indicates a directory
5428
- else if ($i == (sizeof($v_list)-1)) {
5429
- $v_result = $v_list[$i];
5430
- }
5431
- // ----- Double '/' inside the path
5432
- else {
5433
- // ----- Ignore only the double '//' in path,
5434
- // but not the first and last '/'
5435
- }
5436
- }
5437
- else {
5438
- // ----- Look for item to skip
5439
- if ($v_skip > 0) {
5440
- $v_skip--;
5441
- }
5442
- else {
5443
- $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5444
- }
5445
- }
5446
- }
5447
-
5448
- // ----- Look for skip
5449
- if ($v_skip > 0) {
5450
- while ($v_skip > 0) {
5451
- $v_result = '../'.$v_result;
5452
- $v_skip--;
5453
- }
5454
- }
5455
- }
5456
-
5457
- // ----- Return
5458
- return $v_result;
5459
- }
5460
- // --------------------------------------------------------------------------------
5461
-
5462
- // --------------------------------------------------------------------------------
5463
- // Function : PclZipUtilPathInclusion()
5464
- // Description :
5465
- // This function indicates if the path $p_path is under the $p_dir tree. Or,
5466
- // said in an other way, if the file or sub-dir $p_path is inside the dir
5467
- // $p_dir.
5468
- // The function indicates also if the path is exactly the same as the dir.
5469
- // This function supports path with duplicated '/' like '//', but does not
5470
- // support '.' or '..' statements.
5471
- // Parameters :
5472
- // Return Values :
5473
- // 0 if $p_path is not inside directory $p_dir
5474
- // 1 if $p_path is inside directory $p_dir
5475
- // 2 if $p_path is exactly the same as $p_dir
5476
- // --------------------------------------------------------------------------------
5477
- function PclZipUtilPathInclusion($p_dir, $p_path)
5478
- {
5479
- $v_result = 1;
5480
-
5481
- // ----- Look for path beginning by ./
5482
- if ( ($p_dir == '.')
5483
- || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5484
- $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5485
- }
5486
- if ( ($p_path == '.')
5487
- || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5488
- $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5489
- }
5490
-
5491
- // ----- Explode dir and path by directory separator
5492
- $v_list_dir = explode("/", $p_dir);
5493
- $v_list_dir_size = sizeof($v_list_dir);
5494
- $v_list_path = explode("/", $p_path);
5495
- $v_list_path_size = sizeof($v_list_path);
5496
-
5497
- // ----- Study directories paths
5498
- $i = 0;
5499
- $j = 0;
5500
- while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5501
-
5502
- // ----- Look for empty dir (path reduction)
5503
- if ($v_list_dir[$i] == '') {
5504
- $i++;
5505
- continue;
5506
- }
5507
- if ($v_list_path[$j] == '') {
5508
- $j++;
5509
- continue;
5510
- }
5511
-
5512
- // ----- Compare the items
5513
- if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
5514
- $v_result = 0;
5515
- }
5516
-
5517
- // ----- Next items
5518
- $i++;
5519
- $j++;
5520
- }
5521
-
5522
- // ----- Look if everything seems to be the same
5523
- if ($v_result) {
5524
- // ----- Skip all the empty items
5525
- while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5526
- while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5527
-
5528
- if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5529
- // ----- There are exactly the same
5530
- $v_result = 2;
5531
- }
5532
- else if ($i < $v_list_dir_size) {
5533
- // ----- The path is shorter than the dir
5534
- $v_result = 0;
5535
- }
5536
- }
5537
-
5538
- // ----- Return
5539
- return $v_result;
5540
- }
5541
- // --------------------------------------------------------------------------------
5542
-
5543
- // --------------------------------------------------------------------------------
5544
- // Function : PclZipUtilCopyBlock()
5545
- // Description :
5546
- // Parameters :
5547
- // $p_mode : read/write compression mode
5548
- // 0 : src & dest normal
5549
- // 1 : src gzip, dest normal
5550
- // 2 : src normal, dest gzip
5551
- // 3 : src & dest gzip
5552
- // Return Values :
5553
- // --------------------------------------------------------------------------------
5554
- function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5555
- {
5556
- $v_result = 1;
5557
-
5558
- if ($p_mode==0)
5559
- {
5560
- while ($p_size != 0)
5561
- {
5562
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5563
- $v_buffer = @fread($p_src, $v_read_size);
5564
- @fwrite($p_dest, $v_buffer, $v_read_size);
5565
- $p_size -= $v_read_size;
5566
- }
5567
- }
5568
- else if ($p_mode==1)
5569
- {
5570
- while ($p_size != 0)
5571
- {
5572
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5573
- $v_buffer = @gzread($p_src, $v_read_size);
5574
- @fwrite($p_dest, $v_buffer, $v_read_size);
5575
- $p_size -= $v_read_size;
5576
- }
5577
- }
5578
- else if ($p_mode==2)
5579
- {
5580
- while ($p_size != 0)
5581
- {
5582
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5583
- $v_buffer = @fread($p_src, $v_read_size);
5584
- @gzwrite($p_dest, $v_buffer, $v_read_size);
5585
- $p_size -= $v_read_size;
5586
- }
5587
- }
5588
- else if ($p_mode==3)
5589
- {
5590
- while ($p_size != 0)
5591
- {
5592
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5593
- $v_buffer = @gzread($p_src, $v_read_size);
5594
- @gzwrite($p_dest, $v_buffer, $v_read_size);
5595
- $p_size -= $v_read_size;
5596
- }
5597
- }
5598
-
5599
- // ----- Return
5600
- return $v_result;
5601
- }
5602
- // --------------------------------------------------------------------------------
5603
-
5604
- // --------------------------------------------------------------------------------
5605
- // Function : PclZipUtilRename()
5606
- // Description :
5607
- // This function tries to do a simple rename() function. If it fails, it
5608
- // tries to copy the $p_src file in a new $p_dest file and then unlink the
5609
- // first one.
5610
- // Parameters :
5611
- // $p_src : Old filename
5612
- // $p_dest : New filename
5613
- // Return Values :
5614
- // 1 on success, 0 on failure.
5615
- // --------------------------------------------------------------------------------
5616
- function PclZipUtilRename($p_src, $p_dest)
5617
- {
5618
- $v_result = 1;
5619
-
5620
- // ----- Try to rename the files
5621
- if (!@rename($p_src, $p_dest)) {
5622
-
5623
- // ----- Try to copy & unlink the src
5624
- if (!@copy($p_src, $p_dest)) {
5625
- $v_result = 0;
5626
- }
5627
- else if (!@unlink($p_src)) {
5628
- $v_result = 0;
5629
- }
5630
- }
5631
-
5632
- // ----- Return
5633
- return $v_result;
5634
- }
5635
- // --------------------------------------------------------------------------------
5636
-
5637
- // --------------------------------------------------------------------------------
5638
- // Function : PclZipUtilOptionText()
5639
- // Description :
5640
- // Translate option value in text. Mainly for debug purpose.
5641
- // Parameters :
5642
- // $p_option : the option value.
5643
- // Return Values :
5644
- // The option text value.
5645
- // --------------------------------------------------------------------------------
5646
- function PclZipUtilOptionText($p_option)
5647
- {
5648
-
5649
- $v_list = get_defined_constants();
5650
- for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5651
- $v_prefix = substr($v_key, 0, 10);
5652
- if (( ($v_prefix == 'PCLZIP_OPT')
5653
- || ($v_prefix == 'PCLZIP_CB_')
5654
- || ($v_prefix == 'PCLZIP_ATT'))
5655
- && ($v_list[$v_key] == $p_option)) {
5656
- return $v_key;
5657
- }
5658
- }
5659
-
5660
- $v_result = 'Unknown';
5661
-
5662
- return $v_result;
5663
- }
5664
- // --------------------------------------------------------------------------------
5665
-
5666
- // --------------------------------------------------------------------------------
5667
- // Function : PclZipUtilTranslateWinPath()
5668
- // Description :
5669
- // Translate windows path by replacing '\' by '/' and optionally removing
5670
- // drive letter.
5671
- // Parameters :
5672
- // $p_path : path to translate.
5673
- // $p_remove_disk_letter : true | false
5674
- // Return Values :
5675
- // The path translated.
5676
- // --------------------------------------------------------------------------------
5677
- function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5678
- {
5679
- if (stristr(php_uname(), 'windows')) {
5680
- // ----- Look for potential disk letter
5681
- if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5682
- $p_path = substr($p_path, $v_position+1);
5683
- }
5684
- // ----- Change potential windows directory separator
5685
- if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5686
- $p_path = strtr($p_path, '\\', '/');
5687
- }
5688
- }
5689
- return $p_path;
5690
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/readme.txt DELETED
@@ -1,421 +0,0 @@
1
- // --------------------------------------------------------------------------------
2
- // PclZip 2.8.2 - readme.txt
3
- // --------------------------------------------------------------------------------
4
- // License GNU/LGPL - August 2009
5
- // Vincent Blavet - vincent@phpconcept.net
6
- // http://www.phpconcept.net
7
- // --------------------------------------------------------------------------------
8
- // $Id: readme.txt,v 1.60 2009/09/30 20:35:21 vblavet Exp $
9
- // --------------------------------------------------------------------------------
10
-
11
-
12
-
13
- 0 - Sommaire
14
- ============
15
- 1 - Introduction
16
- 2 - What's new
17
- 3 - Corrected bugs
18
- 4 - Known bugs or limitations
19
- 5 - License
20
- 6 - Warning
21
- 7 - Documentation
22
- 8 - Author
23
- 9 - Contribute
24
-
25
- 1 - Introduction
26
- ================
27
-
28
- PclZip is a library that allow you to manage a Zip archive.
29
-
30
- Full documentation about PclZip can be found here : http://www.phpconcept.net/pclzip
31
-
32
- 2 - What's new
33
- ==============
34
-
35
- Version 2.8.2 :
36
- - PCLZIP_CB_PRE_EXTRACT and PCLZIP_CB_POST_EXTRACT are now supported with
37
- extraction as a string (PCLZIP_OPT_EXTRACT_AS_STRING). The string
38
- can also be modified in the post-extract call back.
39
- **Bugs correction :
40
- - PCLZIP_OPT_REMOVE_ALL_PATH was not working correctly
41
- - Remove use of eval() and do direct call to callback functions
42
- - Correct support of 64bits systems (Thanks to WordPress team)
43
-
44
- Version 2.8.1 :
45
- - Move option PCLZIP_OPT_BY_EREG to PCLZIP_OPT_BY_PREG because ereg() is
46
- deprecated in PHP 5.3. When using option PCLZIP_OPT_BY_EREG, PclZip will
47
- automatically replace it by PCLZIP_OPT_BY_PREG.
48
-
49
- Version 2.8 :
50
- - Improve extraction of zip archive for large files by using temporary files
51
- This feature is working like the one defined in r2.7.
52
- Options are renamed : PCLZIP_OPT_TEMP_FILE_ON, PCLZIP_OPT_TEMP_FILE_OFF,
53
- PCLZIP_OPT_TEMP_FILE_THRESHOLD
54
- - Add a ratio constant PCLZIP_TEMPORARY_FILE_RATIO to configure the auto
55
- sense of temporary file use.
56
- - Bug correction : Reduce filepath in returned file list to remove ennoying
57
- './/' preambule in file path.
58
-
59
- Version 2.7 :
60
- - Improve creation of zip archive for large files :
61
- PclZip will now autosense the configured memory and use temporary files
62
- when large file is suspected.
63
- This feature can also ne triggered by manual options in create() and add()
64
- methods. 'PCLZIP_OPT_ADD_TEMP_FILE_ON' force the use of temporary files,
65
- 'PCLZIP_OPT_ADD_TEMP_FILE_OFF' disable the autosense technic,
66
- 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD' allow for configuration of a size
67
- threshold to use temporary files.
68
- Using "temporary files" rather than "memory" might take more time, but
69
- might give the ability to zip very large files :
70
- Tested on my win laptop with a 88Mo file :
71
- Zip "in-memory" : 18sec (max_execution_time=30, memory_limit=180Mo)
72
- Zip "tmporary-files" : 23sec (max_execution_time=30, memory_limit=30Mo)
73
- - Replace use of mktime() by time() to limit the E_STRICT error messages.
74
- - Bug correction : When adding files with full windows path (drive letter)
75
- PclZip is now working. Before, if the drive letter is not the default
76
- path, PclZip was not able to add the file.
77
-
78
- Version 2.6 :
79
- - Code optimisation
80
- - New attributes PCLZIP_ATT_FILE_COMMENT gives the ability to
81
- add a comment for a specific file. (Don't really know if this is usefull)
82
- - New attribute PCLZIP_ATT_FILE_CONTENT gives the ability to add a string
83
- as a file.
84
- - New attribute PCLZIP_ATT_FILE_MTIME modify the timestamp associated with
85
- a file.
86
- - Correct a bug. Files archived with a timestamp with 0h0m0s were extracted
87
- with current time
88
- - Add CRC value in the informations returned back for each file after an
89
- action.
90
- - Add missing closedir() statement.
91
- - When adding a folder, and removing the path of this folder, files were
92
- incorrectly added with a '/' at the beginning. Which means files are
93
- related to root in unix systems. Corrected.
94
- - Add conditional if before constant definition. This will allow users
95
- to redefine constants without changing the file, and then improve
96
- upgrade of pclzip code for new versions.
97
-
98
- Version 2.5 :
99
- - Introduce the ability to add file/folder with individual properties (file descriptor).
100
- This gives for example the ability to change the filename of a zipped file.
101
- . Able to add files individually
102
- . Able to change full name
103
- . Able to change short name
104
- . Compatible with global options
105
- - New attributes : PCLZIP_ATT_FILE_NAME, PCLZIP_ATT_FILE_NEW_SHORT_NAME, PCLZIP_ATT_FILE_NEW_FULL_NAME
106
- - New error code : PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE
107
- - Add a security control feature. PclZip can extract any file in any folder
108
- of a system. People may use this to upload a zip file and try to override
109
- a system file. The PCLZIP_OPT_EXTRACT_DIR_RESTRICTION will give the
110
- ability to forgive any directory transversal behavior.
111
- - New PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : check extraction path
112
- - New error code : PCLZIP_ERR_DIRECTORY_RESTRICTION
113
- - Modification in PclZipUtilPathInclusion() : dir and path beginning with ./ will be prepend
114
- by current path (getcwd())
115
-
116
- Version 2.4 :
117
- - Code improvment : try to speed up the code by removing unusefull call to pack()
118
- - Correct bug in delete() : delete() should be called with no argument. This was not
119
- the case in 2.3. This is corrected in 2.4.
120
- - Correct a bug in path_inclusion function. When the path has several '../../', the
121
- result was bad.
122
- - Add a check for magic_quotes_runtime configuration. If enabled, PclZip will
123
- disable it while working and det it back to its original value.
124
- This resolve a lots of bad formated archive errors.
125
- - Bug correction : PclZip now correctly unzip file in some specific situation,
126
- when compressed content has same size as uncompressed content.
127
- - Bug correction : When selecting option 'PCLZIP_OPT_REMOVE_ALL_PATH',
128
- directories are not any more created.
129
- - Code improvment : correct unclosed opendir(), better handling of . and .. in
130
- loops.
131
-
132
-
133
- Version 2.3 :
134
- - Correct a bug with PHP5 : affecting the value 0xFE49FFE0 to a variable does not
135
- give the same result in PHP4 and PHP5 ....
136
-
137
- Version 2.2 :
138
- - Try development of PCLZIP_OPT_CRYPT .....
139
- However this becomes to a stop. To crypt/decrypt I need to multiply 2 long integers,
140
- the result (greater than a long) is not supported by PHP. Even the use of bcmath
141
- functions does not help. I did not find yet a solution ...;
142
- - Add missing '/' at end of directory entries
143
- - Check is a file is encrypted or not. Returns status 'unsupported_encryption' and/or
144
- error code PCLZIP_ERR_UNSUPPORTED_ENCRYPTION.
145
- - Corrected : Bad "version need to extract" field in local file header
146
- - Add private method privCheckFileHeaders() in order to check local and central
147
- file headers. PclZip is now supporting purpose bit flag bit 3. Purpose bit flag bit 3 gives
148
- the ability to have a local file header without size, compressed size and crc filled.
149
- - Add a generic status 'error' for file status
150
- - Add control of compression type. PclZip only support deflate compression method.
151
- Before v2.2, PclZip does not check the compression method used in an archive while
152
- extracting. With v2.2 PclZip returns a new error status for a file using an unsupported
153
- compression method. New status is "unsupported_compression". New error code is
154
- PCLZIP_ERR_UNSUPPORTED_COMPRESSION.
155
- - Add optional attribute PCLZIP_OPT_STOP_ON_ERROR. This will stop the extract of files
156
- when errors like 'a folder with same name exists' or 'a newer file exists' or
157
- 'a write protected file' exists, rather than set a status for the concerning file
158
- and resume the extract of the zip.
159
- - Add optional attribute PCLZIP_OPT_REPLACE_NEWER. This will force, during an extract' the
160
- replacement of the file, even if a newer version of the file exists.
161
- Note that today if a file with the same name already exists but is older it will be
162
- replaced by the extracted one.
163
- - Improve PclZipUtilOption()
164
- - Support of zip archive with trailing bytes. Before 2.2, PclZip checks that the central
165
- directory structure is the last data in the archive. Crypt encryption/decryption of
166
- zip archive put trailing 0 bytes after decryption. PclZip is now supporting this.
167
-
168
- Version 2.1 :
169
- - Add the ability to abort the extraction by using a user callback function.
170
- The user can now return the value '2' in its callback which indicates to stop the
171
- extraction. For a pre call-back extract is stopped before the extration of the current
172
- file. For a post call back, the extraction is stopped after.
173
- - Add the ability to extract a file (or several files) directly in the standard output.
174
- This is done by the new parameter PCLZIP_OPT_EXTRACT_IN_OUTPUT with method extract().
175
- - Add support for parameters PCLZIP_OPT_COMMENT, PCLZIP_OPT_ADD_COMMENT,
176
- PCLZIP_OPT_PREPEND_COMMENT. This will create, replace, add, or prepend comments
177
- in the zip archive.
178
- - When merging two archives, the comments are not any more lost, but merged, with a
179
- blank space separator.
180
- - Corrected bug : Files are not deleted when all files are asked to be deleted.
181
- - Corrected bug : Folders with name '0' made PclZip to abort the create or add feature.
182
-
183
-
184
- Version 2.0 :
185
- ***** Warning : Some new features may break the backward compatibility for your scripts.
186
- Please carefully read the readme file.
187
- - Add the ability to delete by Index, name and regular expression. This feature is
188
- performed by the method delete(), which uses the optional parameters
189
- PCLZIP_OPT_BY_INDEX, PCLZIP_OPT_BY_NAME, PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG.
190
- - Add the ability to extract by regular expression. To extract by regexp you must use the method
191
- extract(), with the option PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG
192
- (depending if you want to use ereg() or preg_match() syntax) followed by the
193
- regular expression pattern.
194
- - Add the ability to extract by index, directly with the extract() method. This is a
195
- code improvment of the extractByIndex() method.
196
- - Add the ability to extract by name. To extract by name you must use the method
197
- extract(), with the option PCLZIP_OPT_BY_NAME followed by the filename to
198
- extract or an array of filenames to extract. To extract all a folder, use the folder
199
- name rather than the filename with a '/' at the end.
200
- - Add the ability to add files without compression. This is done with a new attribute
201
- which is PCLZIP_OPT_NO_COMPRESSION.
202
- - Add the attribute PCLZIP_OPT_EXTRACT_AS_STRING, which allow to extract a file directly
203
- in a string without using any file (or temporary file).
204
- - Add constant PCLZIP_SEPARATOR for static configuration of filename separators in a single string.
205
- The default separator is now a comma (,) and not any more a blank space.
206
- THIS BREAK THE BACKWARD COMPATIBILITY : Please check if this may have an impact with
207
- your script.
208
- - Improve algorythm performance by removing the use of temporary files when adding or
209
- extracting files in an archive.
210
- - Add (correct) detection of empty filename zipping. This can occurs when the removed
211
- path is the same
212
- as a zipped dir. The dir is not zipped (['status'] = filtered), only its content.
213
- - Add better support for windows paths (thanks for help from manus@manusfreedom.com).
214
- - Corrected bug : When the archive file already exists with size=0, the add() method
215
- fails. Corrected in 2.0.
216
- - Remove the use of OS_WINDOWS constant. Use php_uname() function rather.
217
- - Control the order of index ranges in extract by index feature.
218
- - Change the internal management of folders (better handling of internal flag).
219
-
220
-
221
- Version 1.3 :
222
- - Removing the double include check. This is now done by include_once() and require_once()
223
- PHP directives.
224
- - Changing the error handling mecanism : Remove the use of an external error library.
225
- The former PclError...() functions are replaced by internal equivalent methods.
226
- By changing the environment variable PCLZIP_ERROR_EXTERNAL you can still use the former library.
227
- Introducing the use of constants for error codes rather than integer values. This will help
228
- in futur improvment.
229
- Introduction of error handling functions like errorCode(), errorName() and errorInfo().
230
- - Remove the deprecated use of calling function with arguments passed by reference.
231
- - Add the calling of extract(), extractByIndex(), create() and add() functions
232
- with variable options rather than fixed arguments.
233
- - Add the ability to remove all the file path while extracting or adding,
234
- without any need to specify the path to remove.
235
- This is available for extract(), extractByIndex(), create() and add() functionS by using
236
- the new variable options parameters :
237
- - PCLZIP_OPT_REMOVE_ALL_PATH : by indicating this option while calling the fct.
238
- - Ability to change the mode of a file after the extraction (chmod()).
239
- This is available for extract() and extractByIndex() functionS by using
240
- the new variable options parameters.
241
- - PCLZIP_OPT_SET_CHMOD : by setting the value of this option.
242
- - Ability to definition call-back options. These call-back will be called during the adding,
243
- or the extracting of file (extract(), extractByIndex(), create() and add() functions) :
244
- - PCLZIP_CB_PRE_EXTRACT : will be called before each extraction of a file. The user
245
- can trigerred the change the filename of the extracted file. The user can triggered the
246
- skip of the extraction. This is adding a 'skipped' status in the file list result value.
247
- - PCLZIP_CB_POST_EXTRACT : will be called after each extraction of a file.
248
- Nothing can be triggered from that point.
249
- - PCLZIP_CB_PRE_ADD : will be called before each add of a file. The user
250
- can trigerred the change the stored filename of the added file. The user can triggered the
251
- skip of the add. This is adding a 'skipped' status in the file list result value.
252
- - PCLZIP_CB_POST_ADD : will be called after each add of a file.
253
- Nothing can be triggered from that point.
254
- - Two status are added in the file list returned as function result : skipped & filename_too_long
255
- 'skipped' is used when a call-back function ask for skipping the file.
256
- 'filename_too_long' is used while adding a file with a too long filename to archive (the file is
257
- not added)
258
- - Adding the function PclZipUtilPathInclusion(), that check the inclusion of a path into
259
- a directory.
260
- - Add a check of the presence of the archive file before some actions (like list, ...)
261
- - Add the initialisation of field "index" in header array. This means that by
262
- default index will be -1 when not explicitly set by the methods.
263
-
264
- Version 1.2 :
265
- - Adding a duplicate function.
266
- - Adding a merge function. The merge function is a "quick merge" function,
267
- it just append the content of an archive at the end of the first one. There
268
- is no check for duplicate files or more recent files.
269
- - Improve the search of the central directory end.
270
-
271
- Version 1.1.2 :
272
-
273
- - Changing the license of PclZip. PclZip is now released under the GNU / LGPL license
274
- (see License section).
275
- - Adding the optional support of a static temporary directory. You will need to configure
276
- the constant PCLZIP_TEMPORARY_DIR if you want to use this feature.
277
- - Improving the rename() function. In some cases rename() does not work (different
278
- Filesystems), so it will be replaced by a copy() + unlink() functions.
279
-
280
- Version 1.1.1 :
281
-
282
- - Maintenance release, no new feature.
283
-
284
- Version 1.1 :
285
-
286
- - New method Add() : adding files in the archive
287
- - New method ExtractByIndex() : partial extract of the archive, files are identified by
288
- their index in the archive
289
- - New method DeleteByIndex() : delete some files/folder entries from the archive,
290
- files are identified by their index in the archive.
291
- - Adding a test of the zlib extension presence. If not present abort the script.
292
-
293
- Version 1.0.1 :
294
-
295
- - No new feature
296
-
297
-
298
- 3 - Corrected bugs
299
- ==================
300
-
301
- Corrected in Version 2.0 :
302
- - Corrected : During an extraction, if a call-back fucntion is used and try to skip
303
- a file, all the extraction process is stopped.
304
-
305
- Corrected in Version 1.3 :
306
- - Corrected : Support of static synopsis for method extract() is broken.
307
- - Corrected : invalid size of archive content field (0xFF) should be (0xFFFF).
308
- - Corrected : When an extract is done with a remove_path parameter, the entry for
309
- the directory with exactly the same path is not skipped/filtered.
310
- - Corrected : extractByIndex() and deleteByIndex() were not managing index in the
311
- right way. For example indexes '1,3-5,11' will only extract files 1 and 11. This
312
- is due to a sort of the index resulting table that puts 11 before 3-5 (sort on
313
- string and not interger). The sort is temporarilly removed, this means that
314
- you must provide a sorted list of index ranges.
315
-
316
- Corrected in Version 1.2 :
317
-
318
- - Nothing.
319
-
320
- Corrected in Version 1.1.2 :
321
-
322
- - Corrected : Winzip is unable to delete or add new files in a PclZip created archives.
323
-
324
- Corrected in Version 1.1.1 :
325
-
326
- - Corrected : When archived file is not compressed (0% compression), the
327
- extract method fails.
328
-
329
- Corrected in Version 1.1 :
330
-
331
- - Corrected : Adding a complete tree of folder may result in a bad archive
332
- creation.
333
-
334
- Corrected in Version 1.0.1 :
335
-
336
- - Corrected : Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).
337
-
338
-
339
- 4 - Known bugs or limitations
340
- =============================
341
-
342
- Please publish bugs reports in SourceForge :
343
- http://sourceforge.net/tracker/?group_id=40254&atid=427564
344
-
345
- In Version 2.x :
346
- - PclZip does only support file uncompressed or compressed with deflate (compression method 8)
347
- - PclZip does not support password protected zip archive
348
- - Some concern were seen when changing mtime of a file while archiving.
349
- Seems to be linked to Daylight Saving Time (PclTest_changing_mtime).
350
-
351
- In Version 1.2 :
352
-
353
- - merge() methods does not check for duplicate files or last date of modifications.
354
-
355
- In Version 1.1 :
356
-
357
- - Limitation : Using 'extract' fields in the file header in the zip archive is not supported.
358
- - WinZip is unable to delete a single file in a PclZip created archive. It is also unable to
359
- add a file in a PclZip created archive. (Corrected in v.1.2)
360
-
361
- In Version 1.0.1 :
362
-
363
- - Adding a complete tree of folder may result in a bad archive
364
- creation. (Corrected in V.1.1).
365
- - Path given to methods must be in the unix format (/) and not the Windows format (\).
366
- Workaround : Use only / directory separators.
367
- - PclZip is using temporary files that are sometime the name of the file with a .tmp or .gz
368
- added suffix. Files with these names may already exist and may be overwritten.
369
- Workaround : none.
370
- - PclZip does not check if the zlib extension is present. If it is absent, the zip
371
- file is not created and the lib abort without warning.
372
- Workaround : enable the zlib extension on the php install
373
-
374
- In Version 1.0 :
375
-
376
- - Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).
377
- (Corrected in v.1.0.1)
378
- - Limitation : Multi-disk zip archive are not supported.
379
-
380
-
381
- 5 - License
382
- ===========
383
-
384
- Since version 1.1.2, PclZip Library is released under GNU/LGPL license.
385
- This library is free, so you can use it at no cost.
386
-
387
- HOWEVER, if you release a script, an application, a library or any kind of
388
- code using PclZip library (or a part of it), YOU MUST :
389
- - Indicate in the documentation (or a readme file), that your work
390
- uses PclZip Library, and make a reference to the author and the web site
391
- http://www.phpconcept.net
392
- - Gives the ability to the final user to update the PclZip libary.
393
-
394
- I will also appreciate that you send me a mail (vincent@phpconcept.net), just to
395
- be aware that someone is using PclZip.
396
-
397
- For more information about GNU/LGPL license : http://www.gnu.org
398
-
399
- 6 - Warning
400
- =================
401
-
402
- This library and the associated files are non commercial, non professional work.
403
- It should not have unexpected results. However if any damage is caused by this software
404
- the author can not be responsible.
405
- The use of this software is at the risk of the user.
406
-
407
- 7 - Documentation
408
- =================
409
- PclZip User Manuel is available in English on PhpConcept : http://www.phpconcept.net/pclzip/man/en/index.php
410
- A Russian translation was done by Feskov Kuzma : http://php.russofile.ru/ru/authors/unsort/zip/
411
-
412
- 8 - Author
413
- ==========
414
-
415
- This software was written by Vincent Blavet (vincent@phpconcept.net) on its leasure time.
416
-
417
- 9 - Contribute
418
- ==============
419
- If you want to contribute to the development of PclZip, please contact vincent@phpconcept.net.
420
- If you can help in financing PhpConcept hosting service, please go to
421
- http://www.phpconcept.net/soutien.php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/view/assets/css/backup.min.css ADDED
@@ -0,0 +1 @@
 
1
+ @charset "UTF-8";.ai1wm-divider{-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;border:none;height:0;background-color:transparent;font-size:14px;font-weight:700;text-align:center;text-transform:uppercase;color:rgba(0,0,0,.8);position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,.1);border-bottom:1px solid rgba(255,255,255,.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}@-webkit-keyframes ai1wm-rotate{0%{-webkit-transform:rotateZ(0);transform:rotateZ(0)}25%{-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg)}50%{-webkit-transform:rotateZ(180deg);transform:rotateZ(180deg)}75%{-webkit-transform:rotateZ(270deg);transform:rotateZ(270deg)}100%{-webkit-transform:rotateZ(360deg);transform:rotateZ(360deg)}}@keyframes ai1wm-rotate{0%{-webkit-transform:rotateZ(0);transform:rotateZ(0)}25%{-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg)}50%{-webkit-transform:rotateZ(180deg);transform:rotateZ(180deg)}75%{-webkit-transform:rotateZ(270deg);transform:rotateZ(270deg)}100%{-webkit-transform:rotateZ(360deg);transform:rotateZ(360deg)}}@-webkit-keyframes ai1wm-emphasize{0%{-webkit-transform:scale(1);transform:scale(1)}50%{-webkit-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes ai1wm-emphasize{0%{-webkit-transform:scale(1);transform:scale(1)}50%{-webkit-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes ai1wm-fadein{0%{-webkit-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.5);transform:scale(1.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes ai1wm-fadein{0%{-webkit-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.5);transform:scale(1.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-file-zip:before{content:"\e60f"}.ai1wm-icon-folder:before{content:"\e60e"}.ai1wm-icon-file:before{content:"\e60b"}.ai1wm-icon-file-content:before{content:"\e60c"}.ai1wm-icon-cloud-upload:before{content:"\e600"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-notification:before{content:"\e619"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-close:before{content:"\e61a"}.ai1wm-icon-wordpress2:before{content:"\e620"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-plus2:before{content:"\e607"}.ai1wm-icon-export:before{content:"\e601"}.ai1wm-icon-publish:before{content:"\e602"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-chevron-right:before{content:"\e60d"}.ai1wm-icon-chevron-down{display:inline-block;position:relative;-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg);margin-left:.5em!important}.ai1wm-icon-chevron-down:before{content:"\e60d"}.ai1wm-icon-dropbox:before{content:"\e606"}.ai1wm-icon-gear:before{content:"\e60a"}.ai1wm-icon-alone{margin:0!important}@media (min-width:855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;background-color:#f9f9f9;padding:20px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-right .ai1wm-segment h2{margin:22px 0 0;padding:0;font-weight:700;font-size:14px;text-transform:uppercase;text-align:center}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-holder{position:relative;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-holder h1{margin:0;padding:0;float:left;font-weight:300;font-size:22px;text-transform:uppercase}.ai1wm-holder h1 i{position:relative;top:2px}@media (max-width:854px){.ai1wm-container{margin-left:10px!important}.ai1wm-row,.ai1wm-right{margin-right:0!important}.ai1wm-right{float:left!important;width:100%!important;margin-top:18px}.ai1wm-right .ai1wm-sidebar{width:auto!important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px;border-radius:3px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-container{margin:20px 20px 0 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 #fff;border-radius:3px;color:#333;font-size:11px;font-weight:700;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:400;font-size:.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:400}.ai1wm-field-set{margin-top:18px}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,.6);height:auto;margin:10px 0;min-height:18px;padding:6px 10px;position:relative;border:1px solid;-webkit-transition:opacity .1s ease 0,color .1s ease 0,background .1s ease 0,box-shadow .1s ease 0;transition:opacity .1s ease 0s,color .1s ease 0s,background .1s ease 0s,box-shadow .1s ease 0s}.ai1wm-message.ai1wm-success-message{background-color:#F2F8F0;color:#119000;font-size:12px}.ai1wm-message.ai1wm-info-message{background-color:#d9edf7;color:#31708f;font-size:11px}.ai1wm-message.ai1wm-error-message{background-color:#F1D7D7;color:#A95252;font-size:12px}.ai1wm-message.ai1wm-red-message{color:#D95C5C;border:2px solid #D95C5C;background-color:transparent}.ai1wm-message.ai1wm-red-message h3{margin:.4em 0;color:#D95C5C}.ai1wm-message p{margin:4px 0;font-size:12px}.ai1wm-message-warning{display:block;font-size:14px;line-height:18px;padding:12px 20px;margin:0 0 22px;background-color:#f9f9f9;border:1px solid #d6d6d6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;border-left:4px solid #ffba00}.ai1wm-button-group{width:147px;border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;text-transform:uppercase;font-weight:600;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;display:inline-block}.ai1wm-button-group .ai1wm-button-main{padding:6px 25px 1px;height:22px}.ai1wm-button-group .ai1wm-dropdown-menu{height:0;overflow:hidden;-webkit-transition:height .2s cubic-bezier(.19,1,.22,1);transition:height .2s cubic-bezier(.19,1,.22,1);border-top:none}.ai1wm-button-group-import{width:158px!important}.ai1wm-open>.ai1wm-dropdown-menu{height:150px;border-top:1px solid #27ae60}.ai1wm-dropdown-menu{list-style:none}.ai1wm-dropdown-menu,.ai1wm-dropdown-menu li{margin:0!important;padding:0}.ai1wm-dropdown-menu li a,.ai1wm-dropdown-menu li a:visited{display:block;padding:6px 25px 1px 26px;height:22px;line-height:22px;text-decoration:none;color:#27ae60;text-align:left}.ai1wm-dropdown-menu li a:hover,.ai1wm-dropdown-menu li a:visited:hover{text-decoration:none;color:#111}.ai1mw-lines{-webkit-transform:translate(11px,-1px);transform:translate(11px,-1px);position:relative;display:inline-block;width:12px;height:10px}.ai1wm-line{display:inline-block;width:100%;height:2px;margin:auto;background:#27ae60;position:absolute;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.ai1wm-line-first{top:0}div.ai1wm-open .ai1wm-line-first,div.ai1wm-open .ai1wm-line-third,.ai1wm-line-second{top:50%}.ai1wm-line-third{top:100%}.ai1wm-button-gray{border:2px solid #95a5a6;background-color:transparent;color:#95a5a6;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-gray:hover{background-color:#95a5a6;color:#fff}.ai1wm-button-green{border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-green:hover{background-color:#27ae60;color:#fff}.ai1wm-button-green-small{border:2px solid #6eb649;background-color:transparent;color:#6eb649;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-green-small:hover{background-color:#6eb649;color:#fff}.ai1wm-button-blue{border:2px solid #00aff0;background-color:transparent;color:#00aff0;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-blue:hover{background-color:#00aff0;color:#fff}.ai1wm-button-red{border:2px solid #e74c3c;background-color:transparent;color:#e74c3c;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-red:hover{background-color:#e74c3c;color:#fff}.ai1wm-button-alone{border-radius:50px!important;padding:5px 8px!important}.ai1wm-button-blue[disabled="disabled"],.ai1wm-button-green[disabled="disabled"],.ai1wm-button-red[disabled="disabled"],.ai1wm-button-green-small[disabled="disabled"]{opacity:.6;cursor:default}.ai1wm-button-blue[disabled="disabled"]:hover{color:#00aff0}.ai1wm-button-red[disabled="disabled"]:hover{color:#e74c3c}.ai1wm-button-green[disabled="disabled"]:hover{color:#27ae60}.ai1wm-button-blue[disabled="disabled"]:hover,.ai1wm-button-green[disabled="disabled"]:hover,.ai1wm-button-red[disabled="disabled"]:hover,.ai1wm-button-green-small[disabled="disabled"]:hover{background:0 0}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i,.ai1wm-button-red i{margin-left:-.5em;margin-right:.2em}.ai1wm-message-close-button{position:absolute;right:10px;top:6px;text-decoration:none;font-size:10px}input[type="radio"].ai1wm-flat-radio-button{display:none}input[type="radio"].ai1wm-flat-radio-button+a i,input[type="radio"].ai1wm-flat-radio-button+label i{vertical-align:middle;float:left;width:25px;height:25px;border-radius:50%;background:0 0;border:2px solid #ccc;content:" ";cursor:pointer;position:relative;box-sizing:content-box}input[type="radio"].ai1wm-flat-radio-button:checked+a i,input[type="radio"].ai1wm-flat-radio-button:checked+label i{background-color:#d9d9d9;border-color:#6f6f6f}.ai1wm-clear{*zoom:1;clear:both}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-list-expanded{display:block!important}.ai1wm-field-inline input{border-radius:5px}.ai1wm-container .ai1wm-row label{position:relative;top:-1px}.ai1wm-share-button-container{text-align:center}.ai1wm-share-button-container .ai1wm-share-button{text-decoration:none;margin:10px;font-size:30px}.ai1wm-report-problem{position:relative;float:right}.ai1wm-report-problem-dialog{position:absolute;z-index:999;width:280px;right:0;background-color:#fff;margin:6px 0 0;padding:15px 15px 10px;border:1px solid #D6D6D6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;display:none}.ai1wm-report-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-report-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-report-cancel:link,.ai1wm-report-cancel:visited,.ai1wm-report-cancel:active,.ai1wm-feedback-cancel:link,.ai1wm-feedback-cancel:visited,.ai1wm-feedback-cancel:active{float:right;line-height:34px;outline:0;text-decoration:none;color:#e74c3c}.ai1wm-report-active{display:block}.ai1wm-report-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-report-terms-segment>.ai1wm-report-terms{border-radius:3px}.ai1wm-no-underline{text-decoration:none}.ai1wm-top-negative-four{top:-4px}.ai1wm-feedback-form{display:none}.ai1wm-feedback-types{margin:0;padding:0;list-style:none}.ai1wm-feedback-types li{margin:14px 0;padding:0}.ai1wm-feedback-types>li>label>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-feedback-types>li>a{height:29px;outline:none;color:#333;text-deciration:none}.ai1wm-feedback-types>li>a>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-loader{display:inline-block;width:128px;height:128px;position:relative;-webkit-animation:ai1wm-rotate 1s infinite linear;animation:ai1wm-rotate 1s infinite linear;background:url("../img/logo.svg") no-repeat center center}.ai1wm-hide{display:none}#ai1wm-backup-progress{background-color:#dfdfdf;height:20px;width:350px;border-radius:15px}#ai1wm-backup-progress-bar{background-color:#00aff0;height:20px;line-height:20px;border-radius:15px;color:#fff;width:0;text-align:center}.ai1wm-backups{width:100%;margin:20px 0 0;padding:0;border-collapse:collapse}.ai1wm-backups .ai1wm-column-name{text-align:left}.ai1wm-backups .ai1wm-column-date,.ai1wm-backups .ai1wm-column-size{text-align:center}.ai1wm-backups .ai1wm-column-actions{text-align:right}.ai1wm-backups thead th{padding:4px 6px;text-align:left;font-size:1.2em}.ai1wm-backups tbody tr:first-child{border-top:1px solid #ccc}.ai1wm-backups tbody tr{border-bottom:1px solid #ccc}.ai1wm-backups tbody tr:hover{background:rgba(0,0,0,.1)}.ai1wm-backups tbody td{padding:4px 6px;box-sizing:border-box;line-height:36px}.ai1wm-backups tbody td span{font-weight:700}.ai1wm-backups tbody td.ai1wm-backup-actions{text-align:right;width:250px}.ai1wm-backups tbody td.ai1wm-backup-actions a{margin-left:4px}.ai1wm-backups tbody td.ai1wm-backup-actions span{-webkit-transition:width 2s cubic-bezier(.19,1,.22,1);transition:width 2s cubic-bezier(.19,1,.22,1);display:inline-block;width:0;text-align:center;visibility:hidden}.ai1wm-backups tbody td.ai1wm-backup-actions .ai1wm-button-on span{width:80px;visibility:visible}
lib/view/assets/css/export.min.css CHANGED
@@ -1 +1 @@
1
- @charset "UTF-8";.ai1wm-divider{-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;border:none;height:0;background-color:transparent;font-size:14px;font-weight:700;text-align:center;text-transform:uppercase;color:rgba(0,0,0,.8);position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,.1);border-bottom:1px solid rgba(255,255,255,.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-cloud-upload:before{content:"\e600"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-notification:before{content:"\e619"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-close:before{content:"\e61a"}.ai1wm-icon-wordpress2:before{content:"\e620"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-plus2:before{content:"\e607"}.ai1wm-icon-export:before{content:"\e601"}.ai1wm-icon-publish:before{content:"\e602"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-chevron-right:before{content:"\e60d"}@media (min-width:855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;background-color:#f9f9f9;padding:20px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-right .ai1wm-segment h2{margin:22px 0 0;padding:0;font-weight:700;font-size:14px;text-transform:uppercase;text-align:center}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-holder{position:relative;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-holder h1{margin:0;padding:0;float:left;font-weight:300;font-size:22px;text-transform:uppercase}.ai1wm-holder h1 i{position:relative;top:2px}@media (max-width:854px){.ai1wm-container{margin-left:10px!important}.ai1wm-row,.ai1wm-right{margin-right:0!important}.ai1wm-right{float:left!important;width:100%!important;margin-top:18px}.ai1wm-right .ai1wm-sidebar{width:auto!important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px;border-radius:3px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-container{margin:20px 20px 0 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 #fff;border-radius:3px;color:#333;font-size:11px;font-weight:700;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:400;font-size:.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:400}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,.6);height:auto;margin:10px 0;min-height:18px;padding:6px 10px;position:relative;border:1px solid;-webkit-transition:opacity .1s ease 0,color .1s ease 0,background .1s ease 0,box-shadow .1s ease 0;transition:opacity .1s ease 0s,color .1s ease 0s,background .1s ease 0s,box-shadow .1s ease 0s}.ai1wm-message.ai1wm-success-message{background-color:#F2F8F0;color:#119000;font-size:12px}.ai1wm-message.ai1wm-info-message{background-color:#d9edf7;color:#31708f;font-size:11px}.ai1wm-message.ai1wm-error-message{background-color:#F1D7D7;color:#A95252;font-size:12px}.ai1wm-message.ai1wm-red-message{color:#D95C5C;border:2px solid #D95C5C;background-color:transparent}.ai1wm-message.ai1wm-red-message h3{margin:0 0 .5em;color:#D95C5C}.ai1wm-message p{margin:4px 0;font-size:12px}.ai1wm-button-gray{border:2px solid #95a5a6;background-color:transparent;color:#95a5a6;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-gray:hover{background-color:#95a5a6;color:#fff}.ai1wm-button-green{border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-green:hover{background-color:#27ae60;color:#fff}.ai1wm-button-green-small{border:2px solid #6eb649;background-color:transparent;color:#6eb649;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-green-small:hover{background-color:#6eb649;color:#fff}.ai1wm-button-blue{border:2px solid #00aff0;background-color:transparent;color:#00aff0;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-blue:hover{background-color:#00aff0;color:#fff}.ai1wm-button-red{border:2px solid #e74c3c;background-color:transparent;color:#e74c3c;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-red:hover{background-color:#e74c3c;color:#fff}.ai1wm-button-red[disabled="disabled"]{color:#f8c9c4;border-color:#f8c9c4;cursor:default}.ai1wm-button-red[disabled="disabled"]:hover{background:0 0}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i,.ai1wm-button-red i{margin-left:-.5em;margin-right:.2em}.ai1wm-message-close-button{position:absolute;right:10px;top:6px;text-decoration:none;font-size:10px}input[type="radio"].ai1wm-flat-radio-button{display:none}input[type="radio"].ai1wm-flat-radio-button+a i,input[type="radio"].ai1wm-flat-radio-button+label i{vertical-align:middle;float:left;width:25px;height:25px;border-radius:50%;background:0 0;border:2px solid #ccc;content:" ";cursor:pointer;position:relative;box-sizing:content-box}input[type="radio"].ai1wm-flat-radio-button:checked+a i,input[type="radio"].ai1wm-flat-radio-button:checked+label i{background-color:#d9d9d9;border-color:#6f6f6f}.ai1wm-clear{*zoom:1;clear:both}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-field-inline input{border-radius:5px}.ai1wm-container .ai1wm-row label{position:relative;top:-1px}.ai1wm-share-button-container{text-align:center}.ai1wm-share-button-container .ai1wm-share-button{text-decoration:none;margin:10px;font-size:30px}.ai1wm-report-problem{position:relative;float:right}.ai1wm-report-problem-dialog{position:absolute;z-index:999;width:280px;right:0;background-color:#fff;margin:6px 0 0;padding:15px 15px 10px;border:1px solid #D6D6D6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;display:none}.ai1wm-report-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-report-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-report-cancel:link,.ai1wm-report-cancel:visited,.ai1wm-report-cancel:active,.ai1wm-feedback-cancel:link,.ai1wm-feedback-cancel:visited,.ai1wm-feedback-cancel:active{float:right;line-height:34px;outline:0;text-decoration:none;color:#e74c3c}.ai1wm-report-active{display:block}.ai1wm-report-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-report-terms-segment>.ai1wm-report-terms{border-radius:3px}.ai1wm-no-underline{text-decoration:none}.ai1wm-update-nag{display:block;font-size:14px;line-height:18px;padding:12px 20px;margin:0 0 22px;background-color:#f9f9f9;border:1px solid #d6d6d6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;border-left:4px solid #ffba00}.ai1wm-top-negative-four{top:-4px}.ai1wm-feedback-form{display:none}.ai1wm-feedback-types{margin:0;padding:0;list-style:none}.ai1wm-feedback-types li{margin:14px 0;padding:0}.ai1wm-feedback-types>li>label{height:29px}.ai1wm-feedback-types>li>label>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-feedback-types>li>a{height:29px;outline:none;color:#333;text-deciration:none}.ai1wm-feedback-types>li>a>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-accordion{margin:1em 0}.ai1wm-accordion .ai1wm-title{cursor:pointer;float:left;color:rgba(0,116,162,.8)}.ai1wm-accordion .ai1wm-title:after{clear:both}.ai1wm-accordion .ai1wm-title:hover{color:rgba(0,116,162,.8)}.ai1wm-accordion .ai1wm-title h4{margin:0}.ai1wm-accordion .ai1wm-title h4 small{color:#444;font-weight:400}.ai1wm-accordion .ai1wm-title .ai1wm-icon-arrow-right{-webkit-transition:-webkit-transform .1s ease-out;transition:transform .1s ease-out}.ai1wm-accordion .ai1wm-content{display:none;margin:.6em 0 0 2em}.ai1wm-accordion.ai1wm-active .ai1wm-title .ai1wm-icon-arrow-right{-webkit-transform:rotate(90deg);transform:rotate(90deg);display:inline-block}.ai1wm-accordion.ai1wm-active .ai1wm-content{display:block}.ai1wm-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.6);z-index:100001}.ai1wm-modal{position:fixed;display:block;visibility:hidden;top:50%;left:50%;z-index:100002;width:360px;padding:16px;transform:translate(-180px,-180px);-webkit-transform:translate(-180px,-180px);border:1px solid #fff;box-shadow:0 2px 6px #292929;-moz-box-shadow:0 2px 6px #292929;-webkit-box-shadow:0 2px 6px #292929;border-radius:6px;-moz-border-radius:6px;-webkit-border-radius:6px;background:#f6f6f6;box-sizing:border-box}.ai1wm-modal-content{clear:both;overflow:hidden}.ai1wm-modal-content-middle{clear:both;overflow:hidden;text-align:center}.ai1wm-modal-action{margin-top:16px;text-align:center}.ai1wm-modal-social-button{display:inline-block;text-decoration:none;margin:10px 20px}.ai1wm-modal-social-button .ai1wm-icon-facebook2,.ai1wm-modal-social-button .ai1wm-icon-wordpress2{font-size:40px}.ai1wm-modal-left{text-align:center;width:162px;border-right:1px solid #ddd;float:left;padding:10px 0 11px}.ai1wm-modal-right{text-align:center;padding-top:3px;width:163px;float:left}#ai1wm-export-now-button{text-transform:uppercase;width:50%}.ai1wm-not-visible{visibility:hidden}.ai1wm-not-visible .fb-like span,.ai1wm-not-visible .fb-like iframe{visibility:hidden!important}.ai1wm-visible{visibility:visible}.ai1wm-loader{background:url("../img/ajax-loader.gif?v=1");width:31px;height:31px;display:inline-block}#ai1wm-export-form ul{margin:10px 0 0}#ai1wm-export-form ul li{margin-bottom:10px}.ai1wm-collapse-arrow{position:relative;top:4px;float:right}.ai1wm-expanded{background:#ebebeb!important}.ai1wm-expanded p small{border-bottom:1px dashed #000}.ai1wm-expanded div{display:block!important}.ai1wm-expanded input{width:100%;font-weight:400;font-size:.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px;border:1px solid #ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);background-color:#fff;color:#333;-webkit-transition:.05s border-color ease-in-out;transition:.05s border-color ease-in-out;border-radius:5px}.ai1wm-expanded input:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.ai1wm-expanded .ai1wm-collapse-arrow{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.ai1wm-collapsable{width:100%;margin:0;list-style:none;background:0 0;border:1px solid #d8d8d8;padding:10px;border-radius:5px;box-sizing:border-box}.ai1wm-collapsable div{display:none;margin-top:8px}.ai1wm-collapsable p{margin:0;cursor:pointer}.ai1wm-collapse-arrow{-webkit-transition:-webkit-transform .1s ease-out;transition:transform .1s ease-out}.ai1wm-include-tables{display:inline-block;width:300px;margin:0 6px 0 0}.ai1wm-include-plugins{display:inline-block;width:300px;vertical-align:top}.ai1wm-include-media{display:inline-block;width:300px;margin:0 6px 0 0}.ai1wm-include-themes{display:inline-block;width:300px;vertical-align:top}.ai1wm-export-stats{margin-bottom:1em}
1
+ @charset "UTF-8";.ai1wm-divider{-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;border:none;height:0;background-color:transparent;font-size:14px;font-weight:700;text-align:center;text-transform:uppercase;color:rgba(0,0,0,.8);position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,.1);border-bottom:1px solid rgba(255,255,255,.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}@-webkit-keyframes ai1wm-rotate{0%{-webkit-transform:rotateZ(0);transform:rotateZ(0)}25%{-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg)}50%{-webkit-transform:rotateZ(180deg);transform:rotateZ(180deg)}75%{-webkit-transform:rotateZ(270deg);transform:rotateZ(270deg)}100%{-webkit-transform:rotateZ(360deg);transform:rotateZ(360deg)}}@keyframes ai1wm-rotate{0%{-webkit-transform:rotateZ(0);transform:rotateZ(0)}25%{-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg)}50%{-webkit-transform:rotateZ(180deg);transform:rotateZ(180deg)}75%{-webkit-transform:rotateZ(270deg);transform:rotateZ(270deg)}100%{-webkit-transform:rotateZ(360deg);transform:rotateZ(360deg)}}@-webkit-keyframes ai1wm-emphasize{0%{-webkit-transform:scale(1);transform:scale(1)}50%{-webkit-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes ai1wm-emphasize{0%{-webkit-transform:scale(1);transform:scale(1)}50%{-webkit-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes ai1wm-fadein{0%{-webkit-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.5);transform:scale(1.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes ai1wm-fadein{0%{-webkit-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.5);transform:scale(1.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-file-zip:before{content:"\e60f"}.ai1wm-icon-folder:before{content:"\e60e"}.ai1wm-icon-file:before{content:"\e60b"}.ai1wm-icon-file-content:before{content:"\e60c"}.ai1wm-icon-cloud-upload:before{content:"\e600"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-notification:before{content:"\e619"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-close:before{content:"\e61a"}.ai1wm-icon-wordpress2:before{content:"\e620"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-plus2:before{content:"\e607"}.ai1wm-icon-export:before{content:"\e601"}.ai1wm-icon-publish:before{content:"\e602"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-chevron-right:before{content:"\e60d"}.ai1wm-icon-chevron-down{display:inline-block;position:relative;-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg);margin-left:.5em!important}.ai1wm-icon-chevron-down:before{content:"\e60d"}.ai1wm-icon-dropbox:before{content:"\e606"}.ai1wm-icon-gear:before{content:"\e60a"}.ai1wm-icon-alone{margin:0!important}@media (min-width:855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;background-color:#f9f9f9;padding:20px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-right .ai1wm-segment h2{margin:22px 0 0;padding:0;font-weight:700;font-size:14px;text-transform:uppercase;text-align:center}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-holder{position:relative;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-holder h1{margin:0;padding:0;float:left;font-weight:300;font-size:22px;text-transform:uppercase}.ai1wm-holder h1 i{position:relative;top:2px}@media (max-width:854px){.ai1wm-container{margin-left:10px!important}.ai1wm-row,.ai1wm-right{margin-right:0!important}.ai1wm-right{float:left!important;width:100%!important;margin-top:18px}.ai1wm-right .ai1wm-sidebar{width:auto!important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px;border-radius:3px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-container{margin:20px 20px 0 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 #fff;border-radius:3px;color:#333;font-size:11px;font-weight:700;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:400;font-size:.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:400}.ai1wm-field-set{margin-top:18px}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,.6);height:auto;margin:10px 0;min-height:18px;padding:6px 10px;position:relative;border:1px solid;-webkit-transition:opacity .1s ease 0,color .1s ease 0,background .1s ease 0,box-shadow .1s ease 0;transition:opacity .1s ease 0s,color .1s ease 0s,background .1s ease 0s,box-shadow .1s ease 0s}.ai1wm-message.ai1wm-success-message{background-color:#F2F8F0;color:#119000;font-size:12px}.ai1wm-message.ai1wm-info-message{background-color:#d9edf7;color:#31708f;font-size:11px}.ai1wm-message.ai1wm-error-message{background-color:#F1D7D7;color:#A95252;font-size:12px}.ai1wm-message.ai1wm-red-message{color:#D95C5C;border:2px solid #D95C5C;background-color:transparent}.ai1wm-message.ai1wm-red-message h3{margin:.4em 0;color:#D95C5C}.ai1wm-message p{margin:4px 0;font-size:12px}.ai1wm-message-warning{display:block;font-size:14px;line-height:18px;padding:12px 20px;margin:0 0 22px;background-color:#f9f9f9;border:1px solid #d6d6d6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;border-left:4px solid #ffba00}.ai1wm-button-group{width:147px;border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;text-transform:uppercase;font-weight:600;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;display:inline-block}.ai1wm-button-group .ai1wm-button-main{padding:6px 25px 1px;height:22px}.ai1wm-button-group .ai1wm-dropdown-menu{height:0;overflow:hidden;-webkit-transition:height .2s cubic-bezier(.19,1,.22,1);transition:height .2s cubic-bezier(.19,1,.22,1);border-top:none}.ai1wm-button-group-import{width:158px!important}.ai1wm-open>.ai1wm-dropdown-menu{height:150px;border-top:1px solid #27ae60}.ai1wm-dropdown-menu{list-style:none}.ai1wm-dropdown-menu,.ai1wm-dropdown-menu li{margin:0!important;padding:0}.ai1wm-dropdown-menu li a,.ai1wm-dropdown-menu li a:visited{display:block;padding:6px 25px 1px 26px;height:22px;line-height:22px;text-decoration:none;color:#27ae60;text-align:left}.ai1wm-dropdown-menu li a:hover,.ai1wm-dropdown-menu li a:visited:hover{text-decoration:none;color:#111}.ai1mw-lines{-webkit-transform:translate(11px,-1px);transform:translate(11px,-1px);position:relative;display:inline-block;width:12px;height:10px}.ai1wm-line{display:inline-block;width:100%;height:2px;margin:auto;background:#27ae60;position:absolute;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.ai1wm-line-first{top:0}div.ai1wm-open .ai1wm-line-first,div.ai1wm-open .ai1wm-line-third,.ai1wm-line-second{top:50%}.ai1wm-line-third{top:100%}.ai1wm-button-gray{border:2px solid #95a5a6;background-color:transparent;color:#95a5a6;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-gray:hover{background-color:#95a5a6;color:#fff}.ai1wm-button-green{border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-green:hover{background-color:#27ae60;color:#fff}.ai1wm-button-green-small{border:2px solid #6eb649;background-color:transparent;color:#6eb649;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-green-small:hover{background-color:#6eb649;color:#fff}.ai1wm-button-blue{border:2px solid #00aff0;background-color:transparent;color:#00aff0;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-blue:hover{background-color:#00aff0;color:#fff}.ai1wm-button-red{border:2px solid #e74c3c;background-color:transparent;color:#e74c3c;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-red:hover{background-color:#e74c3c;color:#fff}.ai1wm-button-alone{border-radius:50px!important;padding:5px 8px!important}.ai1wm-button-blue[disabled="disabled"],.ai1wm-button-green[disabled="disabled"],.ai1wm-button-red[disabled="disabled"],.ai1wm-button-green-small[disabled="disabled"]{opacity:.6;cursor:default}.ai1wm-button-blue[disabled="disabled"]:hover{color:#00aff0}.ai1wm-button-red[disabled="disabled"]:hover{color:#e74c3c}.ai1wm-button-green[disabled="disabled"]:hover{color:#27ae60}.ai1wm-button-blue[disabled="disabled"]:hover,.ai1wm-button-green[disabled="disabled"]:hover,.ai1wm-button-red[disabled="disabled"]:hover,.ai1wm-button-green-small[disabled="disabled"]:hover{background:0 0}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i,.ai1wm-button-red i{margin-left:-.5em;margin-right:.2em}.ai1wm-message-close-button{position:absolute;right:10px;top:6px;text-decoration:none;font-size:10px}input[type="radio"].ai1wm-flat-radio-button{display:none}input[type="radio"].ai1wm-flat-radio-button+a i,input[type="radio"].ai1wm-flat-radio-button+label i{vertical-align:middle;float:left;width:25px;height:25px;border-radius:50%;background:0 0;border:2px solid #ccc;content:" ";cursor:pointer;position:relative;box-sizing:content-box}input[type="radio"].ai1wm-flat-radio-button:checked+a i,input[type="radio"].ai1wm-flat-radio-button:checked+label i{background-color:#d9d9d9;border-color:#6f6f6f}.ai1wm-clear{*zoom:1;clear:both}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-list-expanded{display:block!important}.ai1wm-field-inline input{border-radius:5px}.ai1wm-container .ai1wm-row label{position:relative;top:-1px}.ai1wm-share-button-container{text-align:center}.ai1wm-share-button-container .ai1wm-share-button{text-decoration:none;margin:10px;font-size:30px}.ai1wm-report-problem{position:relative;float:right}.ai1wm-report-problem-dialog{position:absolute;z-index:999;width:280px;right:0;background-color:#fff;margin:6px 0 0;padding:15px 15px 10px;border:1px solid #D6D6D6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;display:none}.ai1wm-report-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-report-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-report-cancel:link,.ai1wm-report-cancel:visited,.ai1wm-report-cancel:active,.ai1wm-feedback-cancel:link,.ai1wm-feedback-cancel:visited,.ai1wm-feedback-cancel:active{float:right;line-height:34px;outline:0;text-decoration:none;color:#e74c3c}.ai1wm-report-active{display:block}.ai1wm-report-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-report-terms-segment>.ai1wm-report-terms{border-radius:3px}.ai1wm-no-underline{text-decoration:none}.ai1wm-top-negative-four{top:-4px}.ai1wm-feedback-form{display:none}.ai1wm-feedback-types{margin:0;padding:0;list-style:none}.ai1wm-feedback-types li{margin:14px 0;padding:0}.ai1wm-feedback-types>li>label>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-feedback-types>li>a{height:29px;outline:none;color:#333;text-deciration:none}.ai1wm-feedback-types>li>a>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-loader{display:inline-block;width:128px;height:128px;position:relative;-webkit-animation:ai1wm-rotate 1s infinite linear;animation:ai1wm-rotate 1s infinite linear;background:url("../img/logo.svg") no-repeat center center}.ai1wm-hide{display:none}@keyframes ai1wm-rotate{0%{-webkit-transform:rotateZ(0);transform:rotateZ(0)}25%{-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg)}50%{-webkit-transform:rotateZ(180deg);transform:rotateZ(180deg)}75%{-webkit-transform:rotateZ(270deg);transform:rotateZ(270deg)}100%{-webkit-transform:rotateZ(360deg);transform:rotateZ(360deg)}}@keyframes ai1wm-emphasize{0%{-webkit-transform:scale(1);transform:scale(1)}50%{-webkit-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes ai1wm-fadein{0%{-webkit-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.5);transform:scale(1.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}.ai1wm-accordion{margin:1em 0;display:block}.ai1wm-accordion h4{cursor:pointer;color:rgba(0,116,162,.8);margin:0}.ai1wm-accordion h4 small{color:#444;font-weight:400}.ai1wm-accordion .ai1wm-icon-arrow-right{-webkit-transition:-webkit-transform .1s ease-out;transition:transform .1s ease-out}.ai1wm-accordion ul{margin:0;padding:0;list-style:none;visibility:hidden;height:0;-webkit-transition:height .2s cubic-bezier(.19,1,.22,1);transition:height .2s cubic-bezier(.19,1,.22,1)}.ai1wm-accordion.ai1wm-open h4 .ai1wm-icon-arrow-right{-webkit-transform:rotate(90deg);transform:rotate(90deg);display:inline-block}.ai1wm-accordion.ai1wm-open ul{height:auto;margin:.6em 0 0 2em;visibility:visible}.ai1wm-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.7);z-index:100001}.ai1wm-modal-container{position:fixed;display:none;top:50%;left:50%;z-index:100002;width:480px;height:auto;padding:16px;-webkit-transform:translate(-240px,-94px);transform:translate(-240px,-94px);border:1px solid #fff;box-shadow:0 2px 6px #292929;border-radius:6px;background:#f6f6f6;box-sizing:border-box;text-align:center}.ai1wm-modal-container section{display:block;min-height:102px}.ai1wm-modal-container section h1{margin:0;padding:0}.ai1wm-modal-container section h1 .ai1wm-title-green{color:#27ae60;font-size:20px}.ai1wm-modal-container section h1 .ai1wm-title-red{color:#e74c3c;font-size:20px}.ai1wm-modal-container section h1 .ai1wm-loader{width:64px;height:64px}.ai1wm-modal-container section h1 .ai1wm-icon-notification{font-size:1.2em;color:#e74c3c}.ai1wm-modal-container section p{margin:0;padding:12px 0}.ai1wm-modal-container section p .ai1wm-modal-subtitle-green{color:#27ae60}.ai1wm-modal-container section p .ai1wm-modal-subtitle-red{color:#e74c3c}.ai1wm-modal-container section p .ai1wm-modal-subdescription{display:block;text-align:left}.ai1wm-modal-container section p a.ai1wm-button-green{display:inline-block;position:relative;top:26px}.ai1wm-modal-container section p a.ai1wm-emphasize{-webkit-animation:ai1wm-emphasize 1s infinite;animation:ai1wm-emphasize 1s infinite}.ai1wm-modal-container section p em{display:block;color:#34495e;font-style:normal}.ai1wm-query-arrow{position:relative;top:4px;float:right}.ai1wm-query.ai1wm-open{background:#ebebeb!important}.ai1wm-query.ai1wm-open p small{border-bottom:1px dashed #000}.ai1wm-query.ai1wm-open div{visibility:visible!important;height:82px!important;margin-top:8px}.ai1wm-query.ai1wm-open .ai1wm-query-arrow{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.ai1wm-query{width:100%;margin:0 0 10px;list-style:none;background:0 0;border:1px solid #d8d8d8;padding:10px;border-radius:5px;box-sizing:border-box}.ai1wm-query div{-webkit-transition:height .2s cubic-bezier(.19,1,.22,1);transition:height .2s cubic-bezier(.19,1,.22,1);visibility:hidden;height:0}.ai1wm-query div input{width:100%;font-weight:400;font-size:.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px;border:1px solid #ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);background-color:#fff;color:#333;-webkit-transition:.05s border-color ease-in-out;transition:.05s border-color ease-in-out;border-radius:5px}.ai1wm-query div input:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.ai1wm-query p{margin:0;cursor:pointer}.ai1wm-query p small{display:inline;width:auto;float:none}.ai1wm-query-arrow{-webkit-transition:-webkit-transform .1s ease-out;transition:transform .1s ease-out}.ai1wm-include-tables{display:inline-block;width:300px;margin:0 6px 0 0}.ai1wm-include-plugins{display:inline-block;width:300px;vertical-align:top}.ai1wm-include-media{display:inline-block;width:300px;margin:0 6px 0 0}.ai1wm-include-themes{display:inline-block;width:300px;vertical-align:top}.ai1wm-export-stats{margin-bottom:1em}#ai1wm-export-download{display:none;margin:0 0 2em}#ai1wm-export-download-stop{display:inline-block;margin:0 0 2em}#ai1wm-export-download.ai1wm-active{display:inline-block;-webkit-animation:ai1wm-fadein .5s;animation:ai1wm-fadein .5s}#ai1wm-export-download.ai1wm-emphasize{display:inline-block;-webkit-animation:ai1wm-emphasize 1s infinite;animation:ai1wm-emphasize 1s infinite}#ai1wm-export-download-size{display:block;color:#34495e}
lib/view/assets/css/import.min.css CHANGED
@@ -1 +1 @@
1
- @charset "UTF-8";.ai1wm-divider{-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;border:none;height:0;background-color:transparent;font-size:14px;font-weight:700;text-align:center;text-transform:uppercase;color:rgba(0,0,0,.8);position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,.1);border-bottom:1px solid rgba(255,255,255,.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-cloud-upload:before{content:"\e600"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-notification:before{content:"\e619"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-close:before{content:"\e61a"}.ai1wm-icon-wordpress2:before{content:"\e620"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-plus2:before{content:"\e607"}.ai1wm-icon-export:before{content:"\e601"}.ai1wm-icon-publish:before{content:"\e602"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-chevron-right:before{content:"\e60d"}@media (min-width:855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;background-color:#f9f9f9;padding:20px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-right .ai1wm-segment h2{margin:22px 0 0;padding:0;font-weight:700;font-size:14px;text-transform:uppercase;text-align:center}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-holder{position:relative;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-holder h1{margin:0;padding:0;float:left;font-weight:300;font-size:22px;text-transform:uppercase}.ai1wm-holder h1 i{position:relative;top:2px}@media (max-width:854px){.ai1wm-container{margin-left:10px!important}.ai1wm-row,.ai1wm-right{margin-right:0!important}.ai1wm-right{float:left!important;width:100%!important;margin-top:18px}.ai1wm-right .ai1wm-sidebar{width:auto!important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px;border-radius:3px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-container{margin:20px 20px 0 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 #fff;border-radius:3px;color:#333;font-size:11px;font-weight:700;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:400;font-size:.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:400}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,.6);height:auto;margin:10px 0;min-height:18px;padding:6px 10px;position:relative;border:1px solid;-webkit-transition:opacity .1s ease 0,color .1s ease 0,background .1s ease 0,box-shadow .1s ease 0;transition:opacity .1s ease 0s,color .1s ease 0s,background .1s ease 0s,box-shadow .1s ease 0s}.ai1wm-message.ai1wm-success-message{background-color:#F2F8F0;color:#119000;font-size:12px}.ai1wm-message.ai1wm-info-message{background-color:#d9edf7;color:#31708f;font-size:11px}.ai1wm-message.ai1wm-error-message{background-color:#F1D7D7;color:#A95252;font-size:12px}.ai1wm-message.ai1wm-red-message{color:#D95C5C;border:2px solid #D95C5C;background-color:transparent}.ai1wm-message.ai1wm-red-message h3{margin:0 0 .5em;color:#D95C5C}.ai1wm-message p{margin:4px 0;font-size:12px}.ai1wm-button-gray{border:2px solid #95a5a6;background-color:transparent;color:#95a5a6;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-gray:hover{background-color:#95a5a6;color:#fff}.ai1wm-button-green{border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-green:hover{background-color:#27ae60;color:#fff}.ai1wm-button-green-small{border:2px solid #6eb649;background-color:transparent;color:#6eb649;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-green-small:hover{background-color:#6eb649;color:#fff}.ai1wm-button-blue{border:2px solid #00aff0;background-color:transparent;color:#00aff0;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-blue:hover{background-color:#00aff0;color:#fff}.ai1wm-button-red{border:2px solid #e74c3c;background-color:transparent;color:#e74c3c;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out}.ai1wm-button-red:hover{background-color:#e74c3c;color:#fff}.ai1wm-button-red[disabled="disabled"]{color:#f8c9c4;border-color:#f8c9c4;cursor:default}.ai1wm-button-red[disabled="disabled"]:hover{background:0 0}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i,.ai1wm-button-red i{margin-left:-.5em;margin-right:.2em}.ai1wm-message-close-button{position:absolute;right:10px;top:6px;text-decoration:none;font-size:10px}input[type="radio"].ai1wm-flat-radio-button{display:none}input[type="radio"].ai1wm-flat-radio-button+a i,input[type="radio"].ai1wm-flat-radio-button+label i{vertical-align:middle;float:left;width:25px;height:25px;border-radius:50%;background:0 0;border:2px solid #ccc;content:" ";cursor:pointer;position:relative;box-sizing:content-box}input[type="radio"].ai1wm-flat-radio-button:checked+a i,input[type="radio"].ai1wm-flat-radio-button:checked+label i{background-color:#d9d9d9;border-color:#6f6f6f}.ai1wm-clear{*zoom:1;clear:both}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-field-inline input{border-radius:5px}.ai1wm-container .ai1wm-row label{position:relative;top:-1px}.ai1wm-share-button-container{text-align:center}.ai1wm-share-button-container .ai1wm-share-button{text-decoration:none;margin:10px;font-size:30px}.ai1wm-report-problem{position:relative;float:right}.ai1wm-report-problem-dialog{position:absolute;z-index:999;width:280px;right:0;background-color:#fff;margin:6px 0 0;padding:15px 15px 10px;border:1px solid #D6D6D6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;display:none}.ai1wm-report-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-report-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-report-cancel:link,.ai1wm-report-cancel:visited,.ai1wm-report-cancel:active,.ai1wm-feedback-cancel:link,.ai1wm-feedback-cancel:visited,.ai1wm-feedback-cancel:active{float:right;line-height:34px;outline:0;text-decoration:none;color:#e74c3c}.ai1wm-report-active{display:block}.ai1wm-report-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-report-terms-segment>.ai1wm-report-terms{border-radius:3px}.ai1wm-no-underline{text-decoration:none}.ai1wm-update-nag{display:block;font-size:14px;line-height:18px;padding:12px 20px;margin:0 0 22px;background-color:#f9f9f9;border:1px solid #d6d6d6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;border-left:4px solid #ffba00}.ai1wm-top-negative-four{top:-4px}.ai1wm-feedback-form{display:none}.ai1wm-feedback-types{margin:0;padding:0;list-style:none}.ai1wm-feedback-types li{margin:14px 0;padding:0}.ai1wm-feedback-types>li>label{height:29px}.ai1wm-feedback-types>li>label>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-feedback-types>li>a{height:29px;outline:none;color:#333;text-deciration:none}.ai1wm-feedback-types>li>a>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-drag-drop-area{border:4px dashed #ddd;height:200px;margin:20px 0 16px;background:#fff;text-align:center}.ai1wm-drag-drop-area.dragover{background:rgba(255,255,255,.4);border-color:green}.ai1wm-drag-over .ai1wm-drag-drop-area{border-color:#83b4d8}.ai1wm-upload-form{position:relative}#ai1wm-upload-init{position:absolute;top:10px;left:10%;width:80%;text-align:center}#ai1wm-upload-init>p{font-size:18px;color:#9e9e9e}#ai1wm-upload-init>p>i{font-size:46px}#ai1wm-upload-in-progress{position:absolute;top:40px;text-align:center;width:80%;left:10%;display:none}#ai1wm-upload-in-progress>p{font-size:18px;color:#9e9e9e}#ai1wm-upload-in-progress>p>strong{font-weight:700}#ai1wm-upload-progress{background-color:#ebebeb;height:30px;margin:0 auto;border-radius:15px}#ai1wm-upload-progress-bar{background-color:#62da3e;height:30px;line-height:30px;border-radius:15px;font-weight:700;font-size:16px;color:#fff;width:0}#ai1wm-install-text,#ai1wm-complete-text{display:none}.ai1wm-label{border:1px solid #5cb85c;background-color:transparent;color:#5cb85c;cursor:pointer;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;padding:.2em .6em;font-size:.8em;border-radius:5px}.ai1wm-label:hover{background-color:#5cb85c;color:#fff}.ai1wm-unlimited-import a{text-decoration:none}.ai1wm-max-upload-size{border-bottom:1px solid #000}
1
+ @charset "UTF-8";.ai1wm-divider{-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;border:none;height:0;background-color:transparent;font-size:14px;font-weight:700;text-align:center;text-transform:uppercase;color:rgba(0,0,0,.8);position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,.1);border-bottom:1px solid rgba(255,255,255,.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}@-webkit-keyframes ai1wm-rotate{0%{-webkit-transform:rotateZ(0);transform:rotateZ(0)}25%{-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg)}50%{-webkit-transform:rotateZ(180deg);transform:rotateZ(180deg)}75%{-webkit-transform:rotateZ(270deg);transform:rotateZ(270deg)}100%{-webkit-transform:rotateZ(360deg);transform:rotateZ(360deg)}}@keyframes ai1wm-rotate{0%{-webkit-transform:rotateZ(0);transform:rotateZ(0)}25%{-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg)}50%{-webkit-transform:rotateZ(180deg);transform:rotateZ(180deg)}75%{-webkit-transform:rotateZ(270deg);transform:rotateZ(270deg)}100%{-webkit-transform:rotateZ(360deg);transform:rotateZ(360deg)}}@-webkit-keyframes ai1wm-emphasize{0%{-webkit-transform:scale(1);transform:scale(1)}50%{-webkit-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes ai1wm-emphasize{0%{-webkit-transform:scale(1);transform:scale(1)}50%{-webkit-transform:scale(1.2);transform:scale(1.2)}100%{-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes ai1wm-fadein{0%{-webkit-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.5);transform:scale(1.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes ai1wm-fadein{0%{-webkit-transform:scale(0);transform:scale(0)}50%{-webkit-transform:scale(1.5);transform:scale(1.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-file-zip:before{content:"\e60f"}.ai1wm-icon-folder:before{content:"\e60e"}.ai1wm-icon-file:before{content:"\e60b"}.ai1wm-icon-file-content:before{content:"\e60c"}.ai1wm-icon-cloud-upload:before{content:"\e600"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-notification:before{content:"\e619"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-close:before{content:"\e61a"}.ai1wm-icon-wordpress2:before{content:"\e620"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-plus2:before{content:"\e607"}.ai1wm-icon-export:before{content:"\e601"}.ai1wm-icon-publish:before{content:"\e602"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-chevron-right:before{content:"\e60d"}.ai1wm-icon-chevron-down{display:inline-block;position:relative;-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg);margin-left:.5em!important}.ai1wm-icon-chevron-down:before{content:"\e60d"}.ai1wm-icon-dropbox:before{content:"\e606"}.ai1wm-icon-gear:before{content:"\e60a"}.ai1wm-icon-alone{margin:0!important}@media (min-width:855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;background-color:#f9f9f9;padding:20px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-right .ai1wm-segment h2{margin:22px 0 0;padding:0;font-weight:700;font-size:14px;text-transform:uppercase;text-align:center}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-holder{position:relative;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-holder h1{margin:0;padding:0;float:left;font-weight:300;font-size:22px;text-transform:uppercase}.ai1wm-holder h1 i{position:relative;top:2px}@media (max-width:854px){.ai1wm-container{margin-left:10px!important}.ai1wm-row,.ai1wm-right{margin-right:0!important}.ai1wm-right{float:left!important;width:100%!important;margin-top:18px}.ai1wm-right .ai1wm-sidebar{width:auto!important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;padding:20px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px;border-radius:3px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-container{margin:20px 20px 0 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 #fff;border-radius:3px;color:#333;font-size:11px;font-weight:700;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:400;font-size:.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:400}.ai1wm-field-set{margin-top:18px}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,.6);height:auto;margin:10px 0;min-height:18px;padding:6px 10px;position:relative;border:1px solid;-webkit-transition:opacity .1s ease 0,color .1s ease 0,background .1s ease 0,box-shadow .1s ease 0;transition:opacity .1s ease 0s,color .1s ease 0s,background .1s ease 0s,box-shadow .1s ease 0s}.ai1wm-message.ai1wm-success-message{background-color:#F2F8F0;color:#119000;font-size:12px}.ai1wm-message.ai1wm-info-message{background-color:#d9edf7;color:#31708f;font-size:11px}.ai1wm-message.ai1wm-error-message{background-color:#F1D7D7;color:#A95252;font-size:12px}.ai1wm-message.ai1wm-red-message{color:#D95C5C;border:2px solid #D95C5C;background-color:transparent}.ai1wm-message.ai1wm-red-message h3{margin:.4em 0;color:#D95C5C}.ai1wm-message p{margin:4px 0;font-size:12px}.ai1wm-message-warning{display:block;font-size:14px;line-height:18px;padding:12px 20px;margin:0 0 22px;background-color:#f9f9f9;border:1px solid #d6d6d6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;border-left:4px solid #ffba00}.ai1wm-button-group{width:147px;border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;text-transform:uppercase;font-weight:600;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;display:inline-block}.ai1wm-button-group .ai1wm-button-main{padding:6px 25px 1px;height:22px}.ai1wm-button-group .ai1wm-dropdown-menu{height:0;overflow:hidden;-webkit-transition:height .2s cubic-bezier(.19,1,.22,1);transition:height .2s cubic-bezier(.19,1,.22,1);border-top:none}.ai1wm-button-group-import{width:158px!important}.ai1wm-open>.ai1wm-dropdown-menu{height:150px;border-top:1px solid #27ae60}.ai1wm-dropdown-menu{list-style:none}.ai1wm-dropdown-menu,.ai1wm-dropdown-menu li{margin:0!important;padding:0}.ai1wm-dropdown-menu li a,.ai1wm-dropdown-menu li a:visited{display:block;padding:6px 25px 1px 26px;height:22px;line-height:22px;text-decoration:none;color:#27ae60;text-align:left}.ai1wm-dropdown-menu li a:hover,.ai1wm-dropdown-menu li a:visited:hover{text-decoration:none;color:#111}.ai1mw-lines{-webkit-transform:translate(11px,-1px);transform:translate(11px,-1px);position:relative;display:inline-block;width:12px;height:10px}.ai1wm-line{display:inline-block;width:100%;height:2px;margin:auto;background:#27ae60;position:absolute;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.ai1wm-line-first{top:0}div.ai1wm-open .ai1wm-line-first,div.ai1wm-open .ai1wm-line-third,.ai1wm-line-second{top:50%}.ai1wm-line-third{top:100%}.ai1wm-button-gray{border:2px solid #95a5a6;background-color:transparent;color:#95a5a6;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-gray:hover{background-color:#95a5a6;color:#fff}.ai1wm-button-green{border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-green:hover{background-color:#27ae60;color:#fff}.ai1wm-button-green-small{border:2px solid #6eb649;background-color:transparent;color:#6eb649;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-green-small:hover{background-color:#6eb649;color:#fff}.ai1wm-button-blue{border:2px solid #00aff0;background-color:transparent;color:#00aff0;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-blue:hover{background-color:#00aff0;color:#fff}.ai1wm-button-red{border:2px solid #e74c3c;background-color:transparent;color:#e74c3c;border-radius:5px;cursor:pointer;padding:5px 25px 5px 26px;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-red:hover{background-color:#e74c3c;color:#fff}.ai1wm-button-alone{border-radius:50px!important;padding:5px 8px!important}.ai1wm-button-blue[disabled="disabled"],.ai1wm-button-green[disabled="disabled"],.ai1wm-button-red[disabled="disabled"],.ai1wm-button-green-small[disabled="disabled"]{opacity:.6;cursor:default}.ai1wm-button-blue[disabled="disabled"]:hover{color:#00aff0}.ai1wm-button-red[disabled="disabled"]:hover{color:#e74c3c}.ai1wm-button-green[disabled="disabled"]:hover{color:#27ae60}.ai1wm-button-blue[disabled="disabled"]:hover,.ai1wm-button-green[disabled="disabled"]:hover,.ai1wm-button-red[disabled="disabled"]:hover,.ai1wm-button-green-small[disabled="disabled"]:hover{background:0 0}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i,.ai1wm-button-red i{margin-left:-.5em;margin-right:.2em}.ai1wm-message-close-button{position:absolute;right:10px;top:6px;text-decoration:none;font-size:10px}input[type="radio"].ai1wm-flat-radio-button{display:none}input[type="radio"].ai1wm-flat-radio-button+a i,input[type="radio"].ai1wm-flat-radio-button+label i{vertical-align:middle;float:left;width:25px;height:25px;border-radius:50%;background:0 0;border:2px solid #ccc;content:" ";cursor:pointer;position:relative;box-sizing:content-box}input[type="radio"].ai1wm-flat-radio-button:checked+a i,input[type="radio"].ai1wm-flat-radio-button:checked+label i{background-color:#d9d9d9;border-color:#6f6f6f}.ai1wm-clear{*zoom:1;clear:both}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-list-expanded{display:block!important}.ai1wm-field-inline input{border-radius:5px}.ai1wm-container .ai1wm-row label{position:relative;top:-1px}.ai1wm-share-button-container{text-align:center}.ai1wm-share-button-container .ai1wm-share-button{text-decoration:none;margin:10px;font-size:30px}.ai1wm-report-problem{position:relative;float:right}.ai1wm-report-problem-dialog{position:absolute;z-index:999;width:280px;right:0;background-color:#fff;margin:6px 0 0;padding:15px 15px 10px;border:1px solid #D6D6D6;border-radius:3px;box-shadow:0 1px 0 0 #fff inset;display:none}.ai1wm-report-email{width:100%;font-weight:400;font-size:.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-report-message{width:100%;border-radius:3px;font-size:.8rem;padding:6px 10px;resize:none}.ai1wm-report-cancel:link,.ai1wm-report-cancel:visited,.ai1wm-report-cancel:active,.ai1wm-feedback-cancel:link,.ai1wm-feedback-cancel:visited,.ai1wm-feedback-cancel:active{float:right;line-height:34px;outline:0;text-decoration:none;color:#e74c3c}.ai1wm-report-active{display:block}.ai1wm-report-terms-segment{font-size:.7rem;line-height:1rem;margin:4px 0 8px}.ai1wm-report-terms-segment>.ai1wm-report-terms{border-radius:3px}.ai1wm-no-underline{text-decoration:none}.ai1wm-top-negative-four{top:-4px}.ai1wm-feedback-form{display:none}.ai1wm-feedback-types{margin:0;padding:0;list-style:none}.ai1wm-feedback-types li{margin:14px 0;padding:0}.ai1wm-feedback-types>li>label>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-feedback-types>li>a{height:29px;outline:none;color:#333;text-deciration:none}.ai1wm-feedback-types>li>a>span{display:inline-block;padding:5px 0 6px 8px}.ai1wm-loader{display:inline-block;width:128px;height:128px;position:relative;-webkit-animation:ai1wm-rotate 1s infinite linear;animation:ai1wm-rotate 1s infinite linear;background:url("../img/logo.svg") no-repeat center center}.ai1wm-hide{display:none}.ai1wm-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.7);z-index:100001}.ai1wm-modal-container{position:fixed;display:none;top:50%;left:50%;z-index:100002;width:480px;height:auto;padding:16px;-webkit-transform:translate(-240px,-94px);transform:translate(-240px,-94px);border:1px solid #fff;box-shadow:0 2px 6px #292929;border-radius:6px;background:#f6f6f6;box-sizing:border-box;text-align:center}.ai1wm-modal-container section{display:block;min-height:102px}.ai1wm-modal-container section h1{margin:0;padding:0}.ai1wm-modal-container section h1 .ai1wm-title-green{color:#27ae60;font-size:20px}.ai1wm-modal-container section h1 .ai1wm-title-red{color:#e74c3c;font-size:20px}.ai1wm-modal-container section h1 .ai1wm-loader{width:64px;height:64px}.ai1wm-modal-container section h1 .ai1wm-icon-notification{font-size:1.2em;color:#e74c3c}.ai1wm-modal-container section p{margin:0;padding:12px 0}.ai1wm-modal-container section p .ai1wm-modal-subtitle-green{color:#27ae60}.ai1wm-modal-container section p .ai1wm-modal-subtitle-red{color:#e74c3c}.ai1wm-modal-container section p .ai1wm-modal-subdescription{display:block;text-align:left}.ai1wm-modal-container section p a.ai1wm-button-green{display:inline-block;position:relative;top:26px}.ai1wm-modal-container section p a.ai1wm-emphasize{-webkit-animation:ai1wm-emphasize 1s infinite;animation:ai1wm-emphasize 1s infinite}.ai1wm-modal-container section p em{display:block;color:#34495e;font-style:normal}.ai1wm-growl-info{position:fixed;z-index:200000;top:0;margin-top:16px;right:16px;width:200px;padding:16px;background:#f1c40f;border:1px solid #e67e22;border-radius:5px;color:#111}.ai1wm-drag-drop-area{border:3px dashed #ddd;height:200px;margin:20px 0 16px;background:#fff;text-align:center;border-radius:30px}.ai1wm-drag-drop-area.dragover{background:rgba(255,255,255,.4);border-color:green}.ai1wm-drag-over .ai1wm-drag-drop-area{border-color:#83b4d8}.ai1wm-import-form{position:relative}#ai1wm-import-init{position:absolute;top:10px;left:10%;width:80%;text-align:center}#ai1wm-import-init>p{font-size:18px;color:#9e9e9e}#ai1wm-import-init>p>i{font-size:46px}.ai1wm-label{border:1px solid #5cb85c;background-color:transparent;color:#5cb85c;cursor:pointer;text-transform:uppercase;font-weight:600;outline:none;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;padding:.2em .6em;font-size:.8em;border-radius:5px}.ai1wm-label:hover{background-color:#5cb85c;color:#fff}.ai1wm-unlimited-import a{text-decoration:none}.ai1wm-max-upload-size{border-bottom:1px solid #000}.ai1wm-progress-bar{position:relative;display:inline-block;background-color:#bdc3c7;height:32px;width:100%;border-radius:15px;top:35px}.ai1wm-progress-bar-meter{background-color:#2ecc71;border-radius:15px;width:0;text-align:center}.ai1wm-progress-bar-meter,.ai1wm-progress-bar-percent{display:inline-block;float:left;height:32px;line-height:32px;color:#fff}.ai1wm-progress-bar-percent{position:absolute;width:50px;left:50%;-webkit-transform:translate(-24px,0);transform:translate(-24px,0);font-size:.5em;background:0 0}
lib/view/assets/font/servmask.eot CHANGED
Binary file
lib/view/assets/font/servmask.svg CHANGED
@@ -12,10 +12,16 @@
12
  <glyph unicode="&#xe603;" d="M288 448c123.712 0 224-100.288 224-224s-100.288-224-224-224v48c47.012 0 91.209 18.307 124.451 51.549s51.549 77.439 51.549 124.451c0 47.011-18.307 91.209-51.549 124.451s-77.439 51.549-124.451 51.549c-47.011 0-91.209-18.307-124.451-51.549-25.57-25.569-42.291-57.623-48.653-92.451h93.104l-112-128-112 128h82.285c15.53 108.551 108.869 192 221.715 192zM384 256v-64h-128v160h64v-96z" />
13
  <glyph unicode="&#xe604;" d="M512 224c0 141.385-114.615 256-256 256s-256-114.615-256-256 114.615-256 256-256 256 114.615 256 256zM48 224c0 114.875 93.125 208 208 208s208-93.125 208-208-93.125-208-208-208-208 93.125-208 208zM278.627 73.372l128 128.001c12.497 12.496 12.497 32.757 0 45.254s-32.758 12.497-45.255 0l-73.372-73.372v178.745c0 17.673-14.327 32-32 32s-32-14.327-32-32v-178.745l-73.372 73.373c-12.497 12.497-32.759 12.497-45.256 0-6.248-6.249-9.372-14.439-9.372-22.628s3.124-16.379 9.372-22.627l128-128.001c12.497-12.496 32.759-12.496 45.255 0z" />
14
  <glyph unicode="&#xe605;" d="M153.625 348.16l-0.025-235.52 204.8 117.76z" />
 
15
  <glyph unicode="&#xe607;" d="M256 445.44c-118.784 0-215.040-96.307-215.040-215.040 0-118.784 96.281-215.040 215.040-215.040s215.040 96.281 215.040 215.040c0 118.758-96.281 215.040-215.040 215.040zM282.163 204.237v-103.091h-52.327v103.091h-103.117v52.327h103.091v103.117h52.352v-103.091h103.091v-52.352h-103.091z" />
16
  <glyph unicode="&#xe608;" d="M504.688 477.44c-2.656 1.712-5.68 2.56-8.688 2.56-3.088 0-6.192-0.88-8.88-2.688l-480-320c-4.944-3.28-7.664-9.056-7.024-14.976 0.608-5.904 4.448-11.008 9.968-13.184l125.184-50.096 58.864-103.008c2.816-4.944 8.048-8 13.712-8.064 0.064 0 0.112 0 0.176 0 5.616 0 10.832 2.976 13.712 7.776l33.232 55.408 155.12-62.032c1.904-0.768 3.904-1.136 5.936-1.136 2.72 0 5.408 0.688 7.84 2.064 4.224 2.368 7.12 6.528 7.936 11.312l80 480c1.040 6.288-1.744 12.592-7.088 16.064zM50.176 147.568l370.8 247.216-269.6-288.592c-1.424 0.848-2.688 1.968-4.256 2.592l-96.944 38.784zM163.024 94.944c-0.032 0.064-0.080 0.096-0.112 0.16l303.088 324.4-258.384-402.592-44.592 78.032zM403.472 6.256l-136.656 54.656c-3.248 1.28-6.624 1.712-9.968 1.904l210.432 326.208-63.808-382.768z" />
17
  <glyph unicode="&#xe609;" d="M256-23.273c-141.382 0-256 114.618-256 256s114.618 256 256 256 256-114.618 256-256-114.618-256-256-256zM256 442.182c-115.689 0-209.454-93.766-209.454-209.455s93.766-209.454 209.454-209.454 209.454 93.766 209.454 209.454-93.766 209.455-209.454 209.455zM279.272 189.487c0-12.753 0-26.577 0-26.577h-46.546c0 0 0 33.675 0 46.546s10.426 23.272 23.273 23.272v0c25.693 0 46.545 20.852 46.545 46.546s-20.853 46.546-46.546 46.546-46.546-20.852-46.546-46.546c0-8.518 2.444-16.407 6.447-23.272h-49.688c-1.955 7.47-3.304 15.197-3.304 23.272 0 51.41 41.681 93.091 93.091 93.091s93.091-41.681 93.091-93.091c0-43.31-29.719-79.406-69.818-89.786zM279.272 93.091h-46.546v46.546h46.546v-46.546z" />
 
 
 
18
  <glyph unicode="&#xe60d;" d="M314 237.714q0-14.857-10.572-26l-186.286-186q-10.572-10.572-25.715-10.572t-25.715 10.572l-21.715 21.428q-10.572 11.143-10.572 26 0 15.143 10.572 25.714l138.857 138.857-138.857 138.572q-10.572 11.143-10.572 26 0 15.143 10.572 25.714l21.715 21.428q10.285 10.857 25.715 10.857t25.715-10.857l186.286-186q10.572-10.571 10.572-25.714z" horiz-adv-x="329" />
 
 
19
  <glyph unicode="&#xe619;" d="M256 432c-55.559 0-107.792-21.636-147.078-60.922s-60.922-91.519-60.922-147.078c0-55.559 21.636-107.792 60.922-147.078s91.519-60.922 147.078-60.922c55.559 0 107.792 21.636 147.078 60.922s60.922 91.519 60.922 147.078c0 55.559-21.636 107.792-60.922 147.078s-91.519 60.922-147.078 60.922zM256 480v0c141.385 0 256-114.615 256-256s-114.615-256-256-256c-141.385 0-256 114.615-256 256s114.615 256 256 256zM224 128h64v-64h-64zM224 384h64v-192h-64z" />
20
  <glyph unicode="&#xe61a;" d="M507.331 68.67c-0.002 0.002-0.004 0.004-0.006 0.005l-155.322 155.325 155.322 155.325c0.002 0.002 0.004 0.003 0.006 0.005 1.672 1.673 2.881 3.627 3.656 5.708 2.123 5.688 0.912 12.341-3.662 16.915l-73.373 73.373c-4.574 4.573-11.225 5.783-16.914 3.66-2.080-0.775-4.035-1.984-5.709-3.655 0-0.002-0.002-0.003-0.004-0.005l-155.324-155.326-155.324 155.325c-0.002 0.002-0.003 0.003-0.005 0.005-1.673 1.671-3.627 2.88-5.707 3.655-5.69 2.124-12.341 0.913-16.915-3.66l-73.374-73.374c-4.574-4.574-5.784-11.226-3.661-16.914 0.776-2.080 1.985-4.036 3.656-5.708 0.002-0.001 0.003-0.003 0.005-0.005l155.325-155.324-155.325-155.326c-0.001-0.002-0.003-0.003-0.004-0.005-1.671-1.673-2.88-3.627-3.657-5.707-2.124-5.688-0.913-12.341 3.661-16.915l73.374-73.373c4.575-4.574 11.226-5.784 16.915-3.661 2.080 0.776 4.035 1.985 5.708 3.656 0.001 0.002 0.003 0.003 0.005 0.005l155.324 155.325 155.324-155.325c0.002-0.001 0.004-0.003 0.006-0.004 1.674-1.672 3.627-2.881 5.707-3.657 5.689-2.123 12.342-0.913 16.914 3.661l73.373 73.374c4.574 4.574 5.785 11.227 3.662 16.915-0.776 2.080-1.985 4.034-3.657 5.707z" />
21
  <glyph unicode="&#xe620;" d="M259.371 207.648l59.015-157.471c0.389-0.925 0.866-1.775 1.375-2.577-19.956-6.841-41.402-10.6-63.759-10.6-18.847 0-37.036 2.69-54.244 7.619l57.613 163.029zM448 224.003c0-68.985-38.388-129.215-95.47-161.629l58.643 165.136c10.956 26.677 14.602 48.010 14.602 66.975 0 6.886-0.469 13.274-1.294 19.229 14.989-26.631 23.519-57.196 23.519-89.711zM64 224.004c0 27.112 5.972 52.849 16.626 76.103l91.589-244.392c-64.054 30.305-108.215 94.276-108.215 168.289zM95.582 326.716c34.329 50.761 93.342 84.284 160.422 84.284 49.984 0 95.496-18.613 129.654-49.098-0.828 0.049-1.635 0.151-2.488 0.151-18.86 0-32.243-16.001-32.243-33.188 0-15.411 9.131-28.448 18.86-43.858 7.3-12.453 15.827-28.454 15.827-51.571 0-16.001-6.318-34.575-14.608-60.45l-19.156-62.316-69.39 201.009c11.558 0.589 21.974 1.775 21.974 1.775 10.347 1.194 9.129 16.002-1.223 15.411 0 0-31.102-2.376-51.175-2.376-18.867 0-50.567 2.376-50.567 2.376-10.355 0.59-11.57-14.815-1.219-15.411 0 0 9.795-1.183 20.139-1.775l29.911-79.825-42.022-122.728-69.917 202.553c11.571 0.591 21.976 1.775 21.976 1.775 10.337 1.194 9.116 16.002-1.229 15.411 0 0-31.093-2.376-51.17-2.376-3.603 0-7.851 0.086-12.356 0.227zM426 480h-340c-47.3 0-86-38.7-86-86v-340c0-47.3 38.7-86 86-86h340c47.3 0 86 38.7 86 86v340c0 47.3-38.7 86-86 86zM480 224c0-123.712-100.288-224-224-224s-224 100.288-224 224 100.288 224 224 224 224-100.288 224-224z" />
12
  <glyph unicode="&#xe603;" d="M288 448c123.712 0 224-100.288 224-224s-100.288-224-224-224v48c47.012 0 91.209 18.307 124.451 51.549s51.549 77.439 51.549 124.451c0 47.011-18.307 91.209-51.549 124.451s-77.439 51.549-124.451 51.549c-47.011 0-91.209-18.307-124.451-51.549-25.57-25.569-42.291-57.623-48.653-92.451h93.104l-112-128-112 128h82.285c15.53 108.551 108.869 192 221.715 192zM384 256v-64h-128v160h64v-96z" />
13
  <glyph unicode="&#xe604;" d="M512 224c0 141.385-114.615 256-256 256s-256-114.615-256-256 114.615-256 256-256 256 114.615 256 256zM48 224c0 114.875 93.125 208 208 208s208-93.125 208-208-93.125-208-208-208-208 93.125-208 208zM278.627 73.372l128 128.001c12.497 12.496 12.497 32.757 0 45.254s-32.758 12.497-45.255 0l-73.372-73.372v178.745c0 17.673-14.327 32-32 32s-32-14.327-32-32v-178.745l-73.372 73.373c-12.497 12.497-32.759 12.497-45.256 0-6.248-6.249-9.372-14.439-9.372-22.628s3.124-16.379 9.372-22.627l128-128.001c12.497-12.496 32.759-12.496 45.255 0z" />
14
  <glyph unicode="&#xe605;" d="M153.625 348.16l-0.025-235.52 204.8 117.76z" />
15
+ <glyph unicode="&#xe606;" d="M18.285 196l96.572 77.428 141.143-87.143-97.714-81.428zM18.285 350.572l140 91.143 97.714-81.429-141.143-86.857zM116.285 84v30.857l42-27.428 97.714 81.143v0.572l0.286-0.286 0.286 0.286v-0.572l98-81.143 42 27.428v-30.857l-140-83.714v-0.286l-0.286 0.286-0.286-0.286v0.286zM256 186.286l141.143 87.143 96.572-77.428-139.714-91.143zM256 360.286l98 81.428 139.714-91.143-96.572-77.143z" />
16
  <glyph unicode="&#xe607;" d="M256 445.44c-118.784 0-215.040-96.307-215.040-215.040 0-118.784 96.281-215.040 215.040-215.040s215.040 96.281 215.040 215.040c0 118.758-96.281 215.040-215.040 215.040zM282.163 204.237v-103.091h-52.327v103.091h-103.117v52.327h103.091v103.117h52.352v-103.091h103.091v-52.352h-103.091z" />
17
  <glyph unicode="&#xe608;" d="M504.688 477.44c-2.656 1.712-5.68 2.56-8.688 2.56-3.088 0-6.192-0.88-8.88-2.688l-480-320c-4.944-3.28-7.664-9.056-7.024-14.976 0.608-5.904 4.448-11.008 9.968-13.184l125.184-50.096 58.864-103.008c2.816-4.944 8.048-8 13.712-8.064 0.064 0 0.112 0 0.176 0 5.616 0 10.832 2.976 13.712 7.776l33.232 55.408 155.12-62.032c1.904-0.768 3.904-1.136 5.936-1.136 2.72 0 5.408 0.688 7.84 2.064 4.224 2.368 7.12 6.528 7.936 11.312l80 480c1.040 6.288-1.744 12.592-7.088 16.064zM50.176 147.568l370.8 247.216-269.6-288.592c-1.424 0.848-2.688 1.968-4.256 2.592l-96.944 38.784zM163.024 94.944c-0.032 0.064-0.080 0.096-0.112 0.16l303.088 324.4-258.384-402.592-44.592 78.032zM403.472 6.256l-136.656 54.656c-3.248 1.28-6.624 1.712-9.968 1.904l210.432 326.208-63.808-382.768z" />
18
  <glyph unicode="&#xe609;" d="M256-23.273c-141.382 0-256 114.618-256 256s114.618 256 256 256 256-114.618 256-256-114.618-256-256-256zM256 442.182c-115.689 0-209.454-93.766-209.454-209.455s93.766-209.454 209.454-209.454 209.454 93.766 209.454 209.454-93.766 209.455-209.454 209.455zM279.272 189.487c0-12.753 0-26.577 0-26.577h-46.546c0 0 0 33.675 0 46.546s10.426 23.272 23.273 23.272v0c25.693 0 46.545 20.852 46.545 46.546s-20.853 46.546-46.546 46.546-46.546-20.852-46.546-46.546c0-8.518 2.444-16.407 6.447-23.272h-49.688c-1.955 7.47-3.304 15.197-3.304 23.272 0 51.41 41.681 93.091 93.091 93.091s93.091-41.681 93.091-93.091c0-43.31-29.719-79.406-69.818-89.786zM279.272 93.091h-46.546v46.546h46.546v-46.546z" />
19
+ <glyph unicode="&#xe60a;" d="M486.256 277.12l-49.024 9.824c-2.464 7.088-5.376 13.968-8.592 20.624l27.776 41.664c8.464 12.688 6.784 29.6-4 40.368l-30.784 30.784c-6.192 6.192-14.368 9.376-22.656 9.376-6.128 0-12.32-1.76-17.712-5.376l-41.664-27.76c-6.688 3.232-13.568 6.112-20.656 8.576l-9.824 49.040c-2.976 14.976-16.128 25.728-31.376 25.728h-43.52c-15.248 0-28.384-10.768-31.376-25.728l-9.824-49.040c-7.088-2.464-13.968-5.36-20.624-8.576l-41.648 27.76c-5.424 3.616-11.6 5.376-17.744 5.376-8.272 0-16.448-3.184-22.64-9.376l-30.768-30.784c-10.784-10.784-12.464-27.68-4-40.368l27.76-41.664c-3.232-6.672-6.112-13.552-8.576-20.64l-49.056-9.808c-14.96-2.992-25.728-16.128-25.728-31.376v-43.52c0-15.248 10.768-28.4 25.728-31.376l49.040-9.84c2.464-7.088 5.36-13.968 8.576-20.624l-27.744-41.664c-8.464-12.688-6.784-29.6 4-40.368l30.784-30.784c6.192-6.192 14.368-9.376 22.64-9.376 6.144 0 12.336 1.776 17.728 5.376l41.664 27.776c6.672-3.248 13.552-6.128 20.64-8.592l9.808-49.024c2.992-14.976 16.128-25.744 31.376-25.744h43.52c15.248 0 28.4 10.784 31.376 25.744l9.84 49.024c7.088 2.464 13.968 5.376 20.624 8.592l41.664-27.776c5.408-3.6 11.6-5.376 17.712-5.376 8.288 0 16.464 3.184 22.656 9.376l30.784 30.784c10.784 10.784 12.464 27.68 4 40.368l-27.776 41.664c3.248 6.688 6.128 13.568 8.592 20.656l49.024 9.808c14.96 2.96 25.744 16.128 25.744 31.376v43.52c0 15.248-10.784 28.384-25.744 31.376zM430.944 192.4c-11.12-2.224-20.224-10.16-23.936-20.88-2.064-5.904-4.464-11.632-7.152-17.184-4.976-10.224-4.128-22.288 2.16-31.712l27.776-41.664-30.784-30.784-41.664 27.776c-5.344 3.568-11.536 5.376-17.744 5.376-4.752 0-9.536-1.056-13.936-3.184-5.568-2.688-11.28-5.12-17.216-7.184-10.688-3.712-18.624-12.816-20.848-23.936l-9.84-49.056h-43.52l-9.808 49.056c-2.224 11.12-10.16 20.224-20.864 23.936-5.904 2.064-11.648 4.464-17.2 7.152-4.416 2.16-9.184 3.216-13.952 3.216-6.224 0-12.4-1.808-17.744-5.376l-41.664-27.776-30.784 30.784 27.76 41.664c6.288 9.44 7.104 21.504 2.192 31.68-2.688 5.568-5.104 11.28-7.168 17.216-3.712 10.688-12.832 18.624-23.936 20.848l-49.040 9.84-0.032 43.536 49.056 9.808c11.104 2.224 20.224 10.16 23.936 20.864 2.064 5.904 4.448 11.648 7.152 17.2 4.96 10.208 4.128 22.272-2.176 31.696l-27.744 41.664 30.768 30.784 41.664-27.76c5.344-3.568 11.536-5.376 17.744-5.376 4.752 0 9.52 1.056 13.936 3.184 5.552 2.688 11.28 5.104 17.2 7.168 10.704 3.712 18.64 12.832 20.864 23.936l9.824 49.040 43.52 0.016 9.808-49.056c2.224-11.104 10.16-20.224 20.88-23.936 5.904-2.064 11.632-4.448 17.184-7.152 4.432-2.144 9.184-3.2 13.968-3.2 6.224 0 12.4 1.808 17.744 5.376l41.664 27.76 30.784-30.784-27.776-41.664c-6.288-9.44-7.088-21.488-2.192-31.68 2.688-5.552 5.12-11.28 7.184-17.2 3.712-10.704 12.816-18.64 23.936-20.864l49.024-9.824 0.048-43.52-49.056-9.824zM256 335.984c-61.84 0-112-50.16-112-112 0-61.856 50.16-112 112-112s112 50.16 112 112c0 61.84-50.16 112-112 112zM256 125.968c-54.112 0-98 43.904-98 98 0 54.112 43.888 98 98 98 54.096 0 98-43.888 98-98 0-54.096-43.904-98-98-98zM256 287.984c-35.36 0-64-28.64-64-64 0-35.344 28.64-64 64-64 35.344 0 64 28.656 64 64s-28.656 64-64 64zM256 175.968c-26.496 0-48 21.504-48 48s21.504 48 48 48 48-21.504 48-48c0-26.496-21.504-48-48-48z" />
20
+ <glyph unicode="&#xe60b;" d="M446.059 385.941l-60.117 60.118c-18.669 18.668-55.542 33.941-81.942 33.941h-224c-26.4 0-48-21.6-48-48v-416c0-26.4 21.6-48 48-48h352c26.4 0 48 21.6 48 48v288c0 26.4-15.273 63.273-33.941 81.941zM320 412.219c1.098-0.402 2.226-0.84 3.379-1.318 9.030-3.741 15.299-8.088 17.308-10.097l60.118-60.119c2.009-2.009 6.356-8.277 10.097-17.307 0.478-1.153 0.916-2.281 1.318-3.378h-92.22v92.219zM416 32h-320v384h192v-128h128v-256z" />
21
+ <glyph unicode="&#xe60c;" d="M432 480h-384c-26.4 0-48-21.6-48-48v-416c0-26.4 21.6-48 48-48h384c26.4 0 48 21.6 48 48v416c0 26.4-21.6 48-48 48zM416 32h-352v384h352v-384zM128 256h224v-32h-224zM128 192h224v-32h-224zM128 128h224v-32h-224zM128 320h224v-32h-224z" />
22
  <glyph unicode="&#xe60d;" d="M314 237.714q0-14.857-10.572-26l-186.286-186q-10.572-10.572-25.715-10.572t-25.715 10.572l-21.715 21.428q-10.572 11.143-10.572 26 0 15.143 10.572 25.714l138.857 138.857-138.857 138.572q-10.572 11.143-10.572 26 0 15.143 10.572 25.714l21.715 21.428q10.285 10.857 25.715 10.857t25.715-10.857l186.286-186q10.572-10.571 10.572-25.714z" horiz-adv-x="329" />
23
+ <glyph unicode="&#xe60e;" d="M0 320h512l-32-320h-448l-32 320zM464 384l16-32h-448l32 64h176l16-32h208z" />
24
+ <glyph unicode="&#xe60f;" d="M208 416h48v-32h-48zM160 384h48v-32h-48zM208 352h48v-32h-48zM160 320h48v-32h-48zM208 288h48v-32h-48zM160 256h48v-32h-48zM208 224v-32h-48v-112c0-8.837 7.163-16 16-16h64c8.837 0 16 7.163 16 16v144h-48zM240 96h-64v32h64v-32zM451.716 380.285l-71.432 71.431c-15.556 15.556-46.284 28.284-68.284 28.284h-240c-22 0-40-18-40-40v-432c0-22 18-40 40-40h368c22 0 40 18 40 40v304c0 22-12.728 52.729-28.284 68.285zM429.089 357.657c1.565-1.565 3.125-3.487 4.64-5.657h-81.729v81.728c2.17-1.515 4.092-3.075 5.657-4.64l71.432-71.431zM448 8c0-4.336-3.664-8-8-8h-368c-4.336 0-8 3.664-8 8v432c0 4.336 3.664 8 8 8h240c2.416 0 5.127-0.305 8-0.852v-127.148h127.148c0.547-2.873 0.852-5.583 0.852-8v-304z" />
25
  <glyph unicode="&#xe619;" d="M256 432c-55.559 0-107.792-21.636-147.078-60.922s-60.922-91.519-60.922-147.078c0-55.559 21.636-107.792 60.922-147.078s91.519-60.922 147.078-60.922c55.559 0 107.792 21.636 147.078 60.922s60.922 91.519 60.922 147.078c0 55.559-21.636 107.792-60.922 147.078s-91.519 60.922-147.078 60.922zM256 480v0c141.385 0 256-114.615 256-256s-114.615-256-256-256c-141.385 0-256 114.615-256 256s114.615 256 256 256zM224 128h64v-64h-64zM224 384h64v-192h-64z" />
26
  <glyph unicode="&#xe61a;" d="M507.331 68.67c-0.002 0.002-0.004 0.004-0.006 0.005l-155.322 155.325 155.322 155.325c0.002 0.002 0.004 0.003 0.006 0.005 1.672 1.673 2.881 3.627 3.656 5.708 2.123 5.688 0.912 12.341-3.662 16.915l-73.373 73.373c-4.574 4.573-11.225 5.783-16.914 3.66-2.080-0.775-4.035-1.984-5.709-3.655 0-0.002-0.002-0.003-0.004-0.005l-155.324-155.326-155.324 155.325c-0.002 0.002-0.003 0.003-0.005 0.005-1.673 1.671-3.627 2.88-5.707 3.655-5.69 2.124-12.341 0.913-16.915-3.66l-73.374-73.374c-4.574-4.574-5.784-11.226-3.661-16.914 0.776-2.080 1.985-4.036 3.656-5.708 0.002-0.001 0.003-0.003 0.005-0.005l155.325-155.324-155.325-155.326c-0.001-0.002-0.003-0.003-0.004-0.005-1.671-1.673-2.88-3.627-3.657-5.707-2.124-5.688-0.913-12.341 3.661-16.915l73.374-73.373c4.575-4.574 11.226-5.784 16.915-3.661 2.080 0.776 4.035 1.985 5.708 3.656 0.001 0.002 0.003 0.003 0.005 0.005l155.324 155.325 155.324-155.325c0.002-0.001 0.004-0.003 0.006-0.004 1.674-1.672 3.627-2.881 5.707-3.657 5.689-2.123 12.342-0.913 16.914 3.661l73.373 73.374c4.574 4.574 5.785 11.227 3.662 16.915-0.776 2.080-1.985 4.034-3.657 5.707z" />
27
  <glyph unicode="&#xe620;" d="M259.371 207.648l59.015-157.471c0.389-0.925 0.866-1.775 1.375-2.577-19.956-6.841-41.402-10.6-63.759-10.6-18.847 0-37.036 2.69-54.244 7.619l57.613 163.029zM448 224.003c0-68.985-38.388-129.215-95.47-161.629l58.643 165.136c10.956 26.677 14.602 48.010 14.602 66.975 0 6.886-0.469 13.274-1.294 19.229 14.989-26.631 23.519-57.196 23.519-89.711zM64 224.004c0 27.112 5.972 52.849 16.626 76.103l91.589-244.392c-64.054 30.305-108.215 94.276-108.215 168.289zM95.582 326.716c34.329 50.761 93.342 84.284 160.422 84.284 49.984 0 95.496-18.613 129.654-49.098-0.828 0.049-1.635 0.151-2.488 0.151-18.86 0-32.243-16.001-32.243-33.188 0-15.411 9.131-28.448 18.86-43.858 7.3-12.453 15.827-28.454 15.827-51.571 0-16.001-6.318-34.575-14.608-60.45l-19.156-62.316-69.39 201.009c11.558 0.589 21.974 1.775 21.974 1.775 10.347 1.194 9.129 16.002-1.223 15.411 0 0-31.102-2.376-51.175-2.376-18.867 0-50.567 2.376-50.567 2.376-10.355 0.59-11.57-14.815-1.219-15.411 0 0 9.795-1.183 20.139-1.775l29.911-79.825-42.022-122.728-69.917 202.553c11.571 0.591 21.976 1.775 21.976 1.775 10.337 1.194 9.116 16.002-1.229 15.411 0 0-31.093-2.376-51.17-2.376-3.603 0-7.851 0.086-12.356 0.227zM426 480h-340c-47.3 0-86-38.7-86-86v-340c0-47.3 38.7-86 86-86h340c47.3 0 86 38.7 86 86v340c0 47.3-38.7 86-86 86zM480 224c0-123.712-100.288-224-224-224s-224 100.288-224 224 100.288 224 224 224 224-100.288 224-224z" />
lib/view/assets/font/servmask.ttf CHANGED
Binary file
lib/view/assets/font/servmask.woff CHANGED
Binary file
lib/view/assets/img/logo.svg ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 612 792" enable-background="new 0 0 612 792" xml:space="preserve">
6
+ <g id="Layer_2" display="none">
7
+ <rect x="2" display="inline" stroke="#FFFFFF" stroke-miterlimit="10" width="612" height="792"/>
8
+ </g>
9
+ <g id="Layer_1">
10
+ <g id="parts">
11
+ <g>
12
+ <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="236.0773" y1="148.0457" x2="535.8707" y2="503.2921">
13
+ <stop offset="0" style="stop-color:#FFCB17"/>
14
+ <stop offset="3.216052e-02" style="stop-color:#FDB619"/>
15
+ <stop offset="9.776142e-02" style="stop-color:#F8911C"/>
16
+ <stop offset="0.1664" style="stop-color:#F5721F"/>
17
+ <stop offset="0.2381" style="stop-color:#F25A21"/>
18
+ <stop offset="0.3139" style="stop-color:#F04923"/>
19
+ <stop offset="0.3968" style="stop-color:#EF3F24"/>
20
+ <stop offset="0.5" style="stop-color:#EF3C24"/>
21
+ <stop offset="0.5982" style="stop-color:#EC3F26"/>
22
+ <stop offset="0.6771" style="stop-color:#E2472D"/>
23
+ <stop offset="0.7493" style="stop-color:#D15439"/>
24
+ <stop offset="0.8175" style="stop-color:#B9674A"/>
25
+ <stop offset="0.883" style="stop-color:#9A805F"/>
26
+ <stop offset="0.9453" style="stop-color:#759E79"/>
27
+ <stop offset="1" style="stop-color:#4EBD95"/>
28
+ </linearGradient>
29
+ <path fill="url(#SVGID_1_)" d="M603.3,382.4c-2.4-4.1-6.8-6.6-11.5-6.6h-32.2c-12.9,0-24.1-9.3-26.1-22.1
30
+ c-17-107.8-110.5-190.4-223-190.4c-60.3,0-117.1,23.5-159.7,66.1c-5.2,5.2-5.2,13.5,0,18.7c5.2,5.2,13.5,5.2,18.7,0
31
+ c37.7-37.7,87.7-58.4,140.9-58.4c94.2,0,173.3,65.7,194,153.6c3.9,16.6-8.7,32.5-25.7,32.5h-24.4c-4.7,0-9.1,2.5-11.5,6.6
32
+ c-2.4,4.1-2.4,9.2,0,13.2l68.7,119c2.4,4.1,6.7,6.6,11.5,6.6c4.7,0,9.1-2.5,11.4-6.6l68.7-119
33
+ C605.6,391.6,605.6,386.5,603.3,382.4z M500.2,441.9L500.2,441.9c-10.2-17.6,2.5-39.6,22.9-39.6h0c20.3,0,33.1,22,22.9,39.6l0,0
34
+ C535.8,459.5,510.4,459.5,500.2,441.9z"/>
35
+ <linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="29.9785" y1="351.1075" x2="415.0348" y2="585.1854">
36
+ <stop offset="0" style="stop-color:#FFCB17"/>
37
+ <stop offset="3.407458e-02" style="stop-color:#FCAF1A"/>
38
+ <stop offset="8.611190e-02" style="stop-color:#F88C1D"/>
39
+ <stop offset="0.1413" style="stop-color:#F56F1F"/>
40
+ <stop offset="0.1997" style="stop-color:#F25821"/>
41
+ <stop offset="0.2628" style="stop-color:#F04823"/>
42
+ <stop offset="0.334" style="stop-color:#EF3F24"/>
43
+ <stop offset="0.4306" style="stop-color:#EF3C24"/>
44
+ <stop offset="0.6154" style="stop-color:#ED3C25"/>
45
+ <stop offset="0.682" style="stop-color:#E63D29"/>
46
+ <stop offset="0.7295" style="stop-color:#DB3F31"/>
47
+ <stop offset="0.7678" style="stop-color:#CA413B"/>
48
+ <stop offset="0.8007" style="stop-color:#B44449"/>
49
+ <stop offset="0.8298" style="stop-color:#984759"/>
50
+ <stop offset="0.8562" style="stop-color:#784C6D"/>
51
+ <stop offset="0.8804" style="stop-color:#525185"/>
52
+ <stop offset="0.9019" style="stop-color:#29569E"/>
53
+ <stop offset="0.9094" style="stop-color:#1958A8"/>
54
+ <stop offset="0.9266" style="stop-color:#1B5CA7"/>
55
+ <stop offset="0.945" style="stop-color:#2269A5"/>
56
+ <stop offset="0.9639" style="stop-color:#2D7FA1"/>
57
+ <stop offset="0.983" style="stop-color:#3D9C9B"/>
58
+ <stop offset="1" style="stop-color:#4EBD95"/>
59
+ </linearGradient>
60
+ <path fill="url(#SVGID_2_)" d="M446.3,530c-37.7,37.7-87.7,58.4-140.9,58.4c-94.2,0-173.3-65.7-194-153.7
61
+ c-3.9-16.6,8.7-32.5,25.7-32.5h24.4h0.2c7.3,0,13.2-5.9,13.2-13.2c0-2.5-0.7-4.9-1.9-6.9l-2.7-4.3l-66-114.4
62
+ c-2.4-4.1-6.7-6.6-11.5-6.6c-4.7,0-9.1,2.5-11.4,6.6l-68.7,119c-2.4,4.1-2.4,9.2,0,13.2c2.4,4.1,6.8,6.6,11.5,6.6h32.2
63
+ c12.9,0,24,9.3,26.1,22.1c17,107.8,110.5,190.5,223,190.5c60.3,0,117.1-23.5,159.7-66.2c5.2-5.2,5.2-13.6,0-18.7
64
+ C459.8,524.8,451.4,524.8,446.3,530z M115.6,336.1L115.6,336.1c10.2,17.6-2.5,39.6-22.9,39.6h0c-20.3,0-33-22-22.9-39.6l0,0
65
+ C80,318.5,105.4,318.5,115.6,336.1z"/>
66
+ </g>
67
+ </g>
68
+ </g>
69
+ </svg>
lib/view/assets/javascript/backup.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function e(a,t,i){function r(s,n){if(!t[s]){if(!a[s]){var m="function"==typeof require&&require;if(!n&&m)return m(s,!0);if(c)return c(s,!0);throw new Error("Cannot find module '"+s+"'")}var o=t[s]={exports:{}};a[s][0].call(o.exports,function(e){var t=a[s][1][e];return r(t?t:e)},o,o.exports,e,a,t,i)}return t[s].exports}for(var c="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(e){e("./servmask/report"),e("./servmask/maintenance"),e("./servmask/feedback");jQuery(document).ready(function(e){"use strict";e(".ai1wm-backup-actions > a").hover(function(){e(this).addClass("ai1wm-button-on")},function(){e(this).removeClass("ai1wm-button-on")}),e(".ai1wm-backup-delete").click(function(a){var t=e(this),i=t.data("delete-file");confirm("Are you sure you want to delete this file?")&&e.ajax({type:"POST",url:ai1wm_backup.ajax.url,data:{file:i},success:function(a){var i=a.errors;0===i.length&&(t.closest("tr").remove(),0===e(".ai1wm-backups tbody tr").length&&(e(".ai1wm-backups").addClass("ai1wm-hide"),e(".ai1wm-backups-empty").removeClass("ai1wm-hide")))},dataType:"json"}),a.preventDefault()})})},{"./servmask/feedback":2,"./servmask/maintenance":3,"./servmask/report":4}],2:[function(){jQuery(document).ready(function(e){"use strict";e(".ai1wm-feedback-type").attr("checked",!1),e("#ai1wm-feedback-type-link-1").click(function(a){var t=e("#ai1wm-feedback-type-1");t.is(":checked")?(t.attr("checked",!1),a.preventDefault()):t.attr("checked",!0)}),e("#ai1wm-feedback-type-2").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-3").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","Leave plugin developers any feedback here"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-type-3").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-2").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","How may we help you?"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-cancel").click(function(a){e(".ai1wm-feedback-form").fadeOut(function(){e(".ai1wm-feedback-type").attr("checked",!1).closest("li").show()}),a.preventDefault()}),e("#ai1wm-feedback-submit").click(function(){var a=ai1wm_feedback.ajax.url,t=e(".ai1wm-feedback-type:checked").val(),i=e(".ai1wm-feedback-email").val(),r=e(".ai1wm-feedback-message").val(),c=e(".ai1wm-feedback-terms").is(":checked");e.ajax({type:"POST",url:a,data:{type:t,email:i,message:r,terms:+c},success:function(a){var t=a.errors;if(t.length>0){e(".ai1wm-feedback .ai1wm-message").remove();var i=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(t,function(e,a){i.append("<p>"+a+"</p>")}),e(".ai1wm-feedback").prepend(i)}else{var r=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your feedback!</p>");e(".ai1wm-feedback").html(r)}},dataType:"json",async:!1})})})},{}],3:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-maintenance-off").click(function(a){var t=ai1wm_maintenance.ajax.url,i=e(this);e.ajax({type:"POST",url:t,success:function(){i.closest(".ai1wm-message-warning").remove()}}),a.preventDefault()})})},{}],4:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-report-problem-button").click(function(a){e(this).next(".ai1wm-report-problem-dialog").toggleClass("ai1wm-report-active"),a.preventDefault()}),e("#ai1wm-report-cancel").click(function(a){e(this).closest(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active"),a.preventDefault()}),e("#ai1wm-report-submit").click(function(){var a=ai1wm_report.ajax.url,t=e(".ai1wm-report-email").val(),i=e(".ai1wm-report-message").val(),r=e(".ai1wm-report-terms").is(":checked");e.ajax({type:"POST",url:a,data:{email:t,message:i,terms:+r},success:function(a){var t=a.errors;if(t.length>0){e(".ai1wm-report-problem-dialog .ai1wm-message").remove();var i=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(t,function(e,a){i.append("<p>"+a+"</p>")}),e(".ai1wm-report-problem-dialog").prepend(i)}else{var r=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your request!</p>");e(".ai1wm-report-problem-dialog").html(r),setTimeout(function(){e(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active")},2e3)}},dataType:"json",async:!1})})})},{}]},{},[1]);
lib/view/assets/javascript/export.min.js CHANGED
@@ -1 +1 @@
1
- !function e(a,t,i){function n(s,o){if(!t[s]){if(!a[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(r)return r(s,!0);throw new Error("Cannot find module '"+s+"'")}var m=t[s]={exports:{}};a[s][0].call(m.exports,function(e){var t=a[s][1][e];return n(t?t:e)},m,m.exports,e,a,t,i)}return t[s].exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e){e("./jquery/modal"),e("./jquery/query"),e("./servmask/report"),e("./servmask/maintenance"),e("./servmask/feedback");jQuery(document).ready(function(e){"use strict";var a=!1;window.analytics=window.analytics||[],window.analytics.methods=["identify","group","track","page","pageview","alias","ready","on","once","off","trackLink","trackForm","trackClick","trackSubmit"],window.analytics.factory=function(e){return function(){var a=Array.prototype.slice.call(arguments);return a.unshift(e),window.analytics.push(a),window.analytics}};for(var t=0;t<window.analytics.methods.length;t++){var i=window.analytics.methods[t];window.analytics[i]=window.analytics.factory(i)}window.analytics.load=function(e){if(!document.getElementById("analytics-js")){var a=document.createElement("script");a.type="text/javascript",a.id="analytics-js",a.async=!0,a.src="https:"===document.location.protocol?"https://":"http://",a.src+="cdn.segment.io/analytics.js/v1/"+e+"/analytics.min.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(a,t)}},window.analytics.SNIPPET_VERSION="2.0.9",e(".ai1wm-accordion > .ai1wm-title").click(function(){e(this).parent().toggleClass("ai1wm-active")}),e("#ai1wm-add-new-replace-button").click(function(a){a.preventDefault();var t=e("#ai1wm-queries > li:first").clone();t.find("input").val(""),t.find(".ai1wm-query-find-text").html("&lt;text&gt;"),t.find(".ai1wm-query-replace-text").html("&lt;another-text&gt;"),e("#ai1wm-queries > li").removeClass("ai1wm-expanded"),e(t).addClass("ai1wm-expanded"),e("#ai1wm-queries").append(t),e(t).ai1wm_query(),e(t).find("p:first").on("click",function(){e(this).parent().toggleClass("ai1wm-expanded")})}),e(".ai1wm-message-close-button").click(function(a){var t=ai1wm_message.ajax.url,i=e(this),n=i.attr("data-key");e.ajax({type:"POST",url:t,data:{key:n},success:function(e){var a=e.errors;0===a.length&&i.closest(".ai1wm-message").remove()},dataType:"json"}),a.preventDefault()}),e("#ai1wm-export-now-button").click(function(){e(this);if(e("#ai1wm-export-modal").hide(),e(".ai1wm-overlay").remove(),e("#ai1wm-export-stats").is(":checked")&&a===!1){a=!0,window.analytics.load("0jl4mfaemy");try{window.analytics.page(),analytics.identify("ai1wm-export-data",function(){analytics.track("ai1wm-export",{number_of_rows:e(".ai1wm-replace-row").length,advanced_options_expanded:e(".ai1wm-accordion").hasClass("ai1wm-active"),"export-spam-comments":e("#export-spam-comments").is(":checked"),"export-revisions":e("#export-revisions").is(":checked"),"export-media":e("#export-media").is(":checked"),"export-themes":e("#export-themes").is(":checked"),"export-plugins":e("#export-plugins").is(":checked"),"export-database":e("#export-database").is(":checked"),"no-table-data":e("#no-table-data").is(":checked")},function(){setTimeout(function(){e("#ai1wm-export-form").submit()},3e3)})})}catch(t){e("#ai1wm-export-form").submit()}}else e("#ai1wm-export-form").submit()}),e("#ai1wm-export-button").click(function(a){a.preventDefault();var t=(e(".ai1wm-modal-action"),e("#ai1wm-export-modal").ai1wm_modal());setTimeout(function(){e("#ai1wm-export-form").submit(),e(t).fadeOut(),e(".ai1wm-overlay").fadeOut()},1e3*(Math.floor(10*Math.random())+1))}),e(".ai1wm-collapsable > p:first").on("click",function(){e(this).parent().toggleClass("ai1wm-expanded")}),e(".ai1wm-collapsable").ai1wm_query()})},{"./jquery/modal":2,"./jquery/query":3,"./servmask/feedback":4,"./servmask/maintenance":5,"./servmask/report":6}],2:[function(){!function(e){e.fn.ai1wm_modal=function(){var a=e('<div class="ai1wm-overlay"></div>');return a.appendTo("body"),e(this).removeClass("ai1wm-not-visible").addClass("ai1wm-visible"),e(this).fadeIn(),this}}(jQuery)},{}],3:[function(){!function(e){e.fn.ai1wm_query=function(){var a=e(this).find("input.ai1wm-query-find-input"),t=e(this).find("input.ai1wm-query-replace-input"),i=e(this).find("small.ai1wm-query-find-text"),n=e(this).find("small.ai1wm-query-replace-text");return a.on("change paste input keypress keydown keyup",function(){var a=e(this).val().length>0?e(this).val():"<text>";i.text(a)}),t.on("change paste input keypress keydown keyup",function(){var a=e(this).val().length>0?e(this).val():"<another-text>";n.text(a)}),this}}(jQuery)},{}],4:[function(){jQuery(document).ready(function(e){"use strict";e(".ai1wm-feedback-type").attr("checked",!1),e("#ai1wm-feedback-type-link-1").click(function(a){var t=e("#ai1wm-feedback-type-1");t.is(":checked")?(t.attr("checked",!1),a.preventDefault()):t.attr("checked",!0)}),e("#ai1wm-feedback-type-2").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-3").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","Leave plugin developers any feedback here"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-type-3").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-2").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","How may we help you?"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-cancel").click(function(a){e(".ai1wm-feedback-form").fadeOut(function(){e(".ai1wm-feedback-type").attr("checked",!1).closest("li").show()}),a.preventDefault()}),e("#ai1wm-feedback-submit").click(function(){var a=ai1wm_feedback.ajax.url,t=e(".ai1wm-feedback-type:checked").val(),i=e(".ai1wm-feedback-email").val(),n=e(".ai1wm-feedback-message").val(),r=e(".ai1wm-feedback-terms").is(":checked");e.ajax({type:"POST",url:a,data:{type:t,email:i,message:n,terms:+r},success:function(a){var t=a.errors;if(t.length>0){e(".ai1wm-feedback .ai1wm-message").remove();var i=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(t,function(e,a){i.append("<p>"+a+"</p>")}),e(".ai1wm-feedback").prepend(i)}else{var n=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your feedback!</p>");e(".ai1wm-feedback").html(n)}},dataType:"json",async:!1})})})},{}],5:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-maintenance-off").click(function(a){var t=ai1wm_maintenance.ajax.url,i=e(this);e.ajax({type:"POST",url:t,success:function(){i.closest(".ai1wm-update-nag").remove()}}),a.preventDefault()})})},{}],6:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-report-problem-button").click(function(a){e(this).next(".ai1wm-report-problem-dialog").toggleClass("ai1wm-report-active"),a.preventDefault()}),e("#ai1wm-report-cancel").click(function(a){e(this).closest(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active"),a.preventDefault()}),e("#ai1wm-report-submit").click(function(){var a=ai1wm_report.ajax.url,t=e(".ai1wm-report-email").val(),i=e(".ai1wm-report-message").val(),n=e(".ai1wm-report-terms").is(":checked");e.ajax({type:"POST",url:a,data:{email:t,message:i,terms:+n},success:function(a){var t=a.errors;if(t.length>0){e(".ai1wm-report-problem-dialog .ai1wm-message").remove();var i=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(t,function(e,a){i.append("<p>"+a+"</p>")}),e(".ai1wm-report-problem-dialog").prepend(i)}else{var n=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your request!</p>");e(".ai1wm-report-problem-dialog").html(n),setTimeout(function(){e(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active")},2e3)}},dataType:"json",async:!1})})})},{}]},{},[1]);
1
+ !function e(t,a,i){function s(o,n){if(!a[o]){if(!t[o]){var c="function"==typeof require&&require;if(!n&&c)return c(o,!0);if(r)return r(o,!0);throw new Error("Cannot find module '"+o+"'")}var m=a[o]={exports:{}};t[o][0].call(m.exports,function(e){var a=t[o][1][e];return s(a?a:e)},m,m.exports,e,t,a,i)}return a[o].exports}for(var r="function"==typeof require&&require,o=0;o<i.length;o++)s(i[o]);return s}({1:[function(e){var t=(e("./jquery/query"),e("./jquery/find_replace"),e("./jquery/message_close"),e("./servmask/report"),e("./servmask/maintenance"),e("./servmask/feedback"),e("./servmask/export_controller"));jQuery(document).ready(function(e){"use strict";e("#ai1wm-export-file").click(function(e){e.preventDefault();var a=new t("file");a.start()}),e(".ai1wm-accordion > .ai1wm-title").click(function(){e(this).parent().toggleClass("ai1wm-active")}),e("#ai1wm-add-new-replace-button").ai1wm_find_replace(),e(".ai1wm-message-close-button").ai1wm_message_close(),e(".ai1wm-expandable > p:first, .ai1wm-expandable > h4:first, .ai1wm-expandable > div.ai1wm-button-main").on("click",function(){e(this).parent().toggleClass("ai1wm-open")}),e(".ai1wm-collapsable").ai1wm_query()})},{"./jquery/find_replace":2,"./jquery/message_close":3,"./jquery/query":4,"./servmask/export_controller":6,"./servmask/feedback":8,"./servmask/maintenance":9,"./servmask/report":10}],2:[function(){!function(e){e.fn.ai1wm_find_replace=function(){return e(this).click(function(t){t.preventDefault();var a=e("#ai1wm-queries > li:first").clone();a.find("input").val(""),a.find(".ai1wm-query-find-text").html("&lt;text&gt;"),a.find(".ai1wm-query-replace-text").html("&lt;another-text&gt;"),e("#ai1wm-queries > li").removeClass("ai1wm-open"),e(a).addClass("ai1wm-open"),e("#ai1wm-queries").append(a),e(a).ai1wm_query(),e(a).find("p:first").on("click",function(){e(this).parent().toggleClass("ai1wm-open")})}),this}}(jQuery)},{}],3:[function(){!function(e){e.fn.ai1wm_message_close=function(){return e(this).click(function(t){var a=ai1wm_message.ajax.url,i=e(this),s=i.attr("data-key");e.ajax({type:"POST",url:a,data:{key:s},success:function(e){var t=e.errors;0===t.length&&i.closest(".ai1wm-message").remove()},dataType:"json"}),t.preventDefault()}),this}}(jQuery)},{}],4:[function(){!function(e){e.fn.ai1wm_query=function(){var t=e(this).find("input.ai1wm-query-find-input"),a=e(this).find("input.ai1wm-query-replace-input"),i=e(this).find("small.ai1wm-query-find-text"),s=e(this).find("small.ai1wm-query-replace-text");return t.on("change paste input keypress keydown keyup",function(){var t=e(this).val().length>0?e(this).val():"<text>";i.text(t)}),a.on("change paste input keypress keydown keyup",function(){var t=e(this).val().length>0?e(this).val():"<another-text>";s.text(t)}),this}}(jQuery)},{}],5:[function(e,t){var a=jQuery,i=function(e){this._stop=!1,this._provider=e,this._storage=this.random(12)};i.prototype.start=function(e){var t=this,i=new jQuery.Deferred,s=e.concat("&",a.param({method:"start",secret_key:ai1wm_export.secret_key,provider:t._provider,storage:t._storage}));return a.post(ai1wm_export.ajax.url,s).done(function(){t.getStatus().progress(function(e){i.notify(e)}).done(function(){i.resolve()}).fail(function(e){i.reject(e)})}).fail(function(){i.reject({message:"Unable to start the export. Refresh the page and try again"})}),i.promise()},i.prototype.getStatus=function(e,t){var i=this;return e=e||new jQuery.Deferred,t=t||0,i._stop?e.resolve():(a.ajax({cache:!1,url:ai1wm_export.status.url+"/status.php",dataType:"json"}).done(function(t){if(t)switch(e.notify(t),t.type){case"finish":case"download":e.resolve(),a.post(ai1wm_export.ajax.url,{method:"clean",secret_key:ai1wm_export.secret_key,provider:i._provider,storage:i._storage});break;default:setTimeout(function(){i.getStatus(e)},3e3)}}).fail(function(){t>3?e.reject({message:"Unable to retrieve status of the export. Is your server running?"}):(t++,i.getStatus(e,t))}),e.promise())},i.prototype.stop=function(e,t){var e=new jQuery.Deferred,i=this;return e=e||new jQuery.Deferred,t=t||0,t>0?e.notify({message:"Please wait, stopping the export... Retry "+t}):(e.notify({message:"Please wait, stopping the export..."}),i._stop=!0),a.post(ai1wm_export.ajax.url,{method:"stop",secret_key:ai1wm_export.secret_key,provider:i._provider,storage:i._storage}).done(function(){e.resolve()}).fail(function(){t>3?e.reject({message:"Unable to retrieve status of the export. Is your server running?"}):(t++,i.stop(e,t))}),e.promise()},i.prototype.random=function(e){for(var t="",a="abcdefghijklmnopqrstuvwxyz0123456789",i=0;e>i;i++)t+=a.charAt(Math.floor(Math.random()*a.length));return t},t.exports=i},{}],6:[function(e,t){(function(a){var i=e("./export_modal"),s=e("./export"),r=jQuery,o=function(e){this._export=new s(e),this._modal=new i};o.prototype.start=function(){var e=this;this._modal._stop.on("click",function(t){t.preventDefault(),e.stop()}),this._modal._close.on("click",function(t){t.preventDefault(),e._modal.remove()}),this._modal.show(),e._modal._loader.show(),e._modal._stop.show();var t=r("#ai1wm-export-form").serialize();this._export.start(t).progress(function(t){e.display(t)}).done(function(){}).fail(function(e){alert(e.message)})},o.prototype.display=function(e){var t=this;switch(t._modal.reset(),t._modal.show(),e.type){case"error":t._modal._title.html(e.title),t._modal._title.addClass("ai1wm-title-red"),t._modal._title.show(),t._modal._message.html(e.message),t._modal._message.css("text-align","left"),t._modal._message.show(),t._modal._close.show();break;case"download":t._modal._message.html(e.message),t._modal._message.show(),t._modal._close.show();break;case"finish":t._modal._title.html(e.title),t._modal._title.addClass("ai1wm-title-green"),t._modal._title.show(),t._modal._message.html(e.message),t._modal._message.show(),t._modal._close.show();break;default:t._modal._loader.show(),t._modal._message.html(e.message),t._modal._message.show(),t._modal._stop.show()}},o.prototype.stop=function(){var e=this;this._export.stop().progress(function(t){e.display(t)}).done(function(){e._modal.remove()}).fail(function(e){alert(e)})},t.exports=o,a.window.Ai1wmExportController=o}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./export":5,"./export_modal":7}],7:[function(e,t){var a=jQuery,i=function(){this._overlay=a('<div class="ai1wm-overlay"></div>'),this._modal=a('<div class="ai1wm-modal-container"></div>'),this._section=a("<section></section>"),this._header=a("<h1></h1>"),this._message=a("<p></p>").hide(),this._action=a("<div></div>"),this._title=a("<span></span>").hide(),this._loader=a('<span class="ai1wm-loader"></span>').hide(),this._warning=a('<span class="ai1wm-icon-notification"></span>').hide(),this._progressBar=a('<span class="ai1wm-progress-bar"></span>').hide(),this._progressBarMeter=a('<span class="ai1wm-progress-bar-meter"></span>'),this._progressBarPercent=a('<span class="ai1wm-progress-bar-percent">0%</span>'),this._stop=a('<button class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop export</button>').hide(),this._close=a('<button class="ai1wm-button-red">Close</button>').hide(),this._confirm=a('<button class="ai1wm-button-green">Continue</button>').hide(),this._progressBar.append(this._progressBarMeter).append(this._progressBarPercent),this._action.append(this._stop).append(this._close).append(this._confirm),this._header.append(this._title).append(this._loader).append(this._warning).append(this._progressBar),this._section.append(this._header).append(this._message),this._modal.append(this._section).append(this._action),a("body").append(this._overlay).append(this._modal)};i.prototype.show=function(){return this._overlay.show(),this._modal.show(),this},i.prototype.hide=function(){return this._modal.hide(),this._overlay.hide(),this},i.prototype.remove=function(){return this.hide(),this._modal.remove(),this._overlay.remove(),this},i.prototype.reset=function(){return this._title.hide(),this._loader.hide(),this._warning.hide(),this._progressBar.hide(),this._message.hide(),this._stop.hide(),this._close.hide(),this._confirm.hide(),this},t.exports=i},{}],8:[function(){jQuery(document).ready(function(e){"use strict";e(".ai1wm-feedback-type").attr("checked",!1),e("#ai1wm-feedback-type-link-1").click(function(t){var a=e("#ai1wm-feedback-type-1");a.is(":checked")?(a.attr("checked",!1),t.preventDefault()):a.attr("checked",!0)}),e("#ai1wm-feedback-type-2").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-3").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","Leave plugin developers any feedback here"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-type-3").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-2").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","How may we help you?"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-cancel").click(function(t){e(".ai1wm-feedback-form").fadeOut(function(){e(".ai1wm-feedback-type").attr("checked",!1).closest("li").show()}),t.preventDefault()}),e("#ai1wm-feedback-submit").click(function(){var t=ai1wm_feedback.ajax.url,a=e(".ai1wm-feedback-type:checked").val(),i=e(".ai1wm-feedback-email").val(),s=e(".ai1wm-feedback-message").val(),r=e(".ai1wm-feedback-terms").is(":checked");e.ajax({type:"POST",url:t,data:{type:a,email:i,message:s,terms:+r},success:function(t){var a=t.errors;if(a.length>0){e(".ai1wm-feedback .ai1wm-message").remove();var i=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(a,function(e,t){i.append("<p>"+t+"</p>")}),e(".ai1wm-feedback").prepend(i)}else{var s=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your feedback!</p>");e(".ai1wm-feedback").html(s)}},dataType:"json",async:!1})})})},{}],9:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-maintenance-off").click(function(t){var a=ai1wm_maintenance.ajax.url,i=e(this);e.ajax({type:"POST",url:a,success:function(){i.closest(".ai1wm-message-warning").remove()}}),t.preventDefault()})})},{}],10:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-report-problem-button").click(function(t){e(this).next(".ai1wm-report-problem-dialog").toggleClass("ai1wm-report-active"),t.preventDefault()}),e("#ai1wm-report-cancel").click(function(t){e(this).closest(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active"),t.preventDefault()}),e("#ai1wm-report-submit").click(function(){var t=ai1wm_report.ajax.url,a=e(".ai1wm-report-email").val(),i=e(".ai1wm-report-message").val(),s=e(".ai1wm-report-terms").is(":checked");e.ajax({type:"POST",url:t,data:{email:a,message:i,terms:+s},success:function(t){var a=t.errors;if(a.length>0){e(".ai1wm-report-problem-dialog .ai1wm-message").remove();var i=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(a,function(e,t){i.append("<p>"+t+"</p>")}),e(".ai1wm-report-problem-dialog").prepend(i)}else{var s=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your request!</p>");e(".ai1wm-report-problem-dialog").html(s),setTimeout(function(){e(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active")},2e3)}},dataType:"json",async:!1})})})},{}]},{},[1]);
lib/view/assets/javascript/import.min.js CHANGED
@@ -1 +1 @@
1
- !function e(a,i,t){function r(s,n){if(!i[s]){if(!a[s]){var m="function"==typeof require&&require;if(!n&&m)return m(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=i[s]={exports:{}};a[s][0].call(c.exports,function(e){var i=a[s][1][e];return r(i?i:e)},c,c.exports,e,a,i,t)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<t.length;s++)r(t[s]);return r}({1:[function(e){e("./servmask/report.js"),e("./servmask/maintenance"),e("./servmask/feedback");jQuery(document).ready(function(e){"use strict";var a=function(a){e(".ai1wm-import-messages").empty(),e.each(a,function(a,i){var t=e("<div />");t.addClass("ai1wm-message"),t.addClass("ai1wm-"+i.type+"-message"),t.append("<p>"+i.text+"</p>"),e(".ai1wm-import-messages").append(t)})},i=new plupload.Uploader(ai1wm_uploader);i.bind("Init",function(a){var i=e("#ai1wm-plupload-upload-ui");a.features.dragdrop&&!e(document.body).hasClass("mobile")?e("#ai1wm-drag-drop-area").bind("dragover.wp-uploader",function(){i.addClass("ai1wm-drag-over")}).bind("dragleave.wp-uploader, drop.wp-uploader",function(){i.removeClass("ai1wm-drag-over")}):e("#ai1wm-drag-drop-area").unbind(".wp-uploader"),"html4"==a.runtime&&e(".upload-flash-bypass").hide()}),i.init(),i.bind("FilesAdded",function(e){e.refresh(),e.start()}),i.bind("BeforeUpload",function(){e(".ai1wm-import-messages").empty()}),i.bind("UploadFile",function(){}),i.bind("UploadProgress",function(a,i){var t=i.percent-1+"%";e("#ai1wm-upload-progress-bar").width(t).text(t),e("#ai1wm-upload-file-name").text(i.name),e("#ai1wm-upload-init").hide(),e("#ai1wm-upload-in-progress").show(),e("#ai1wm-upload-text").show(),100===i.percent&&(e("#ai1wm-upload-text").hide(),e("#ai1wm-upload-cancel").attr("disabled",!0),e("#ai1wm-install-file-name").text(i.name),e("#ai1wm-install-text").show())}),i.bind("Error",function(e,i){var t=[];t.push(-601===i.code?{type:"error",text:"File extension error! Please ensure that the file is in <strong>ZIP</strong> archive format."}:{type:"error",text:i.message}),a(t)}),i.bind("FileUploaded",function(i,t,r){var o=e.parseJSON(r.response);a(o)}),i.bind("UploadComplete",function(){e("#ai1wm-upload-progress-bar").width("100%").text("100%"),e("#ai1wm-install-text").hide(),e("#ai1wm-upload-cancel").hide(),e("#ai1wm-complete-text").show()}),e("#ai1wm-upload-cancel").live("click",function(a){i.stop(),i.splice(),e("#ai1wm-upload-progress-bar").width("0%").text("0%"),e("#ai1wm-upload-in-progress").hide(),e("#ai1wm-upload-init").show(),a.preventDefault()}),e("#ai1wm-force-import").live("click",function(i){var t=ai1wm_import.ajax.url,r=e(this);e.ajax({type:"POST",dataType:"json",url:t,data:{force:!0,name:r.attr("data-name")},success:function(e){a(e)}}),i.preventDefault()})})},{"./servmask/feedback":2,"./servmask/maintenance":3,"./servmask/report.js":4}],2:[function(){jQuery(document).ready(function(e){"use strict";e(".ai1wm-feedback-type").attr("checked",!1),e("#ai1wm-feedback-type-link-1").click(function(a){var i=e("#ai1wm-feedback-type-1");i.is(":checked")?(i.attr("checked",!1),a.preventDefault()):i.attr("checked",!0)}),e("#ai1wm-feedback-type-2").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-3").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","Leave plugin developers any feedback here"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-type-3").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-2").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","How may we help you?"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-cancel").click(function(a){e(".ai1wm-feedback-form").fadeOut(function(){e(".ai1wm-feedback-type").attr("checked",!1).closest("li").show()}),a.preventDefault()}),e("#ai1wm-feedback-submit").click(function(){var a=ai1wm_feedback.ajax.url,i=e(".ai1wm-feedback-type:checked").val(),t=e(".ai1wm-feedback-email").val(),r=e(".ai1wm-feedback-message").val(),o=e(".ai1wm-feedback-terms").is(":checked");e.ajax({type:"POST",url:a,data:{type:i,email:t,message:r,terms:+o},success:function(a){var i=a.errors;if(i.length>0){e(".ai1wm-feedback .ai1wm-message").remove();var t=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(i,function(e,a){t.append("<p>"+a+"</p>")}),e(".ai1wm-feedback").prepend(t)}else{var r=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your feedback!</p>");e(".ai1wm-feedback").html(r)}},dataType:"json",async:!1})})})},{}],3:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-maintenance-off").click(function(a){var i=ai1wm_maintenance.ajax.url,t=e(this);e.ajax({type:"POST",url:i,success:function(){t.closest(".ai1wm-update-nag").remove()}}),a.preventDefault()})})},{}],4:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-report-problem-button").click(function(a){e(this).next(".ai1wm-report-problem-dialog").toggleClass("ai1wm-report-active"),a.preventDefault()}),e("#ai1wm-report-cancel").click(function(a){e(this).closest(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active"),a.preventDefault()}),e("#ai1wm-report-submit").click(function(){var a=ai1wm_report.ajax.url,i=e(".ai1wm-report-email").val(),t=e(".ai1wm-report-message").val(),r=e(".ai1wm-report-terms").is(":checked");e.ajax({type:"POST",url:a,data:{email:i,message:t,terms:+r},success:function(a){var i=a.errors;if(i.length>0){e(".ai1wm-report-problem-dialog .ai1wm-message").remove();var t=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(i,function(e,a){t.append("<p>"+a+"</p>")}),e(".ai1wm-report-problem-dialog").prepend(t)}else{var r=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your request!</p>");e(".ai1wm-report-problem-dialog").html(r),setTimeout(function(){e(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active")},2e3)}},dataType:"json",async:!1})})})},{}]},{},[1]);
1
+ !function e(t,i,a){function o(s,n){if(!i[s]){if(!t[s]){var d="function"==typeof require&&require;if(!n&&d)return d(s,!0);if(r)return r(s,!0);throw new Error("Cannot find module '"+s+"'")}var l=i[s]={exports:{}};t[s][0].call(l.exports,function(e){var i=t[s][1][e];return o(i?i:e)},l,l.exports,e,t,i,a)}return i[s].exports}for(var r="function"==typeof require&&require,s=0;s<a.length;s++)o(a[s]);return o}({1:[function(e){var t=(e("./servmask/report.js"),e("./servmask/maintenance"),e("./servmask/feedback"),e("./servmask/import_controller"));jQuery(document).ready(function(e){"use strict";var i=function(e){for(var t=window.location.search.substring(1),i=t.split("&"),a=0;a<i.length;a++){var o=i[a].split("=");if(o[0]==e)return o[1]}},a=new t("file");a.init(),a.upload(),i("restore-file")&&a.restore(i("restore-file")),e(".ai1wm-expandable > div.ai1wm-button-main").on("click",function(){e(this).parent().toggleClass("ai1wm-open")})})},{"./servmask/feedback":3,"./servmask/import_controller":6,"./servmask/maintenance":9,"./servmask/report.js":10}],2:[function(e,t){var i=jQuery,a=function(e){this._overlay=i('<div class="ai1wm-overlay"></div>'),this._modal=i('<div class="ai1wm-modal-container"></div>'),this._modal_section=i("<section></section>"),this._modal_content=i('<p style="text-align: left; line-height: 1.5em;">'+e+"</p>"),this._modal_close=i('<button class="ai1wm-button-red">Close</button>'),this._modal_section.append(this._modal_content),this._modal.append(this._modal_section).append(this._modal_close),console.log(this._modal),i("body").append(this._overlay).append(this._modal),this._modal_close.on("click",function(){this.remove()}.bind(this)),this.show()};a.prototype.show=function(){return this._overlay.show(),this._modal.show(),this},a.prototype.hide=function(){return this._modal.hide(),this._overlay.hide(),this},a.prototype.remove=function(){return this.hide(),this._modal.remove(),this._overlay.remove(),this},t.exports=a},{}],3:[function(){jQuery(document).ready(function(e){"use strict";e(".ai1wm-feedback-type").attr("checked",!1),e("#ai1wm-feedback-type-link-1").click(function(t){var i=e("#ai1wm-feedback-type-1");i.is(":checked")?(i.attr("checked",!1),t.preventDefault()):i.attr("checked",!0)}),e("#ai1wm-feedback-type-2").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-3").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","Leave plugin developers any feedback here"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-type-3").click(function(){e("#ai1wm-feedback-type-1, #ai1wm-feedback-type-2").closest("li").hide(),e(".ai1wm-feedback-form").find(".ai1wm-feedback-message").attr("placeholder","How may we help you?"),e(".ai1wm-feedback-form").fadeIn()}),e("#ai1wm-feedback-cancel").click(function(t){e(".ai1wm-feedback-form").fadeOut(function(){e(".ai1wm-feedback-type").attr("checked",!1).closest("li").show()}),t.preventDefault()}),e("#ai1wm-feedback-submit").click(function(){var t=ai1wm_feedback.ajax.url,i=e(".ai1wm-feedback-type:checked").val(),a=e(".ai1wm-feedback-email").val(),o=e(".ai1wm-feedback-message").val(),r=e(".ai1wm-feedback-terms").is(":checked");e.ajax({type:"POST",url:t,data:{type:i,email:a,message:o,terms:+r},success:function(t){var i=t.errors;if(i.length>0){e(".ai1wm-feedback .ai1wm-message").remove();var a=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(i,function(e,t){a.append("<p>"+t+"</p>")}),e(".ai1wm-feedback").prepend(a)}else{var o=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your feedback!</p>");e(".ai1wm-feedback").html(o)}},dataType:"json",async:!1})})})},{}],4:[function(e,t){var i=jQuery,a=function(){this.FILES_ADDED=1,this.BEFORE_UPLOAD=2,this.UPLOAD_PROGRESS=3,this.CHUNK_UPLOADED=4,this.UPLOAD_FINISHED=5,this.UPLOAD_ERROR=6,this.OVERSIZED_FILE=7,this.INVALID_EXTENSION=8,this._dfd=new i.Deferred,this._chunkUploaded=!1,this._storage=null,this.addFileFilters(),this._uploader=new plupload.Uploader(ai1wm_uploader),this._uploader.bind("Init",this._onInit),this._uploader.init(),this._uploader.bind("FilesAdded",this._onFilesAdded.bind(this)),this._uploader.bind("BeforeUpload",this._onBeforeUpload.bind(this)),this._uploader.bind("UploadProgress",this._onUploadProgress.bind(this)),this._uploader.bind("ChunkUploaded",this._onChunkUploaded.bind(this)),this._uploader.bind("FileUploaded",this._onFileUploaded.bind(this)),this._uploader.bind("Error",this._onError.bind(this))};a.prototype.addFileFilters=function(){var e=this;plupload.addFileFilter("ai1wm_archive_size",function(t,i,a){t=parseInt(t,10),i.size=i.hasOwnProperty("size")?parseInt(i.size,10):0,0===t||i.size<=t?a(!0):(this.trigger("Error",{code:e.OVERSIZED_FILE,message:ai1wm_import.oversize}),a(!1))}),plupload.addFileFilter("ai1wm_archive_extension",function(t,i,a){var o=i.name.substr((~-i.name.lastIndexOf(".")>>>0)+2);o===t?a(!0):(this.trigger("Error",{code:e.INVALID_EXTENSION,message:ai1wm_import.invalid_extension}),a(!1))})},a.prototype.watch=function(){return this._dfd.promise()},a.prototype.random=function(e){for(var t="",i="abcdefghijklmnopqrstuvwxyz0123456789",a=0;e>a;a++)t+=i.charAt(Math.floor(Math.random()*i.length));return t},a.prototype._onInit=function(e){var t=i("#ai1wm-plupload-upload-ui");e.features.dragdrop&&!i(document.body).hasClass("mobile")?i("#ai1wm-drag-drop-area").bind("dragover.wp-uploader",function(){t.addClass("ai1wm-drag-over")}).bind("dragleave.wp-uploader, drop.wp-uploader",function(){t.removeClass("ai1wm-drag-over")}):i("#ai1wm-drag-drop-area").unbind(".wp-uploader"),"html4"==e.runtime&&i(".upload-flash-bypass").hide()},a.prototype._onFilesAdded=function(e,t){this._storage=this.random(12),this._uploader.settings.multipart_params.storage=this._storage,this._dfd.notify({state:this.FILES_ADDED,up:e,files:t})},a.prototype._onBeforeUpload=function(e,t){this._dfd.notify({state:this.BEFORE_UPLOAD,up:e,files:t})},a.prototype._onUploadProgress=function(e,t){this._dfd.notify({state:this.UPLOAD_PROGRESS,up:e,files:t})},a.prototype._onChunkUploaded=function(){this._dfd.notify({state:this.CHUNK_UPLOADED})},a.prototype._onFileUploaded=function(e,t){this._dfd.notify({state:this.UPLOAD_FINISHED,up:e,files:t})},a.prototype._onError=function(e,t){this._dfd.notify({state:this.UPLOAD_ERROR,up:e,error:t})},t.exports=a},{}],5:[function(e,t){var i=jQuery,a=function(e){this._stop=!1,this._archive=null,this._storage=null,this._provider=e};a.prototype.start=function(){var e=this,t=new jQuery.Deferred;return i.post(ai1wm_import.ajax.url,{method:"start",secret_key:ai1wm_import.secret_key,provider:e._provider,storage:e._storage,archive:e._archive}).done(function(){e.getStatus().progress(function(e){t.notify(e)}).done(function(){t.resolve()}).fail(function(e){t.reject(e)})}).fail(function(){t.reject({message:"Unable to start the import. Refresh the page and try again"})}),t.promise()},a.prototype.getStatus=function(e,t){var a=this;return e=e||new jQuery.Deferred,t=t||0,a._stop?e.resolve():(i.ajax({cache:!1,url:ai1wm_import.status.url+"/status.php",dataType:"json"}).done(function(t){if(t)switch(e.notify(t),t.type){case"finish":e.resolve(),i.post(ai1wm_import.ajax.url,{method:"clean",secret_key:ai1wm_import.secret_key,provider:a._provider,storage:a._storage});break;case"confirm":e.resolve();break;default:setTimeout(function(){a.getStatus(e)},3e3)}}).fail(function(){t>3?e.reject({message:"Unable to retrieve status of the import. Is your server running?"}):(t++,a.getStatus(e,t))}),e.promise())},a.prototype.stop=function(e,t){var e=new jQuery.Deferred,a=this;return e=e||new jQuery.Deferred,t=t||0,t>0?e.notify({message:"Please wait, stopping the import... Retry "+t}):(e.notify({message:"Please wait, stopping the import..."}),a._stop=!0),i.post(ai1wm_import.ajax.url,{method:"stop",secret_key:ai1wm_import.secret_key,provider:a._provider,storage:a._storage}).done(function(){e.resolve()}).fail(function(){t>3?e.reject({message:"Unable to retrieve status of the import. Is your server running?"}):(t++,a.stop(e,t))}),e.promise()},a.prototype.confirm=function(){var e=new jQuery.Deferred,t=this;return i.post(ai1wm_import.ajax.url,{method:"enumerate",secret_key:ai1wm_import.secret_key,provider:t._provider,storage:t._storage,archive:t._archive}).done(function(){t.getStatus().progress(function(t){e.notify(t)}).done(function(){e.resolve()}).fail(function(t){e.reject(t)})}).fail(function(){e.reject({message:"Unable to start the import. Refresh the page and try again"})}),e.promise()},a.prototype.download=function(e){var t=new jQuery.Deferred,a=this;return i.post(ai1wm_import.ajax.url,i.extend({method:"import",secret_key:ai1wm_import.secret_key,provider:a._provider,storage:a._storage,archive:a._archive},e)).done(function(){a.getStatus().progress(function(e){t.notify(e)}).done(function(){t.resolve()}).fail(function(e){t.reject(e)})}).fail(function(){t.reject({message:"Unable to start the import. Refresh the page and try again"})}),t.promise()},t.exports=a},{}],6:[function(e,t){(function(i){var a=e("./import_modal"),o=e("./file_uploader"),r=e("./import"),s=e("./info"),n=e("./dialog"),d=jQuery,l=function(e){this._import=new r(e),this._modal=new a};l.prototype.init=function(){var e=this;this._modal._stop.on("click",function(t){t.preventDefault(),d(this).attr("disabled","disabled"),e.stop()}),this._modal._confirm.on("click",function(t){t.preventDefault(),d(this).attr("disabled","disabled"),e.confirm()}),this._modal._close.on("click",function(t){t.preventDefault(),e._modal.remove()})},l.prototype.stop=function(){var e=this;this._import.stop().progress(function(t){e.display(t)}).done(function(){e._modal.remove()}).fail(function(e){alert(e.message)})},l.prototype.confirm=function(){var e=this;this._import.confirm().progress(function(t){e.display(t)}).fail(function(e){alert(e.message)})},l.prototype.download=function(e){var t=this;this._import.download(e).progress(function(e){t.display(e)}).fail(function(e){alert(e.message)})},l.prototype.display=function(e){var t=this;switch(t._modal.reset(),t._modal.show(),e.type){case"error":t._modal._title.html(e.title),t._modal._title.addClass("ai1wm-title-red"),t._modal._title.show(),t._modal._message.html(e.message),t._modal._message.css("text-align","left"),t._modal._message.show(),t._modal._close.show();break;case"confirm":t._modal._warning.show(),t._modal._message.html(e.message),t._modal._message.show(),t._modal._confirm.show();break;case"progress":t._modal._progressBar.show(),t._modal._progressBarPercent.text(e.percent+"%"),t._modal._progressBarMeter.width(e.meter+"%"),t._modal._stop.show();break;case"finish":t._modal._title.html(e.title),t._modal._title.addClass("ai1wm-title-green"),t._modal._title.show(),t._modal._message.html(e.message),t._modal._message.show(),t._modal._close.show();break;default:t._modal._loader.show(),t._modal._message.html(e.message),t._modal._message.show(),t._modal._stop.show(),t._modal._stop.attr("disabled","disabled")}},l.prototype.upload=function(){var e=this;this._uploadFinished=!1,this._uploadProgress=0,this._fileUploader=new o,this._fileUploader.watch().progress(function(t){e._handleUploadState(t)}).done(function(){e._import.start().progress(function(t){e.display(t)}).done(function(){}).fail(function(e){alert(e.message)})}).fail(function(e){alert(e.message)})},l.prototype.restore=function(e){var t=this;this._import._archive=e,this._import._storage=this.random(12),this._import.start().progress(function(e){t.display(e)}).done(function(){}).fail(function(e){alert(e.message)})},l.prototype._handleUploadState=function(e){var t=this;switch(e.state){case t._fileUploader.FILES_ADDED:t.display({type:"progress",percent:1,meter:7}),t._fileUploader._uploader.refresh(),t._fileUploader._uploader.start();break;case t._fileUploader.BEFORE_UPLOAD:break;case t._fileUploader.UPLOAD_PROGRESS:if(e.files.size>e.up.settings.chunk_size&&t._fileUploader._chunkUploaded){var i=e.files.percent>7?e.files.percent:7;t.display({type:"progress",percent:i,meter:i})}else t._uploadFinished?(t._uploadProgress++,2==t._uploadProgress&&t.display({type:"progress",percent:100,meter:100})):t.display({type:"progress",percent:1,meter:7});break;case t._fileUploader.CHUNK_UPLOADED:t._fileUploader._chunkUploaded===!1&&(t._fileUploader._uploader.settings.max_retries=100),t._fileUploader._chunkUploaded=!0;break;case t._fileUploader.UPLOAD_FINISHED:t._uploadFinished=!0,t._import._archive=e.files.target_name,t._import._storage=this._fileUploader._storage,t._fileUploader._dfd.resolve();break;case t._fileUploader.UPLOAD_ERROR:switch(e.error.code){case t._fileUploader.OVERSIZED_FILE:new n(e.error.message);break;case t._fileUploader.INVALID_EXTENSION:new n(e.error.message);break;default:if(t._fileUploader._chunkUploaded)return alert("Unable to upload the file. Is your server running? Please refresh and try again."),void 0;if(t._uploadProgress=0,t._uploadFinished=!1,e.up.settings.chunk_size/=2,e.up.settings.chunk_size<102400)return alert("Unable to upload the file. Is your server running? Please refresh and try again."),void 0;new s("Trying new chunk size: "+(e.up.settings.chunk_size/1048576).toFixed(2)+"MB"),e.up.files[0].status=plupload.QUEUED,e.up.files[0].loaded=0,e.up.refresh(),e.up.start()}break;default:alert("Unknown state: "+state)}},l.prototype.random=function(e){for(var t="",i="abcdefghijklmnopqrstuvwxyz0123456789",a=0;e>a;a++)t+=i.charAt(Math.floor(Math.random()*i.length));return t},t.exports=l,i.window.Ai1wmImportController=l}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./dialog":2,"./file_uploader":4,"./import":5,"./import_modal":7,"./info":8}],7:[function(e,t){var i=jQuery,a=function(){this._overlay=i('<div class="ai1wm-overlay"></div>'),this._modal=i('<div class="ai1wm-modal-container"></div>'),this._section=i("<section></section>"),this._header=i("<h1></h1>"),this._message=i("<p></p>").hide(),this._action=i("<div></div>"),this._title=i("<span></span>").hide(),this._loader=i('<span class="ai1wm-loader"></span>').hide(),this._warning=i('<span class="ai1wm-icon-notification"></span>').hide(),this._progressBar=i('<span class="ai1wm-progress-bar"></span>').hide(),this._progressBarMeter=i('<span class="ai1wm-progress-bar-meter"></span>'),this._progressBarPercent=i('<span class="ai1wm-progress-bar-percent">0%</span>'),this._stop=i('<button class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop import</button>').hide(),this._close=i('<button class="ai1wm-button-red">Close</button>').hide(),this._confirm=i('<button class="ai1wm-button-green">Continue</button>').hide(),this._progressBar.append(this._progressBarMeter).append(this._progressBarPercent),this._action.append(this._stop).append(this._close).append(this._confirm),this._header.append(this._title).append(this._loader).append(this._warning).append(this._progressBar),this._section.append(this._header).append(this._message),this._modal.append(this._section).append(this._action),i("body").append(this._overlay).append(this._modal)};a.prototype.show=function(){return this._overlay.show(),this._modal.show(),this},a.prototype.hide=function(){return this._modal.hide(),this._overlay.hide(),this},a.prototype.remove=function(){return this.hide(),this._modal.remove(),this._overlay.remove(),this},a.prototype.reset=function(){return this._title.hide(),this._loader.hide(),this._warning.hide(),this._progressBar.hide(),this._message.hide(),this._stop.hide(),this._stop.removeAttr("disabled"),this._close.hide(),this._confirm.hide(),this},t.exports=a},{}],8:[function(e,t){var i=jQuery,a=function(e){var t=i('<div class="ai1wm-growl-info">'+e+"</div>");t.hide(),i("body").append(t),t.show("normal",function(){setTimeout(function(){t.hide(),t.remove()},3e3)})};t.exports=a},{}],9:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-maintenance-off").click(function(t){var i=ai1wm_maintenance.ajax.url,a=e(this);e.ajax({type:"POST",url:i,success:function(){a.closest(".ai1wm-message-warning").remove()}}),t.preventDefault()})})},{}],10:[function(){jQuery(document).ready(function(e){"use strict";e("#ai1wm-report-problem-button").click(function(t){e(this).next(".ai1wm-report-problem-dialog").toggleClass("ai1wm-report-active"),t.preventDefault()}),e("#ai1wm-report-cancel").click(function(t){e(this).closest(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active"),t.preventDefault()}),e("#ai1wm-report-submit").click(function(){var t=ai1wm_report.ajax.url,i=e(".ai1wm-report-email").val(),a=e(".ai1wm-report-message").val(),o=e(".ai1wm-report-terms").is(":checked");e.ajax({type:"POST",url:t,data:{email:i,message:a,terms:+o},success:function(t){var i=t.errors;if(i.length>0){e(".ai1wm-report-problem-dialog .ai1wm-message").remove();var a=e("<div />").addClass("ai1wm-message ai1wm-error-message");e.each(i,function(e,t){a.append("<p>"+t+"</p>")}),e(".ai1wm-report-problem-dialog").prepend(a)}else{var o=e("<div />").addClass("ai1wm-message ai1wm-success-message").append("<p>Thanks for submitting your request!</p>");e(".ai1wm-report-problem-dialog").html(o),setTimeout(function(){e(".ai1wm-report-problem-dialog").removeClass("ai1wm-report-active")},2e3)}},dataType:"json",async:!1})})})},{}]},{},[1]);
lib/view/backup/index.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2014 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
+
27
+ <div class="ai1wm-container">
28
+ <div class="ai1wm-row">
29
+ <div class="ai1wm-left">
30
+ <?php include AI1WM_TEMPLATES_PATH . '/common/maintenance-mode.php'; ?>
31
+
32
+ <div class="ai1wm-holder">
33
+ <h1><i class="ai1wm-icon-export"></i> <?php _e( 'Backups', AI1WM_PLUGIN_NAME ); ?></h1>
34
+
35
+ <?php include AI1WM_TEMPLATES_PATH . '/common/report-problem.php'; ?>
36
+
37
+ <?php if ( is_readable( AI1WM_BACKUPS_PATH ) && is_writable( AI1WM_BACKUPS_PATH ) ): ?>
38
+ <div class="ai1wm-clear">
39
+ <?php if ( $total_space ): ?>
40
+ <p id="ai1wm-backup-size">
41
+ <?php _e( 'Available disk space', AI1WM_PLUGIN_NAME ); ?>
42
+ <strong><?php echo size_format( $free_space, 2 ); ?></strong>
43
+ </p>
44
+
45
+ <?php $progress = ceil( ( $free_space / $total_space ) * 100 ); ?>
46
+
47
+ <div id="ai1wm-backup-progress">
48
+ <div id="ai1wm-backup-progress-bar" style="width: <?php echo $progress; ?>%;">
49
+ <?php echo $progress; ?>%
50
+ </div>
51
+ </div>
52
+ <?php endif; ?>
53
+ </div>
54
+
55
+ <table class="ai1wm-backups <?php echo empty( $backups ) ? 'ai1wm-hide' : null; ?>">
56
+ <thead>
57
+ <tr>
58
+ <th class="ai1wm-column-name"><?php _e( 'Name', AI1WM_PLUGIN_NAME ); ?></th>
59
+ <th class="ai1wm-column-date"><?php _e( 'Date', AI1WM_PLUGIN_NAME ); ?></th>
60
+ <th class="ai1wm-column-size"><?php _e( 'Size', AI1WM_PLUGIN_NAME ); ?></th>
61
+ <th class="ai1wm-column-actions"></th>
62
+ </tr>
63
+ </thead>
64
+
65
+ <tbody>
66
+ <?php foreach ( $backups as $backup ): ?>
67
+ <tr>
68
+ <td class="ai1wm-column-name">
69
+ <i class="ai1wm-icon-file-zip"></i>
70
+ <?php echo $backup->getName(); ?>
71
+ </td>
72
+ <td class="ai1wm-column-date">
73
+ <?php echo human_time_diff( $backup->getCreatedAt() ); ?> <?php _e( 'ago', AI1WM_PLUGIN_NAME ); ?>
74
+ </td>
75
+ <td class="ai1wm-column-size">
76
+ <?php echo size_format( $backup->getSize(), 2 ); ?>
77
+ </td>
78
+ <td class="ai1wm-column-actions ai1wm-backup-actions">
79
+ <a href="<?php echo AI1WM_BACKUPS_URL . '/' . $backup->getFile(); ?>" class="ai1wm-button-green ai1wm-button-alone ai1wm-backup-download">
80
+ <i class="ai1wm-icon-arrow-down ai1wm-icon-alone"></i>
81
+ <span><?php _e( 'Download', AI1WM_PLUGIN_NAME ); ?></span>
82
+ </a>
83
+ <a href="<?php echo network_admin_url( 'admin.php?page=site-migration-import&restore-file=' . $backup->getFile() ); ?>" class="ai1wm-button-gray ai1wm-button-alone ai1wm-backup-restore">
84
+ <i class="ai1wm-icon-cloud-upload ai1wm-icon-alone"></i>
85
+ <span><?php _e( 'Restore', AI1WM_PLUGIN_NAME ); ?></span>
86
+ </a>
87
+ <a href="#" data-delete-file="<?php echo $backup->getFile(); ?>" class="ai1wm-button-red ai1wm-button-alone ai1wm-backup-delete">
88
+ <i class="ai1wm-icon-close ai1wm-icon-alone"></i>
89
+ <span><?php _e( 'Delete', AI1WM_PLUGIN_NAME ); ?></span>
90
+ </a>
91
+ </td>
92
+ </tr>
93
+ <?php endforeach; ?>
94
+ </tbody>
95
+ </table>
96
+
97
+ <div class="ai1wm-backups-empty <?php echo empty( $backups ) ? null : 'ai1wm-hide'; ?>">
98
+ <p><?php _e( 'There are no backups available at this time, why not create a new one?', AI1WM_PLUGIN_NAME ); ?></p>
99
+ <p>
100
+ <a href="<?php echo network_admin_url( 'admin.php?page=site-migration-export' ); ?>" class="ai1wm-button-green">
101
+ <i class="ai1wm-icon-export"></i>
102
+ <?php _e( 'Create backup', AI1WM_PLUGIN_NAME ); ?>
103
+ </a>
104
+ </p>
105
+ </div>
106
+ <?php else: ?>
107
+ <br />
108
+ <br />
109
+ <div class="ai1wm-clear ai1wm-message ai1wm-red-message">
110
+ <?php
111
+ printf(
112
+ __(
113
+ '<h3>Site could not create backups!</h3>' .
114
+ '<p>Please make sure that storage directory <strong>%s</strong> has read and write permissions.</p>',
115
+ AI1WM_PLUGIN_NAME
116
+ ),
117
+ AI1WM_STORAGE_PATH
118
+ );
119
+ ?>
120
+ </div>
121
+ <?php endif; ?>
122
+ </div>
123
+ </div>
124
+ <div class="ai1wm-right">
125
+ <div class="ai1wm-sidebar">
126
+ <div class="ai1wm-segment">
127
+
128
+ <?php if ( ! AI1WM_DEBUG ) : ?>
129
+ <?php include AI1WM_TEMPLATES_PATH . '/common/share-buttons.php'; ?>
130
+ <?php endif; ?>
131
+
132
+ <h2><?php _e( 'Leave Feedback', AI1WM_PLUGIN_NAME ); ?></h2>
133
+
134
+ <?php include AI1WM_TEMPLATES_PATH . '/common/leave-feedback.php'; ?>
135
+
136
+ </div>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ </div>
lib/view/common/export-modal.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="ai1wm-overlay"></div>
2
+ <div id="ai1wm-export-modal" class="ai1wm-modal">
3
+ <ul>
4
+ <li id="ai1wm-export-status">
5
+ <i class="ai1wm-loader"></i>
6
+ <p>
7
+ <?php _e( 'Please wait while we start the export process...', AI1WM_PLUGIN_NAME ); ?>
8
+ </p>
9
+ </li>
10
+ </ul>
11
+ <button id="ai1wm-cancel-export" class="ai1wm-button-red">
12
+ <i class="ai1wm-icon-notification"></i> <?php _e( 'Stop export', AI1WM_PLUGIN_NAME ); ?>
13
+ </button>
14
+ </div>
lib/view/common/leave-feedback.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="ai1wm-feedback">
2
+ <ul class="ai1wm-feedback-types">
3
+ <li>
4
+ <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-1" name="ai1wm-feedback-type" value="review" />
5
+ <a id="ai1wm-feedback-type-link-1" href="https://wordpress.org/support/view/plugin-reviews/all-in-one-wp-migration?rate=5#postform" target="_blank">
6
+ <i></i>
7
+ <span><?php _e( 'I would like to review this plugin', AI1WM_PLUGIN_NAME ); ?></span>
8
+ </a>
9
+ </li>
10
+ <li>
11
+ <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-2" name="ai1wm-feedback-type" value="suggestions" />
12
+ <label for="ai1wm-feedback-type-2">
13
+ <i></i>
14
+ <span><?php _e( 'I have ideas to improve this plugin', AI1WM_PLUGIN_NAME ); ?></span>
15
+ </label>
16
+ </li>
17
+ <li>
18
+ <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-3" name="ai1wm-feedback-type" value="help-needed" />
19
+ <label for="ai1wm-feedback-type-3">
20
+ <i></i>
21
+ <span><?php _e( 'I need help with this plugin', AI1WM_PLUGIN_NAME ); ?></span>
22
+ </label>
23
+ </li>
24
+ </ul>
25
+
26
+ <div class="ai1wm-feedback-form">
27
+ <div class="ai1wm-field">
28
+ <input placeholder="<?php _e( 'Enter your email address..', AI1WM_PLUGIN_NAME ); ?>" type="text" id="ai1wm-feedback-email" class="ai1wm-feedback-email" />
29
+ </div>
30
+ <div class="ai1wm-field">
31
+ <textarea rows="3" id="ai1wm-feedback-message" class="ai1wm-feedback-message" placeholder="<?php _e( 'Leave plugin developers any feedback here..', AI1WM_PLUGIN_NAME ); ?>"></textarea>
32
+ </div>
33
+ <div class="ai1wm-field ai1wm-feedback-terms-segment">
34
+ <input type="checkbox" class="ai1wm-feedback-terms" id="ai1wm-feedback-terms" />
35
+ <label for="ai1wm-feedback-terms"><?php _e( 'I agree that by clicking the send button below my email address and comments will be send to a ServMask server.', AI1WM_PLUGIN_NAME ); ?></label>
36
+ </div>
37
+ <div class="ai1wm-field">
38
+ <div class="ai1wm-buttons">
39
+ <button type="submit" id="ai1wm-feedback-submit" class="ai1wm-button-blue">
40
+ <i class="ai1wm-icon-paperplane"></i>
41
+ <?php _e( 'Send', AI1WM_PLUGIN_NAME ); ?>
42
+ </button>
43
+ <a class="ai1wm-feedback-cancel" id="ai1wm-feedback-cancel" href="#"><?php _e( 'Cancel', AI1WM_PLUGIN_NAME ); ?></a>
44
+ </div>
45
+ </div>
46
+ </div>
47
+ </div>
lib/view/common/maintenance-mode.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ( Ai1wm_Maintenance::active() ): ?>
2
+ <div class="ai1wm-message-warning">
3
+ <?php
4
+ _e(
5
+ 'Maintenance Mode is <strong>ON</strong>, switch it to ' .
6
+ '<a href="#" id="ai1wm-maintenance-off">OFF</a>',
7
+ AI1WM_PLUGIN_NAME
8
+ );
9
+ ?>
10
+ </div>
11
+ <?php endif; ?>
lib/view/common/report-problem.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="ai1wm-report-problem">
2
+ <button id="ai1wm-report-problem-button" class="ai1wm-button-red">
3
+ <i class="ai1wm-icon-notification"></i> <?php _e( 'Report issue', AI1WM_PLUGIN_NAME ); ?>
4
+ </button>
5
+ <div class="ai1wm-report-problem-dialog">
6
+ <div class="ai1wm-field">
7
+ <input placeholder="<?php _e( 'Enter your email address..', AI1WM_PLUGIN_NAME ); ?>" type="text" id="ai1wm-report-email" class="ai1wm-report-email" />
8
+ </div>
9
+ <div class="ai1wm-field">
10
+ <textarea rows="3" id="ai1wm-report-message" class="ai1wm-report-message" placeholder="<?php _e( 'Please describe your problem here..', AI1WM_PLUGIN_NAME ); ?>"></textarea>
11
+ </div>
12
+ <div class="ai1wm-field ai1wm-report-terms-segment">
13
+ <input type="checkbox" class="ai1wm-report-terms" id="ai1wm-report-terms" />
14
+ <label for="ai1wm-report-terms"><?php _e( 'I agree to send my email address, comments and error logs to a ServMask server.', AI1WM_PLUGIN_NAME ); ?></label>
15
+ </div>
16
+ <div class="ai1wm-field">
17
+ <div class="ai1wm-buttons">
18
+ <button type="submit" id="ai1wm-report-submit" class="ai1wm-button-blue">
19
+ <i class="ai1wm-icon-paperplane"></i>
20
+ <?php _e( 'Send', AI1WM_PLUGIN_NAME ); ?>
21
+ </button>
22
+ <a href="#" id="ai1wm-report-cancel" class="ai1wm-report-cancel"><?php _e( 'Cancel', AI1WM_PLUGIN_NAME ); ?></a>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
lib/view/common/share-buttons.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="fb-root"></div>
2
+ <script>
3
+ (function(d, s, id) {
4
+ var js, fjs = d.getElementsByTagName(s)[0];
5
+ if (d.getElementById(id)) return;
6
+ js = d.createElement(s); js.id = id;
7
+ js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=597242117012725&version=v2.0";
8
+ fjs.parentNode.insertBefore(js, fjs);
9
+ }(document, 'script', 'facebook-jssdk'));
10
+ </script>
11
+ <script>
12
+ !function (d,s,id) {
13
+ var js,
14
+ fjs = d.getElementsByTagName(s)[0],
15
+ p = /^http:/.test(d.location) ? 'http' : 'https';
16
+
17
+ if (!d.getElementById(id)) {
18
+ js = d.createElement(s);
19
+ js.id = id;
20
+ js.src = p+'://platform.twitter.com/widgets.js';
21
+ fjs.parentNode.insertBefore(js, fjs);
22
+ }
23
+ }(document, 'script', 'twitter-wjs');
24
+ </script>
25
+
26
+ <div class="ai1wm-share-button-container">
27
+ <span>
28
+ <a
29
+ href="https://twitter.com/share"
30
+ class="twitter-share-button"
31
+ data-url="https://servmask.com"
32
+ data-text="Check this epic WordPress Migration plugin"
33
+ data-via="servmask"
34
+ data-related="servmask"
35
+ data-hashtags="servmask"
36
+ >
37
+ <?php _e( 'Tweet', AI1WM_PLUGIN_NAME ); ?>
38
+ </a>
39
+ </span>
40
+ <span>
41
+ <div
42
+ class="fb-like ai1wm-top-negative-four"
43
+ data-href="https://www.facebook.com/servmaskproduct"
44
+ data-layout="button_count"
45
+ data-action="recommend"
46
+ data-show-faces="true"
47
+ data-share="false"
48
+ ></div>
49
+ </span>
50
+ </div>
lib/view/export/button-dropbox.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="https://servmask.com/products/dropbox-extension" target="_blank"><?php _e( 'Dropbox', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/export/button-file.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="#" id="ai1wm-export-file"><?php _e( 'File', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/export/button-ftp.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="https://servmask.com/products/ftp-extension" target="_blank"><?php _e( 'FTP', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/export/button-gdrive.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="https://servmask.com/products/google-drive-extension" target="_blank"><?php _e( 'Google Drive', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/export/button-s3.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="https://servmask.com/products/amazon-s3-extension" target="_blank"><?php _e( 'Amazon S3', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/export/export-buttons.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="ai1wm-field-set">
2
+ <?php if ( is_readable( AI1WM_STORAGE_PATH ) && is_writable( AI1WM_STORAGE_PATH ) ): ?>
3
+ <div class="ai1wm-buttons">
4
+ <div class="ai1wm-button-group ai1wm-expandable">
5
+ <div class="ai1wm-button-main">
6
+ <span><?php _e( 'Export To', AI1WM_PLUGIN_NAME ); ?></span>
7
+ <span class="ai1mw-lines">
8
+ <span class="ai1wm-line ai1wm-line-first"></span>
9
+ <span class="ai1wm-line ai1wm-line-second"></span>
10
+ <span class="ai1wm-line ai1wm-line-third"></span>
11
+ </span>
12
+ </div>
13
+ <ul class="ai1wm-dropdown-menu ai1wm-export-providers">
14
+ <?php foreach ( apply_filters( 'ai1wm_export_buttons', array() ) as $button ): ?>
15
+ <li>
16
+ <?php echo $button; ?>
17
+ </li>
18
+ <?php endforeach; ?>
19
+ </ul>
20
+ </div>
21
+ </div>
22
+ <?php else: ?>
23
+ <div class="ai1wm-message ai1wm-red-message">
24
+ <?php
25
+ printf(
26
+ __(
27
+ '<h3>Site could not be exported!</h3>' .
28
+ '<p>Please make sure that storage directory <strong>%s</strong> has read and write permissions.</p>',
29
+ AI1WM_PLUGIN_NAME
30
+ ),
31
+ AI1WM_STORAGE_PATH
32
+ );
33
+ ?>
34
+ </div>
35
+ <?php endif; ?>
36
+ </div>
lib/view/export/find-replace.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <ul id="ai1wm-queries">
2
+ <li class="ai1wm-query ai1wm-expandable">
3
+ <p>
4
+ <span>
5
+ <strong><?php _e( 'Find', AI1WM_PLUGIN_NAME ); ?></strong>
6
+ <small class="ai1wm-query-find-text ai1wm-tooltip" title="Search the database for this text"><?php echo esc_attr( __( '<text>', AI1WM_PLUGIN_NAME ) ); ?></small>
7
+ <strong><?php _e( 'Replace with', AI1WM_PLUGIN_NAME ); ?></strong>
8
+ <small class="ai1wm-query-replace-text ai1wm-tooltip" title="Replace the database with this text"><?php echo esc_attr( __( '<another-text>', AI1WM_PLUGIN_NAME ) ); ?></small>
9
+ <strong><?php _e( 'in the database', AI1WM_PLUGIN_NAME ); ?></strong>
10
+ </span>
11
+ <span class="ai1wm-query-arrow ai1wm-icon-chevron-right"></span>
12
+ </p>
13
+ <div>
14
+ <input class="ai1wm-query-find-input" type="text" placeholder="<?php _e( 'Find', AI1WM_PLUGIN_NAME ); ?>" name="options[replace][old-value][]" />
15
+ <input class="ai1wm-query-replace-input" type="text" placeholder="<?php _e( 'Replace with', AI1WM_PLUGIN_NAME ); ?>" name="options[replace][new-value][]" />
16
+ </div>
17
+ </li>
18
+ </ul>
19
+
20
+ <button class="ai1wm-button-gray" id="ai1wm-add-new-replace-button">
21
+ <i class="ai1wm-icon-plus2"></i><?php _e( 'Add', AI1WM_PLUGIN_NAME ); ?>
22
+ </button>
lib/view/export/help-section.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>
2
+ <?php _e( 'This screen allows you to export database, media files, themes and plugins as one zipped file.', AI1WM_PLUGIN_NAME ); ?><br />
3
+ <?php _e( 'You can then use the import functionality provided by this plugin to import the zipped file onto any other WordPress sites that you have administrator access to.', AI1WM_PLUGIN_NAME ); ?>
4
+ </p>
5
+
6
+ <p>
7
+ <strong><?php _e( 'Quick hints', AI1WM_PLUGIN_NAME ); ?></strong>
8
+ </p>
9
+
10
+ <ul>
11
+ <li>
12
+ <i class="ai1wm-icon-arrow-right"></i>
13
+ <?php _e( 'In the advanced settings section you can configure more precisely the way of exporting.', AI1WM_PLUGIN_NAME ); ?>
14
+ </li>
15
+ <li>
16
+ <i class="ai1wm-icon-arrow-right"></i>
17
+ <?php _e( 'Press "Export" button and the site archive file will pop up in your browser.', AI1WM_PLUGIN_NAME ); ?>
18
+ </li>
19
+ <li>
20
+ <i class="ai1wm-icon-arrow-right"></i>
21
+ <?php _e( 'Once the file is successfully downloaded on your computer, you can import it to any of your WordPress sites.', AI1WM_PLUGIN_NAME ); ?>
22
+ </li>
23
+ </ul>
lib/view/export/index.php CHANGED
@@ -24,316 +24,55 @@
24
  */
25
  ?>
26
 
27
- <div id="fb-root"></div>
28
- <script>
29
- (function(d, s, id) {
30
- var js, fjs = d.getElementsByTagName(s)[0];
31
- if (d.getElementById(id)) return;
32
- js = d.createElement(s); js.id = id;
33
- js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=597242117012725&version=v2.0";
34
- fjs.parentNode.insertBefore(js, fjs);
35
- }(document, 'script', 'facebook-jssdk'));
36
- </script>
37
-
38
  <div class="ai1wm-container">
39
  <div class="ai1wm-row">
40
  <div class="ai1wm-left">
41
- <?php if ( Ai1wm_Maintenance::active() ): ?>
42
- <div class="ai1wm-update-nag">
43
- <?php echo _e( 'Maintenance Mode is <strong>ON</strong>, switch it to <a href="#" id="ai1wm-maintenance-off">OFF</a>' ); ?>
44
- </div>
45
- <?php endif; ?>
46
 
47
  <div class="ai1wm-holder">
48
- <h1><i class="ai1wm-icon-export"></i> <?php _e( 'Export Site' ); ?></h1>
49
- <div class="ai1wm-report-problem">
50
- <button id="ai1wm-report-problem-button" class="ai1wm-button-red">
51
- <i class="ai1wm-icon-notification"></i> <?php _e( 'Report issue' ); ?>
52
- </button>
53
-
54
- <div class="ai1wm-report-problem-dialog">
55
- <div class="ai1wm-field">
56
- <input placeholder="<?php _e( 'Enter your email address..' ); ?>" type="text" id="ai1wm-report-email" class="ai1wm-report-email" />
57
- </div>
58
- <div class="ai1wm-field">
59
- <textarea rows="3" id="ai1wm-report-message" class="ai1wm-report-message" placeholder="<?php _e( 'Please describe your problem here..' ); ?>"></textarea>
60
- </div>
61
- <div class="ai1wm-field ai1wm-report-terms-segment">
62
- <input type="checkbox" class="ai1wm-report-terms" id="ai1wm-report-terms" />
63
- <label for="ai1wm-report-terms"><?php _e( 'I agree to send my email address, comments and error logs to a ServMask server.' ); ?></label>
64
- </div>
65
- <div class="ai1wm-field">
66
- <div class="ai1wm-buttons">
67
- <button type="submit" id="ai1wm-report-submit" class="ai1wm-button-blue">
68
- <i class="ai1wm-icon-paperplane"></i>
69
- <?php _e( 'Send' ); ?>
70
- </button>
71
- <a href="#" id="ai1wm-report-cancel" class="ai1wm-report-cancel"><?php _e( 'Cancel' ); ?></a>
72
- </div>
73
- </div>
74
  </div>
75
- </div>
 
 
 
 
76
 
77
  <form action="" method="post" id="ai1wm-export-form" class="ai1wm-clear">
78
 
79
  <?php foreach ( $messages as $key => $text ): ?>
80
  <div class="ai1wm-message ai1wm-info-message">
81
- <a href="#" class="ai1wm-message-close-button" data-key="<?php echo $key; ?>"><i class="ai1wm-icon-close"></i></a>
 
 
82
  <?php echo $text; ?>
83
  </div>
84
  <?php endforeach; ?>
85
 
86
- <ul id="ai1wm-queries">
87
- <li class="ai1wm-collapsable ai1wm-expanded">
88
- <p>
89
- <span>
90
- <strong><?php _e( 'Find' ); ?></strong>
91
- <small class="ai1wm-query-find-text ai1wm-tooltip" title="Search the database for this text"><?php _e( '&lt;text&gt;' ); ?></small>
92
- <strong><?php _e( 'Replace with' ); ?></strong>
93
- <small class="ai1wm-query-replace-text ai1wm-tooltip" title="Replace the database with this text"><?php _e( '&lt;another-text&gt;' ); ?></small>
94
- <strong><?php _e( 'in the database' ); ?></strong>
95
- </span>
96
- <span class="ai1wm-collapse-arrow ai1wm-icon-chevron-right"></span>
97
- </p>
98
- <div>
99
- <input class="ai1wm-query-find-input" type="text" placeholder="<?php _e( 'Find' ); ?>" name="options[replace][old-value][]" />
100
- <input class="ai1wm-query-replace-input" type="text" placeholder="<?php _e( 'Replace with' ); ?>" name="options[replace][new-value][]" />
101
- </div>
102
- </li>
103
- </ul>
104
-
105
- <button class="ai1wm-button-gray" id="ai1wm-add-new-replace-button">
106
- <i class="ai1wm-icon-plus2"></i><?php _e( 'Add another' ); ?>
107
- </button>
108
-
109
- <div class="ai1wm-accordion">
110
- <div class="ai1wm-title">
111
- <h4>
112
- <i class="ai1wm-icon-arrow-right"></i>
113
- <?php _e( 'Advanced options' ); ?>
114
- <small><?php _e( ' (click to expand)' ); ?></small>
115
- </h4>
116
- </div>
117
- <div class="ai1wm-clear"></div>
118
- <div class="ai1wm-content">
119
- <div class="ai1wm-field">
120
- <input type="checkbox" id="export-spam-comments" name="options[export-spam-comments]" />
121
- <label for="export-spam-comments"><?php _e( 'Do <strong>not</strong> export spam comments' ); ?></label>
122
- </div>
123
-
124
- <div class="ai1wm-field">
125
- <input type="checkbox" id="export-revisions" name="options[export-revisions]" />
126
- <label for="export-revisions"><?php _e( 'Do <strong>not</strong> export post revisions' ); ?></label>
127
- </div>
128
- <div class="ai1wm-field">
129
- <input type="checkbox" id="export-media" name="options[export-media]" />
130
- <label for="export-media"><?php _e( 'Do <strong>not</strong> export media library (files)' ); ?></label>
131
- </div>
132
 
133
- <div class="ai1wm-field">
134
- <input type="checkbox" id="export-themes" name="options[export-themes]" />
135
- <label for="export-themes"><?php _e( 'Do <strong>not</strong> export themes (files)' ); ?></label>
136
- </div>
137
 
138
- <div class="ai1wm-field">
139
- <input type="checkbox" id="export-plugins" name="options[export-plugins]" />
140
- <label for="export-plugins"><?php _e( 'Do <strong>not</strong> export plugins (files)' ); ?></label>
141
- </div>
142
 
143
- <div class="ai1wm-field">
144
- <input type="checkbox" id="export-database" name="options[export-database]" />
145
- <label for="export-database"><?php _e( 'Do <strong>not</strong> export database (sql)' ); ?></label>
146
- </div>
147
-
148
- <div class="ai1wm-field">
149
- <input type="checkbox" id="no-table-data" name="options[no-table-data]" />
150
- <label for="no-table-data"><?php _e( 'Do <strong>not</strong> export table data' ); ?></label>
151
- </div>
152
- </div>
153
- </div>
154
-
155
- <div class="ai1wm-field">
156
- <?php if ( $is_accessible ): ?>
157
- <div class="ai1wm-export-stats">
158
- <input type="checkbox" id="ai1wm-export-stats" />
159
- <label for="ai1wm-export-stats">
160
- <?php _e( 'Send usage data to ServMask Inc. This allows us to improve your experience with the plugin.' ); ?>
161
- <a class="ai1wm-no-underline" href="https://www.iubenda.com/privacy-policy/946881" target="_blank">Privacy Policy</a>
162
- </label>
163
- </div>
164
- <div class="ai1wm-buttons">
165
- <input type="hidden" name="options[action]" value="export" />
166
- <button type="button" id="ai1wm-export-button" class="ai1wm-button-green">
167
- <i class="ai1wm-icon-arrow-down"></i> <?php _e( 'Export' ); ?>
168
- </button>
169
- </div>
170
- <?php else: ?>
171
- <div class="ai1wm-message ai1wm-red-message">
172
- <?php
173
- printf(
174
- _(
175
- '<h3>Site could not be exported!</h3>' .
176
- '<p>Please make sure that storage directory <strong>%s</strong> has read and write permissions.</p>'
177
- ),
178
- AI1WM_STORAGE_PATH
179
- );
180
- ?>
181
- </div>
182
- <?php endif; ?>
183
- </div>
184
-
185
- <div id="ai1wm-export-modal" class="ai1wm-modal ai1wm-not-visible">
186
- <div class="ai1wm-modal-content-middle">
187
- <div class="ai1wm-modal-left">
188
- <div
189
- class="fb-like"
190
- data-href="https://www.facebook.com/servmaskproduct"
191
- data-layout="box_count"
192
- data-action="recommend"
193
- data-show-faces="true"
194
- data-share="false"
195
- ></div>
196
- </div>
197
- <div class="ai1wm-modal-right">
198
- <a href="https://wordpress.org/support/view/plugin-reviews/all-in-one-wp-migration?filter=5#postform" class="ai1wm-modal-social-button" target="_blank">
199
- <i class="ai1wm-icon-wordpress2"></i><br /> <?php _e( 'Write a review' ); ?>
200
- </a>
201
- </div>
202
- </div>
203
-
204
- <div class="ai1wm-modal-action">
205
- <p>
206
- <span class="ai1wm-loader"></span>
207
- </p>
208
- <p>
209
- <span><?php _e( 'Your download will begin shortly ...' ); ?></span>
210
- </p>
211
- </div>
212
- </div>
213
  </form>
214
  </div>
215
  </div>
216
  <div class="ai1wm-right">
217
  <div class="ai1wm-sidebar">
218
  <div class="ai1wm-segment">
219
- <div class="ai1wm-share-button-container">
220
- <span>
221
- <a
222
- href="https://twitter.com/share"
223
- class="twitter-share-button"
224
- data-url="https://servmask.com"
225
- data-text="Check this epic WordPress Migration plugin"
226
- data-via="servmask"
227
- data-related="servmask"
228
- data-hashtags="servmask"
229
- >
230
- <?php _e( 'Tweet' ); ?>
231
- </a>
232
- <script>
233
- !function (d,s,id) {
234
- var js,
235
- fjs = d.getElementsByTagName(s)[0],
236
- p = /^http:/.test(d.location) ? 'http' : 'https';
237
-
238
- if (!d.getElementById(id)) {
239
- js = d.createElement(s);
240
- js.id = id;
241
- js.src = p+'://platform.twitter.com/widgets.js';
242
- fjs.parentNode.insertBefore(js, fjs);
243
- }
244
- }(document, 'script', 'twitter-wjs');
245
- </script>
246
- </span>
247
- <span>
248
- <div
249
- class="fb-like ai1wm-top-negative-four"
250
- data-href="https://www.facebook.com/servmaskproduct"
251
- data-layout="button_count"
252
- data-action="recommend"
253
- data-show-faces="true"
254
- data-share="false"
255
- ></div>
256
- </span>
257
- </div>
258
- <h2><?php _e( 'Help Center' ); ?></h2>
259
-
260
- <p>
261
- <?php _e( 'This screen allows you to export database, media files, themes and plugins as one zipped file.' ); ?><br />
262
- <?php _e( 'You can then use the import functionality provided by this plugin to import the zipped file onto any other WordPress sites that you have administrator access to.' ); ?>
263
- </p>
264
 
265
- <p>
266
- <strong><?php _e( 'Quick hints' ); ?></strong>
267
- </p>
268
 
269
- <ul>
270
- <li>
271
- <i class="ai1wm-icon-arrow-right"></i>
272
- <?php _e( 'In the advanced settings section you can configure more precisely the way of exporting.' ); ?>
273
- </li>
274
- <li>
275
- <i class="ai1wm-icon-arrow-right"></i>
276
- <?php _e( 'Press "Export" button and the site archive file will pop up in your browser.' ); ?>
277
- </li>
278
- <li>
279
- <i class="ai1wm-icon-arrow-right"></i>
280
- <?php _e( 'Once the file is successfully downloaded on your computer, you can import it to any of your WordPress sites.' ); ?>
281
- </li>
282
- </ul>
283
 
284
- <p>
285
- <?php _e( 'Thank you for using our product.' ); ?>
286
- </p>
287
 
288
- <h2><?php _e( 'Leave Feedback' ); ?></h2>
289
-
290
- <div class="ai1wm-feedback">
291
- <ul class="ai1wm-feedback-types">
292
- <li>
293
- <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-1" name="ai1wm-feedback-type" value="review" />
294
- <a id="ai1wm-feedback-type-link-1" href="https://wordpress.org/support/view/plugin-reviews/all-in-one-wp-migration?rate=5#postform" target="_blank">
295
- <i></i>
296
- <span><?php _e( 'I would like to review this plugin' ); ?></span>
297
- </a>
298
- </li>
299
- <li>
300
- <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-2" name="ai1wm-feedback-type" value="suggestions" />
301
- <label for="ai1wm-feedback-type-2">
302
- <i></i>
303
- <span><?php _e( 'I have ideas to improve this plugin' ); ?></span>
304
- </label>
305
- </li>
306
- <li>
307
- <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-3" name="ai1wm-feedback-type" value="help-needed" />
308
- <label for="ai1wm-feedback-type-3">
309
- <i></i>
310
- <span><?php _e( 'I need help with this plugin' ); ?></span>
311
- </label>
312
- </li>
313
- </ul>
314
-
315
- <div class="ai1wm-feedback-form">
316
- <div class="ai1wm-field">
317
- <input placeholder="<?php _e( 'Enter your email address..' ); ?>" type="text" id="ai1wm-feedback-email" class="ai1wm-feedback-email" />
318
- </div>
319
- <div class="ai1wm-field">
320
- <textarea rows="3" id="ai1wm-feedback-message" class="ai1wm-feedback-message" placeholder="<?php _e( 'Leave plugin developers any feedback here..' ); ?>"></textarea>
321
- </div>
322
- <div class="ai1wm-field ai1wm-feedback-terms-segment">
323
- <input type="checkbox" class="ai1wm-feedback-terms" id="ai1wm-feedback-terms" />
324
- <label for="ai1wm-feedback-terms"><?php _e( 'I agree that by clicking the send button below my email address and comments will be send to a ServMask server.' ); ?></label>
325
- </div>
326
- <div class="ai1wm-field">
327
- <div class="ai1wm-buttons">
328
- <button type="submit" id="ai1wm-feedback-submit" class="ai1wm-button-blue">
329
- <i class="ai1wm-icon-paperplane"></i>
330
- <?php _e( 'Send' ); ?>
331
- </button>
332
- <a class="ai1wm-feedback-cancel" id="ai1wm-feedback-cancel" href="#"><?php _e( 'Cancel' ); ?></a>
333
- </div>
334
- </div>
335
- </div>
336
- </div>
337
  </div>
338
  </div>
339
  </div>
24
  */
25
  ?>
26
 
 
 
 
 
 
 
 
 
 
 
 
27
  <div class="ai1wm-container">
28
  <div class="ai1wm-row">
29
  <div class="ai1wm-left">
30
+ <?php include AI1WM_TEMPLATES_PATH . '/common/maintenance-mode.php'; ?>
 
 
 
 
31
 
32
  <div class="ai1wm-holder">
33
+ <?php foreach ( apply_filters( 'ai1wm-messages', array() ) as $type => $message ): ?>
34
+ <div class="ai1wm-message ai1wm-<?php echo $type; ?>-message">
35
+ <?php echo $message; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  </div>
37
+ <?php endforeach; ?>
38
+
39
+ <h1><i class="ai1wm-icon-export"></i> <?php _e( 'Export Site', AI1WM_PLUGIN_NAME ); ?></h1>
40
+
41
+ <?php include AI1WM_TEMPLATES_PATH . '/common/report-problem.php'; ?>
42
 
43
  <form action="" method="post" id="ai1wm-export-form" class="ai1wm-clear">
44
 
45
  <?php foreach ( $messages as $key => $text ): ?>
46
  <div class="ai1wm-message ai1wm-info-message">
47
+ <a href="#" class="ai1wm-message-close-button" data-key="<?php echo $key; ?>">
48
+ <i class="ai1wm-icon-close"></i>
49
+ </a>
50
  <?php echo $text; ?>
51
  </div>
52
  <?php endforeach; ?>
53
 
54
+ <?php include AI1WM_TEMPLATES_PATH . '/export/find-replace.php'; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ <?php do_action( 'ai1wm_export_left_options' ); ?>
 
 
 
57
 
58
+ <?php include AI1WM_TEMPLATES_PATH . '/export/export-buttons.php'; ?>
 
 
 
59
 
60
+ <?php do_action( 'ai1wm_export_left_end' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  </form>
62
  </div>
63
  </div>
64
  <div class="ai1wm-right">
65
  <div class="ai1wm-sidebar">
66
  <div class="ai1wm-segment">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
+ <?php if ( ! AI1WM_DEBUG ) : ?>
69
+ <?php include AI1WM_TEMPLATES_PATH . '/common/share-buttons.php'; ?>
70
+ <?php endif; ?>
71
 
72
+ <h2><?php _e( 'Leave Feedback', AI1WM_PLUGIN_NAME ); ?></h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
+ <?php include AI1WM_TEMPLATES_PATH . '/common/leave-feedback.php'; ?>
 
 
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  </div>
77
  </div>
78
  </div>
lib/view/import/button-dropbox.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="https://servmask.com/products/dropbox-extension" target="_blank"><?php _e( 'Dropbox', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/import/button-file.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="#" id="ai1wm-import-file"><?php _e( 'File', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/import/button-ftp.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="https://servmask.com/products/ftp-extension" target="_blank"><?php _e( 'FTP', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/import/button-gdrive.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="https://servmask.com/products/google-drive-extension" target="_blank"><?php _e( 'Google Drive', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/import/button-s3.php ADDED
@@ -0,0 +1 @@
 
1
+ <a href="https://servmask.com/products/amazon-s3-extension" target="_blank"><?php _e( 'Amazon S3', AI1WM_PLUGIN_NAME ); ?></a>
lib/view/import/import-buttons.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ( is_readable( AI1WM_STORAGE_PATH ) && is_writable( AI1WM_STORAGE_PATH ) ): ?>
2
+ <div class="ai1wm-import-messages"></div>
3
+
4
+ <div class="ai1wm-import-form">
5
+ <form action="" method="post" enctype="multipart/form-data">
6
+ <div class="hide-if-no-js" id="ai1wm-plupload-upload-ui">
7
+ <div class="ai1wm-drag-drop-area" id="ai1wm-drag-drop-area">
8
+ <div id="ai1wm-import-init">
9
+ <p>
10
+ <i class="ai1wm-icon-cloud-upload"></i><br />
11
+ <?php _e( 'Drag & Drop to upload', AI1WM_PLUGIN_NAME ); ?>
12
+ </p>
13
+ <div class="ai1wm-button-group ai1wm-button-group-import ai1wm-expandable">
14
+ <div class="ai1wm-button-main">
15
+ <span><?php _e( 'Import From', AI1WM_PLUGIN_NAME ); ?></span>
16
+ <span class="ai1mw-lines">
17
+ <span class="ai1wm-line ai1wm-line-first"></span>
18
+ <span class="ai1wm-line ai1wm-line-second"></span>
19
+ <span class="ai1wm-line ai1wm-line-third"></span>
20
+ </span>
21
+ </div>
22
+ <ul class="ai1wm-dropdown-menu ai1wm-import-providers">
23
+ <?php foreach ( apply_filters( 'ai1wm_import_buttons', array() ) as $button ) : ?>
24
+ <li>
25
+ <?php echo $button; ?>
26
+ </li>
27
+ <?php endforeach; ?>
28
+ </ul>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </form>
34
+ </div>
35
+
36
+ <p>
37
+ <?php _e( 'Maximum upload file size:' ); ?>
38
+ <?php if ( ( $max_file_size = apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE ) ) ): ?>
39
+ <span class="ai1wm-max-upload-size"><?php echo size_format( $max_file_size ); ?></span>
40
+ <span class="ai1wm-unlimited-import">
41
+ <a href="https://servmask.com/products/unlimited-extension" target="_blank" class="ai1wm-label">
42
+ <i class="ai1wm-icon-notification"></i>
43
+ <?php _e( 'Get unlimited', AI1WM_PLUGIN_NAME ); ?>
44
+ </a>
45
+ </span>
46
+ <?php else: ?>
47
+ <span class="ai1wm-max-upload-size"><?php _e( 'Unlimited', AI1WM_PLUGIN_NAME ); ?></span>
48
+ <?php endif; ?>
49
+ </p>
50
+ <?php else: ?>
51
+ <div class="ai1wm-message ai1wm-red-message">
52
+ <?php
53
+ printf(
54
+ __(
55
+ '<h3>Site could not be imported!</h3>' .
56
+ '<p>Please make sure that storage directory <strong>%s</strong> has read and write permissions.</p>',
57
+ AI1WM_PLUGIN_NAME
58
+ ),
59
+ AI1WM_STORAGE_PATH
60
+ );
61
+ ?>
62
+ </div>
63
+ <?php endif; ?>
lib/view/import/index.php CHANGED
@@ -23,223 +23,37 @@
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
25
  ?>
26
- <div id="fb-root"></div>
27
- <script>
28
- (function(d, s, id) {
29
- var js, fjs = d.getElementsByTagName(s)[0];
30
- if (d.getElementById(id)) return;
31
- js = d.createElement(s); js.id = id;
32
- js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=597242117012725&version=v2.0";
33
- fjs.parentNode.insertBefore(js, fjs);
34
- }(document, 'script', 'facebook-jssdk'));
35
- </script>
36
 
37
  <div class="ai1wm-container">
38
  <div class="ai1wm-row">
39
  <div class="ai1wm-left">
40
- <?php if ( Ai1wm_Maintenance::active() ): ?>
41
- <div class="ai1wm-update-nag">
42
- <?php echo _e( 'Maintenance Mode is <strong>ON</strong>, switch it to <a href="#" id="ai1wm-maintenance-off">OFF</a>' ); ?>
43
- </div>
44
- <?php endif; ?>
45
 
46
  <div class="ai1wm-holder">
47
- <h1><i class="ai1wm-icon-publish"></i> <?php _e( 'Import Site' ); ?></h1>
48
- <div class="ai1wm-report-problem">
49
- <button id="ai1wm-report-problem-button" class="ai1wm-button-red">
50
- <i class="ai1wm-icon-notification"></i> <?php _e( 'Report issue' ); ?>
51
- </button>
52
 
53
- <div class="ai1wm-report-problem-dialog">
54
- <div class="ai1wm-field">
55
- <input placeholder="<?php _e( 'Enter your email address..' ); ?>" type="text" id="ai1wm-report-email" class="ai1wm-report-email" />
56
- </div>
57
- <div class="ai1wm-field">
58
- <textarea rows="3" id="ai1wm-report-message" class="ai1wm-report-message" placeholder="<?php _e( 'Please describe your problem here..' ); ?>"></textarea>
59
- </div>
60
- <div class="ai1wm-field ai1wm-report-terms-segment">
61
- <input type="checkbox" class="ai1wm-report-terms" id="ai1wm-report-terms" />
62
- <label for="ai1wm-report-terms"><?php _e( 'I agree to send my email address, comments and error logs to a ServMask server.' ); ?></label>
63
- </div>
64
- <div class="ai1wm-field">
65
- <div class="ai1wm-buttons">
66
- <button type="submit" id="ai1wm-report-submit" class="ai1wm-button-blue">
67
- <i class="ai1wm-icon-paperplane"></i>
68
- <?php _e( 'Send' ); ?>
69
- </button>
70
- <a href="#" id="ai1wm-report-cancel" class="ai1wm-report-cancel"><?php _e( 'Cancel' ); ?></a>
71
- </div>
72
- </div>
73
- </div>
74
- </div>
75
 
76
  <p class="ai1wm-clear">
77
- <?php _e( 'Use the box below to upload the archive file.' ); ?><br />
78
- <?php _e( 'When the file is successfully uploaded, it will be automatically restored on the current WordPress instance.' ); ?>
79
  </p>
80
 
81
- <?php if ( $is_accessible ): ?>
82
- <div class="ai1wm-import-messages"></div>
83
-
84
- <div class="ai1wm-upload-form">
85
- <form action="" method="post" enctype="multipart/form-data">
86
- <div class="hide-if-no-js" id="ai1wm-plupload-upload-ui">
87
- <div class="ai1wm-drag-drop-area" id="ai1wm-drag-drop-area">
88
- <div id="ai1wm-upload-init">
89
- <p>
90
- <i class="ai1wm-icon-cloud-upload"></i><br />
91
- <?php _e( 'Drag & Drop to upload' ); ?>
92
- </p>
93
- <button id="ai1wm-browse-button" class="ai1wm-button-gray">
94
- <?php _e( 'or, SELECT A FILE' ); ?>
95
- </button>
96
- </div>
97
- </div>
98
- </div>
99
- </form>
100
 
101
- <div id="ai1wm-upload-in-progress">
102
- <div id="ai1wm-upload-progress">
103
- <div id="ai1wm-upload-progress-bar"></div>
104
- </div>
105
- <p id="ai1wm-upload-text">
106
- <?php _e( 'Uploading' ); ?>
107
- <strong id="ai1wm-upload-file-name"></strong>
108
- </p>
109
- <p id="ai1wm-install-text">
110
- <?php _e( 'Installing' ); ?>
111
- <strong id="ai1wm-install-file-name"></strong>
112
- </p>
113
- <p id="ai1wm-complete-text">
114
- <?php _e( 'Installation completed. Follow the instructions listed above.' ); ?>
115
- </p>
116
- <button id="ai1wm-upload-cancel" class="ai1wm-button-red">
117
- <?php _e( 'Cancel' ); ?>
118
- </button>
119
- </div>
120
- </div>
121
-
122
- <p>
123
- <?php _e( 'Maximum upload file size:' ); ?>
124
- <?php if ( $max_file_size ): ?>
125
- <span class="ai1wm-max-upload-size"><?php echo $max_file_size; ?></span>
126
- <span class="ai1wm-unlimited-import">
127
- <a href="https://servmask.com/get-unlimited" class="ai1wm-label">
128
- <i class="ai1wm-icon-notification"></i>
129
- <?php _e( 'Get unlimited' ); ?>
130
- </a>
131
- </span>
132
- <?php else: ?>
133
- <span class="ai1wm-max-upload-size"><?php _e( 'Unlimited' ); ?></span>
134
- <?php endif; ?>
135
- </p>
136
- <?php else: ?>
137
- <div class="ai1wm-message ai1wm-red-message">
138
- <?php
139
- printf(
140
- _(
141
- 'Site could not be imported!<br />' .
142
- 'Please make sure that storage directory <strong>%s</strong> has read and write permissions.'
143
- ),
144
- AI1WM_STORAGE_PATH
145
- );
146
- ?>
147
- </div>
148
- <?php endif; ?>
149
  </div>
150
  </div>
151
  <div class="ai1wm-right">
152
  <div class="ai1wm-sidebar">
153
  <div class="ai1wm-segment">
154
- <div class="ai1wm-share-button-container">
155
- <span>
156
- <a
157
- href="https://twitter.com/share"
158
- class="twitter-share-button"
159
- data-url="https://servmask.com"
160
- data-text="Check this epic WordPress Migration plugin"
161
- data-via="servmask"
162
- data-related="servmask"
163
- data-hashtags="servmask"
164
- >
165
- <?php _e( 'Tweet' ); ?>
166
- </a>
167
- <script>
168
- !function (d,s,id) {
169
- var js,
170
- fjs = d.getElementsByTagName(s)[0],
171
- p = /^http:/.test(d.location) ? 'http' : 'https';
172
-
173
- if (!d.getElementById(id)) {
174
- js = d.createElement(s);
175
- js.id = id;
176
- js.src = p+'://platform.twitter.com/widgets.js';
177
- fjs.parentNode.insertBefore(js, fjs);
178
- }
179
- }(document, 'script', 'twitter-wjs');
180
- </script>
181
- </span>
182
- <span>
183
- <div
184
- class="fb-like ai1wm-top-negative-four"
185
- data-href="https://www.facebook.com/servmaskproduct"
186
- data-layout="button_count"
187
- data-action="recommend"
188
- data-show-faces="true"
189
- data-share="false"
190
- ></div>
191
- </span>
192
- </div>
193
-
194
- <h2><?php _e( 'Leave Feedback' ); ?></h2>
195
 
196
- <div class="ai1wm-feedback">
197
- <ul class="ai1wm-feedback-types">
198
- <li>
199
- <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-1" name="ai1wm-feedback-type" value="review" />
200
- <a id="ai1wm-feedback-type-link-1" href="https://wordpress.org/support/view/plugin-reviews/all-in-one-wp-migration?rate=5#postform" target="_blank">
201
- <i></i>
202
- <span><?php _e( 'I would like to review this plugin' ); ?></span>
203
- </a>
204
- </li>
205
- <li>
206
- <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-2" name="ai1wm-feedback-type" value="suggestions" />
207
- <label for="ai1wm-feedback-type-2">
208
- <i></i>
209
- <span><?php _e( 'I have ideas to improve this plugin' ); ?></span>
210
- </label>
211
- </li>
212
- <li>
213
- <input type="radio" class="ai1wm-flat-radio-button ai1wm-feedback-type" id="ai1wm-feedback-type-3" name="ai1wm-feedback-type" value="help-needed" />
214
- <label for="ai1wm-feedback-type-3">
215
- <i></i>
216
- <span><?php _e( 'I need help with this plugin' ); ?></span>
217
- </label>
218
- </li>
219
- </ul>
220
 
221
- <div class="ai1wm-feedback-form">
222
- <div class="ai1wm-field">
223
- <input placeholder="<?php _e( 'Enter your email address..' ); ?>" type="text" id="ai1wm-feedback-email" class="ai1wm-feedback-email" />
224
- </div>
225
- <div class="ai1wm-field">
226
- <textarea rows="3" id="ai1wm-feedback-message" class="ai1wm-feedback-message" placeholder="<?php _e( 'Leave plugin developers any feedback here..' ); ?>"></textarea>
227
- </div>
228
- <div class="ai1wm-field ai1wm-feedback-terms-segment">
229
- <input type="checkbox" class="ai1wm-feedback-terms" id="ai1wm-feedback-terms" />
230
- <label for="ai1wm-feedback-terms"><?php _e( 'I agree that by clicking the send button below my email address and comments will be send to a ServMask server.' ); ?></label>
231
- </div>
232
- <div class="ai1wm-field">
233
- <div class="ai1wm-buttons">
234
- <button type="submit" id="ai1wm-feedback-submit" class="ai1wm-button-blue">
235
- <i class="ai1wm-icon-paperplane"></i>
236
- <?php _e( 'Send' ); ?>
237
- </button>
238
- <a class="ai1wm-feedback-cancel" id="ai1wm-feedback-cancel" href="#"><?php _e( 'Cancel' ); ?></a>
239
- </div>
240
- </div>
241
- </div>
242
- </div>
243
  </div>
244
  </div>
245
  </div>
23
  * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
  */
25
  ?>
 
 
 
 
 
 
 
 
 
 
26
 
27
  <div class="ai1wm-container">
28
  <div class="ai1wm-row">
29
  <div class="ai1wm-left">
30
+ <?php include AI1WM_TEMPLATES_PATH . '/common/maintenance-mode.php'; ?>
 
 
 
 
31
 
32
  <div class="ai1wm-holder">
33
+ <h1><i class="ai1wm-icon-publish"></i> <?php _e( 'Import Site', AI1WM_PLUGIN_NAME ); ?></h1>
 
 
 
 
34
 
35
+ <?php include AI1WM_TEMPLATES_PATH . '/common/report-problem.php'; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  <p class="ai1wm-clear">
38
+ <?php _e( 'Use the box below to upload the archive file.', AI1WM_PLUGIN_NAME ); ?><br />
39
+ <?php _e( 'When the file is successfully uploaded, it will be automatically restored on the current WordPress instance.', AI1WM_PLUGIN_NAME ); ?>
40
  </p>
41
 
42
+ <?php include AI1WM_TEMPLATES_PATH . '/import/import-buttons.php'; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
+ <?php do_action( 'ai1wm_import_left_end' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  </div>
46
  </div>
47
  <div class="ai1wm-right">
48
  <div class="ai1wm-sidebar">
49
  <div class="ai1wm-segment">
50
+ <?php if ( ! AI1WM_DEBUG ) : ?>
51
+ <?php include AI1WM_TEMPLATES_PATH . '/common/share-buttons.php'; ?>
52
+ <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
+ <h2><?php _e( 'Leave Feedback', AI1WM_PLUGIN_NAME ); ?></h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ <?php include AI1WM_TEMPLATES_PATH . '/common/leave-feedback.php'; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  </div>
58
  </div>
59
  </div>
loader.php CHANGED
@@ -46,23 +46,59 @@ require_once AI1WM_VENDOR_PATH .
46
 
47
  require_once AI1WM_VENDOR_PATH .
48
  DIRECTORY_SEPARATOR .
49
- 'zip-factory' .
50
  DIRECTORY_SEPARATOR .
51
- 'zip-factory' .
52
  DIRECTORY_SEPARATOR .
53
- 'lib' .
 
 
 
 
 
 
54
  DIRECTORY_SEPARATOR .
55
- 'ZipFactory.php';
56
 
57
  require_once AI1WM_VENDOR_PATH .
58
  DIRECTORY_SEPARATOR .
59
- 'storage-factory' .
60
  DIRECTORY_SEPARATOR .
61
- 'storage-factory' .
 
 
 
 
62
  DIRECTORY_SEPARATOR .
63
- 'lib' .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  DIRECTORY_SEPARATOR .
65
- 'StorageArea.php';
 
 
 
 
 
 
 
 
 
 
66
 
67
  require_once AI1WM_CONTROLLER_PATH .
68
  DIRECTORY_SEPARATOR .
@@ -76,6 +112,10 @@ require_once AI1WM_CONTROLLER_PATH .
76
  DIRECTORY_SEPARATOR .
77
  'class-ai1wm-export-controller.php';
78
 
 
 
 
 
79
  require_once AI1WM_CONTROLLER_PATH .
80
  DIRECTORY_SEPARATOR .
81
  'class-ai1wm-feedback-controller.php';
@@ -90,40 +130,64 @@ require_once AI1WM_CONTROLLER_PATH .
90
 
91
  require_once AI1WM_MODEL_PATH .
92
  DIRECTORY_SEPARATOR .
93
- 'class-ai1wm-maintenance.php';
94
 
95
  require_once AI1WM_MODEL_PATH .
96
  DIRECTORY_SEPARATOR .
97
- 'class-ai1wm-logger.php';
98
 
99
  require_once AI1WM_MODEL_PATH .
100
  DIRECTORY_SEPARATOR .
101
- 'class-ai1wm-template.php';
102
 
103
  require_once AI1WM_MODEL_PATH .
104
  DIRECTORY_SEPARATOR .
105
- 'class-ai1wm-export.php';
106
 
107
  require_once AI1WM_MODEL_PATH .
108
  DIRECTORY_SEPARATOR .
109
- 'class-ai1wm-import.php';
110
 
111
  require_once AI1WM_MODEL_PATH .
112
  DIRECTORY_SEPARATOR .
113
- 'class-ai1wm-error.php';
114
 
115
  require_once AI1WM_MODEL_PATH .
116
  DIRECTORY_SEPARATOR .
117
- 'class-ai1wm-feedback.php';
118
 
119
  require_once AI1WM_MODEL_PATH .
120
  DIRECTORY_SEPARATOR .
121
- 'class-ai1wm-report.php';
 
 
 
 
 
 
 
 
122
 
123
  require_once AI1WM_MODEL_PATH .
124
  DIRECTORY_SEPARATOR .
125
  'class-ai1wm-message.php';
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  require_once AI1WM_SERVICE_PATH .
128
  DIRECTORY_SEPARATOR .
129
  'class-ai1wm-service-interface.php';
@@ -134,28 +198,36 @@ require_once AI1WM_SERVICE_PATH .
134
 
135
  require_once AI1WM_SERVICE_PATH .
136
  DIRECTORY_SEPARATOR .
137
- 'class-ai1wm-service-media.php';
 
 
 
 
138
 
139
- require_once AI1WM_SERVICE_PATH .
140
  DIRECTORY_SEPARATOR .
141
- 'class-ai1wm-service-package.php';
142
 
143
- require_once AI1WM_SERVICE_PATH .
144
  DIRECTORY_SEPARATOR .
145
- 'class-ai1wm-service-plugins.php';
146
 
147
- require_once AI1WM_SERVICE_PATH .
148
  DIRECTORY_SEPARATOR .
149
- 'class-ai1wm-service-sites.php';
150
 
151
- require_once AI1WM_SERVICE_PATH .
152
  DIRECTORY_SEPARATOR .
153
- 'class-ai1wm-service-themes.php';
154
 
155
  require_once AI1WM_EXCEPTION_PATH .
156
  DIRECTORY_SEPARATOR .
157
- 'class-ai1wm-import-exception.php';
158
 
159
  require_once AI1WM_EXCEPTION_PATH .
160
  DIRECTORY_SEPARATOR .
161
- 'class-ai1wm-export-exception.php';
 
 
 
 
46
 
47
  require_once AI1WM_VENDOR_PATH .
48
  DIRECTORY_SEPARATOR .
49
+ 'servmask' .
50
  DIRECTORY_SEPARATOR .
51
+ 'filesystem' .
52
  DIRECTORY_SEPARATOR .
53
+ 'class-ai1wm-file.php';
54
+
55
+ require_once AI1WM_VENDOR_PATH .
56
+ DIRECTORY_SEPARATOR .
57
+ 'servmask' .
58
+ DIRECTORY_SEPARATOR .
59
+ 'cron' .
60
  DIRECTORY_SEPARATOR .
61
+ 'class-ai1wm-cron.php';
62
 
63
  require_once AI1WM_VENDOR_PATH .
64
  DIRECTORY_SEPARATOR .
65
+ 'servmask' .
66
  DIRECTORY_SEPARATOR .
67
+ 'iterator' .
68
+ DIRECTORY_SEPARATOR .
69
+ 'class-ai1wm-recursive-directory-iterator.php';
70
+
71
+ require_once AI1WM_VENDOR_PATH .
72
  DIRECTORY_SEPARATOR .
73
+ 'servmask' .
74
+ DIRECTORY_SEPARATOR .
75
+ 'filter' .
76
+ DIRECTORY_SEPARATOR .
77
+ 'class-ai1wm-recursive-exclude-filter.php';
78
+
79
+ require_once AI1WM_VENDOR_PATH .
80
+ DIRECTORY_SEPARATOR .
81
+ 'servmask' .
82
+ DIRECTORY_SEPARATOR .
83
+ 'archiver' .
84
+ DIRECTORY_SEPARATOR .
85
+ 'class-ai1wm-archiver.php';
86
+
87
+ require_once AI1WM_VENDOR_PATH .
88
+ DIRECTORY_SEPARATOR .
89
+ 'servmask' .
90
  DIRECTORY_SEPARATOR .
91
+ 'archiver' .
92
+ DIRECTORY_SEPARATOR .
93
+ 'class-ai1wm-compressor.php';
94
+
95
+ require_once AI1WM_VENDOR_PATH .
96
+ DIRECTORY_SEPARATOR .
97
+ 'servmask' .
98
+ DIRECTORY_SEPARATOR .
99
+ 'archiver' .
100
+ DIRECTORY_SEPARATOR .
101
+ 'class-ai1wm-extractor.php';
102
 
103
  require_once AI1WM_CONTROLLER_PATH .
104
  DIRECTORY_SEPARATOR .
112
  DIRECTORY_SEPARATOR .
113
  'class-ai1wm-export-controller.php';
114
 
115
+ require_once AI1WM_CONTROLLER_PATH .
116
+ DIRECTORY_SEPARATOR .
117
+ 'class-ai1wm-backup-controller.php';
118
+
119
  require_once AI1WM_CONTROLLER_PATH .
120
  DIRECTORY_SEPARATOR .
121
  'class-ai1wm-feedback-controller.php';
130
 
131
  require_once AI1WM_MODEL_PATH .
132
  DIRECTORY_SEPARATOR .
133
+ 'class-ai1wm-backup.php';
134
 
135
  require_once AI1WM_MODEL_PATH .
136
  DIRECTORY_SEPARATOR .
137
+ 'class-ai1wm-error.php';
138
 
139
  require_once AI1WM_MODEL_PATH .
140
  DIRECTORY_SEPARATOR .
141
+ 'class-ai1wm-export-abstract.php';
142
 
143
  require_once AI1WM_MODEL_PATH .
144
  DIRECTORY_SEPARATOR .
145
+ 'class-ai1wm-export-file.php';
146
 
147
  require_once AI1WM_MODEL_PATH .
148
  DIRECTORY_SEPARATOR .
149
+ 'class-ai1wm-feedback.php';
150
 
151
  require_once AI1WM_MODEL_PATH .
152
  DIRECTORY_SEPARATOR .
153
+ 'class-ai1wm-import-abstract.php';
154
 
155
  require_once AI1WM_MODEL_PATH .
156
  DIRECTORY_SEPARATOR .
157
+ 'class-ai1wm-import-file.php';
158
 
159
  require_once AI1WM_MODEL_PATH .
160
  DIRECTORY_SEPARATOR .
161
+ 'class-ai1wm-log.php';
162
+
163
+ require_once AI1WM_MODEL_PATH .
164
+ DIRECTORY_SEPARATOR .
165
+ 'class-ai1wm-logger.php';
166
+
167
+ require_once AI1WM_MODEL_PATH .
168
+ DIRECTORY_SEPARATOR .
169
+ 'class-ai1wm-maintenance.php';
170
 
171
  require_once AI1WM_MODEL_PATH .
172
  DIRECTORY_SEPARATOR .
173
  'class-ai1wm-message.php';
174
 
175
+ require_once AI1WM_MODEL_PATH .
176
+ DIRECTORY_SEPARATOR .
177
+ 'class-ai1wm-report.php';
178
+
179
+ require_once AI1WM_MODEL_PATH .
180
+ DIRECTORY_SEPARATOR .
181
+ 'class-ai1wm-status.php';
182
+
183
+ require_once AI1WM_MODEL_PATH .
184
+ DIRECTORY_SEPARATOR .
185
+ 'class-ai1wm-storage.php';
186
+
187
+ require_once AI1WM_MODEL_PATH .
188
+ DIRECTORY_SEPARATOR .
189
+ 'class-ai1wm-template.php';
190
+
191
  require_once AI1WM_SERVICE_PATH .
192
  DIRECTORY_SEPARATOR .
193
  'class-ai1wm-service-interface.php';
198
 
199
  require_once AI1WM_SERVICE_PATH .
200
  DIRECTORY_SEPARATOR .
201
+ 'class-ai1wm-service-package.php';
202
+
203
+ require_once AI1WM_EXCEPTION_PATH .
204
+ DIRECTORY_SEPARATOR .
205
+ 'class-ai1wm-backup-exception.php';
206
 
207
+ require_once AI1WM_EXCEPTION_PATH .
208
  DIRECTORY_SEPARATOR .
209
+ 'class-ai1wm-export-exception.php';
210
 
211
+ require_once AI1WM_EXCEPTION_PATH .
212
  DIRECTORY_SEPARATOR .
213
+ 'class-ai1wm-import-exception.php';
214
 
215
+ require_once AI1WM_EXCEPTION_PATH .
216
  DIRECTORY_SEPARATOR .
217
+ 'class-ai1wm-not-accessible-exception.php';
218
 
219
+ require_once AI1WM_EXCEPTION_PATH .
220
  DIRECTORY_SEPARATOR .
221
+ 'class-ai1wm-not-found-exception.php';
222
 
223
  require_once AI1WM_EXCEPTION_PATH .
224
  DIRECTORY_SEPARATOR .
225
+ 'class-ai1wm-not-readable-exception.php';
226
 
227
  require_once AI1WM_EXCEPTION_PATH .
228
  DIRECTORY_SEPARATOR .
229
+ 'class-ai1wm-not-writable-exception.php';
230
+
231
+ require_once AI1WM_EXCEPTION_PATH .
232
+ DIRECTORY_SEPARATOR .
233
+ 'class-ai1wm-storage-exception.php';
readme.txt CHANGED
@@ -3,72 +3,77 @@ Contributors: yani.iliev, bangelov, pimjitsawang
3
  Tags: db migration, migration, wordpress migration, db backup, db restore, website backup, website restore, website migration, website deploy, wordpress deploy, db backup, database export, database serialization, database find replace
4
  Requires at least: 3.3
5
  Tested up to: 4.1
6
- Stable tag: 2.0.5
7
  License: GPLv2 or later
8
 
9
  All-in-One WP Migration is the only tool that you will ever need to migrate a WordPress site.
10
 
11
  == Description ==
12
-
13
  The plugin allows you to export your database, media files, plugins, and themes.
14
- You can apply unlimited find and replace operations on your database and the plugin will also fix any serialization problems that occur during find/replace operations.
15
 
16
  All in One WP Plugin is the first plugin to offer true mobile experience on WordPress versions 3.3 and up.
17
 
18
- = Not yet Multisite compatible =
19
- * Support for multisites is comming soon
20
-
21
- = Works on Windows OS and IIS =
22
- * Tested the plugin on Windows 7 and Windows Server 2012 with the default available IIS
23
- * You will need to make sure that Windows\TEMP folder has write permissions for the IIS user
24
-
25
- = memory_limit requirement of only 32MB =
26
- * The plugin handles archiving of files by using 2048 bytes of chunks
27
- * The plugin processes database find/replacement in chunks of 1MB
28
 
29
  = Bypass all upload size restriction =
30
- * We use chunks to import your data and that way we bypass any webserver upload size restrictions up to **512MB** - commercial version supports up to **5GB**
31
 
32
- = Works with PHP v5.2.17 and above =
33
- * We tested the plugin on a php compiled with the following modules:
34
- `./configure --with-zlib --with-mysql`
35
 
36
  = Support for MySQL, PDO, MySQLi =
37
- * No matter what php mysql driver your webserver ships with, we support it
38
-
39
- = Support for ZipArchive and PclZIP =
40
- * Your export files are archived using the fast ZipArchive pecl extension. If your server doesn't have it, we fall back to PclZIP which is included in WordPress
41
-
42
- = WordPress v3.3 Support =
43
- * We tested every WordPress version from `3.3` up to `4.1`
44
-
45
- * [Get free help from us here](https://servmask.com/#contactModal)
46
- * [Report a bug or request a feature](https://servmask.com/#contactModal)
 
 
 
 
 
 
47
  * [Find out more about us](https://servmask.com)
48
 
49
  [youtube http://www.youtube.com/watch?v=5FMzLf9a4Dc]
50
 
51
  == Installation ==
52
-
53
  1. Upload the `all-in-one-wp-migration` folder to the `/wp-content/plugins/` directory
54
  1. Activate the All in One WP Migration plugin through the 'Plugins' menu in WordPress
55
  1. Configure the plugin by going to the `Site Migration` menu that appears in your admin menu
56
 
57
  == Screenshots ==
58
-
59
  1. Mobile Export page
60
  2. Mobile Import page
61
  3. Plugin Menu
62
 
63
  == Changelog ==
64
- = 2.0.5 =
65
- * Fixed a security issue where permissions were not checked during export/import. Thank you James Golovich for reporting. You can find more details on his website, [http://www.pritect.net](http://www.pritect.net)
 
 
 
 
 
 
 
 
 
66
 
67
  = 2.0.4 =
68
- * Update readme to reflect that the plugin is not multisite compatible
69
 
70
  = 2.0.3 =
71
- * Fixed a security issue when importing site using regular users
72
 
73
  = 2.0.2 =
74
  * Added support for WordPress v4.0
@@ -81,8 +86,8 @@ All in One WP Plugin is the first plugin to offer true mobile experience on Word
81
  * New improved UI and UX
82
  * New improved language translations on the menu items and help texts
83
  * Better error handling and notifications
84
- * Fixed a bug when exporting comments and associated comments meta data
85
- * Fixed a bug when using find and replace functionality
86
  * Fixed a bug with storage directory permissions and search indexation
87
 
88
  = 1.9.2 =
@@ -95,8 +100,8 @@ All in One WP Plugin is the first plugin to offer true mobile experience on Word
95
  * New improved design on the export/import page
96
  * Added an option for gathering user experience statistics
97
  * Added a message box with important notifications about the plugin
98
- * Fixed a bug when exporting database with multiple WordPress sites
99
- * Fixed a bug when exporting database with table constraints
100
  * Fixed a bug with auto recognizing zip archiver
101
 
102
  = 1.8.1 =
@@ -106,15 +111,15 @@ All in One WP Plugin is the first plugin to offer true mobile experience on Word
106
  = 1.8.0 =
107
  * Added support for dynamically recognizing Site URL and Home URL on the import page
108
  * Fixed a bug when maximum uploaded size is exceeded
109
- * Fixed a bug when exporting big database tables
110
 
111
  = 1.7.2 =
112
  * Added support for automatically switching database adapters for better performance and optimization
113
- * Fixed a bug when using host:port syntax with MySQL PDO
114
- * Fixed a bug when using find and replace functionality
115
 
116
  = 1.7.1 =
117
- * Fixed a bug when exporting WordPress plugins directory
118
 
119
  = 1.7.0 =
120
  * Added storage layer to avoid permission issues with OS's directory used for temporary storage
@@ -135,18 +140,18 @@ All in One WP Plugin is the first plugin to offer true mobile experience on Word
135
  * Fixed typos on the import page. Thanks to Terry Heenan
136
 
137
  = 1.4.0 =
138
- * Adding a twitter and facebook share buttons to the sidebar on import and export pages
139
 
140
  = 1.3.1 =
141
  * Fixed a bug when the user was unable to import site archive
142
- * Optimize and speed up import process
143
 
144
  = 1.3.0 =
145
  * Added support for mysql connection to happen over sockets or TCP
146
  * Added support for Windows OS and fully tested the plugin on IIS
147
  * Added support for limited memory_limit - 1MB - The plugin now requires only 1MB to operate properly
148
  * Added support for multisite
149
- * Use mysql_unbuffered_query instead of mysql_query to overcome any memory problems
150
  * Fixed a deprecated warning for mysql_pconnect when php 5.5 and above is used
151
  * Fixed memory_limit problem with PCLZIP library
152
  * Fixed a bug when the archive is exported with zero size when using PCLZIP
@@ -157,30 +162,28 @@ All in One WP Plugin is the first plugin to offer true mobile experience on Word
157
  * Fixed an issue when HTTP Error was shown on some hosts after import, credit to Michael Simon
158
  * Fixed an issue when exporting databases with different prefix than wp_, credit to najtrox
159
  * Fixed an issue when PDO is avalable but mysql driver for PDO is not, credit to Jaydesain69
160
- * Delete a plugin specific option when uninstalling the plugin (clean after itself)
161
  * Support is done via Zendesk
162
- * Include WP Version and Plugin version in the feedback form
163
 
164
  = 1.2.0 =
165
  * Increased upload limit of files from 128MB to 512MB
166
- * Use ZipArchive with fallback to PclZip (a few users notified us that they don’t have ZipArchive enabled on their servers)
167
- * Use PDO with fallback to mysql (a few users notified us that they dont have PDO enabled on their servers, mysql is deprecated as of PHP v5.5 but we are supporting PHP v5.2.17).
168
- * Support for PHP v5.2.17 and WordPress v3.3 and above.
169
- * Fix a bug during export that causes plugins to not be exported on some hosts (the problem that you are experiencing).
170
 
171
  = 1.1.0 =
172
  * Importing files using chunks to overcome any webserver upload size restriction
173
  * Fixed a bug where HTTP code error was shown to some users
174
 
175
  = 1.0.0 =
176
-
177
  * Export database as SQL file
178
  * Export media files
179
  * Export themes files
180
  * Export installed plugins
181
- * Unlimited Find & replaces
182
  * Option to exclude spam comments
183
- * Option to apply find & replace to GUIDs
184
  * Option to exclude post revisions
185
  * Option to exclude tables data
186
- * WordPress multisite support
3
  Tags: db migration, migration, wordpress migration, db backup, db restore, website backup, website restore, website migration, website deploy, wordpress deploy, db backup, database export, database serialization, database find replace
4
  Requires at least: 3.3
5
  Tested up to: 4.1
6
+ Stable tag: 3.0.1
7
  License: GPLv2 or later
8
 
9
  All-in-One WP Migration is the only tool that you will ever need to migrate a WordPress site.
10
 
11
  == Description ==
 
12
  The plugin allows you to export your database, media files, plugins, and themes.
13
+ You can apply unlimited find/replace operations on your database and the plugin will also fix any serialization problems that occur during find/replace operations.
14
 
15
  All in One WP Plugin is the first plugin to offer true mobile experience on WordPress versions 3.3 and up.
16
 
17
+ = Works on all hosting providers =
18
+ * The plugin does not depend on any extensions, making it compatible with all PHP hosting providers.
19
+ * The plugin exports and imports data in time chunks of 3 seconds each, which keeps the plugin below the max execution time that most providers set to 30 seconds.
20
+ * We have tested the plugin on the major Linux distributions, Mac OS X, and Microsoft Windows.
 
 
 
 
 
 
21
 
22
  = Bypass all upload size restriction =
23
+ * We use chunks to import your data and that way we bypass any webserver upload size restrictions up to **512MB** - commercial version supports up to **5GB**.
24
 
25
+ = 0 Dependencies =
26
+ * The plugin does not require any php extensions and can work with PHP v5.2.
 
27
 
28
  = Support for MySQL, PDO, MySQLi =
29
+ * No matter what php mysql driver your webserver ships with, we support it.
30
+
31
+ = Support WordPress v3.3 up to v4.1 =
32
+ * We tested every WordPress version from `3.3` up to `4.1`.
33
+
34
+ = Migrate WordPress to most popular cloud services using our completely new extensions =
35
+ * [Dropbox](https://servmask.com/products/dropbox-extension)
36
+ * [Google Drive](https://servmask.com/products/google-drive-extension)
37
+ * [Amazon S3](https://servmask.com/products/amazon-s3-extension)
38
+ * [Multisite](https://servmask.com/products/multisite-extension)
39
+ * [Unlimited](https://servmask.com/products/unlimited-extension)
40
+ * And many more to come
41
+
42
+ = Contact us =
43
+ * [Get free help from us here](https://servmask.com/help)
44
+ * [Report a bug or request a feature](https://servmask.com/help)
45
  * [Find out more about us](https://servmask.com)
46
 
47
  [youtube http://www.youtube.com/watch?v=5FMzLf9a4Dc]
48
 
49
  == Installation ==
 
50
  1. Upload the `all-in-one-wp-migration` folder to the `/wp-content/plugins/` directory
51
  1. Activate the All in One WP Migration plugin through the 'Plugins' menu in WordPress
52
  1. Configure the plugin by going to the `Site Migration` menu that appears in your admin menu
53
 
54
  == Screenshots ==
 
55
  1. Mobile Export page
56
  2. Mobile Import page
57
  3. Plugin Menu
58
 
59
  == Changelog ==
60
+ = 3.0.1 =
61
+ * Added export to File, [Dropbox](https://servmask.com/products/dropbox-extension), [Amazon S3](https://servmask.com/products/amazon-s3-extension), [Google Drive](https://servmask.com/products/google-drive-extension)
62
+ * Added import from File, [Dropbox](https://servmask.com/products/dropbox-extension), [Amazon S3](https://servmask.com/products/amazon-s3-extension), [Google Drive](https://servmask.com/products/google-drive-extension)
63
+ * Implemented our own archiving format that reduces export and import by a factor of 10
64
+ * One-click export with the new simplified export page
65
+ * Improved upload functionality with auto-recognizing chunk size on import
66
+ * New **Backups** page for storing all WordPress site exports
67
+ * Easy restore WordPress site from **Backups** page
68
+ * Monitoring availability of the disk space on the server
69
+ * Both export and import happen in time chunks of 3 seconds
70
+ * Plugin works behind HTTP basic authentication
71
 
72
  = 2.0.4 =
73
+ * Updated readme to reflect that the plugin is not multisite compatible
74
 
75
  = 2.0.3 =
76
+ * Fixed a security issue while importing site using regular users
77
 
78
  = 2.0.2 =
79
  * Added support for WordPress v4.0
86
  * New improved UI and UX
87
  * New improved language translations on the menu items and help texts
88
  * Better error handling and notifications
89
+ * Fixed a bug while exporting comments and associated comments meta data
90
+ * Fixed a bug while using find/replace functionality
91
  * Fixed a bug with storage directory permissions and search indexation
92
 
93
  = 1.9.2 =
100
  * New improved design on the export/import page
101
  * Added an option for gathering user experience statistics
102
  * Added a message box with important notifications about the plugin
103
+ * Fixed a bug while exporting database with multiple WordPress sites
104
+ * Fixed a bug while exporting database with table constraints
105
  * Fixed a bug with auto recognizing zip archiver
106
 
107
  = 1.8.1 =
111
  = 1.8.0 =
112
  * Added support for dynamically recognizing Site URL and Home URL on the import page
113
  * Fixed a bug when maximum uploaded size is exceeded
114
+ * Fixed a bug while exporting big database tables
115
 
116
  = 1.7.2 =
117
  * Added support for automatically switching database adapters for better performance and optimization
118
+ * Fixed a bug while using host:port syntax with MySQL PDO
119
+ * Fixed a bug while using find/replace functionality
120
 
121
  = 1.7.1 =
122
+ * Fixed a bug while exporting WordPress plugins directory
123
 
124
  = 1.7.0 =
125
  * Added storage layer to avoid permission issues with OS's directory used for temporary storage
140
  * Fixed typos on the import page. Thanks to Terry Heenan
141
 
142
  = 1.4.0 =
143
+ * Added a Twitter and Facebook share buttons to the sidebar on import and export pages
144
 
145
  = 1.3.1 =
146
  * Fixed a bug when the user was unable to import site archive
147
+ * Optimized and speeded up import process
148
 
149
  = 1.3.0 =
150
  * Added support for mysql connection to happen over sockets or TCP
151
  * Added support for Windows OS and fully tested the plugin on IIS
152
  * Added support for limited memory_limit - 1MB - The plugin now requires only 1MB to operate properly
153
  * Added support for multisite
154
+ * Used mysql_unbuffered_query instead of mysql_query to overcome any memory problems
155
  * Fixed a deprecated warning for mysql_pconnect when php 5.5 and above is used
156
  * Fixed memory_limit problem with PCLZIP library
157
  * Fixed a bug when the archive is exported with zero size when using PCLZIP
162
  * Fixed an issue when HTTP Error was shown on some hosts after import, credit to Michael Simon
163
  * Fixed an issue when exporting databases with different prefix than wp_, credit to najtrox
164
  * Fixed an issue when PDO is avalable but mysql driver for PDO is not, credit to Jaydesain69
165
+ * Deleted a plugin specific option when uninstalling the plugin (clean after itself)
166
  * Support is done via Zendesk
167
+ * Included WP Version and Plugin version in the feedback form
168
 
169
  = 1.2.0 =
170
  * Increased upload limit of files from 128MB to 512MB
171
+ * Used ZipArchive with fallback to PclZip (a few users notified us that they don’t have ZipArchive enabled on their servers)
172
+ * Used PDO with fallback to mysql (a few users notified us that they dont have PDO enabled on their servers, mysql is deprecated as of PHP v5.5 but we are supporting PHP v5.2.17)
173
+ * Supported PHP v5.2.17 and WordPress v3.3 and above
174
+ * Fixed a bug during export that causes plugins to not be exported on some hosts (the problem that you are experiencing)
175
 
176
  = 1.1.0 =
177
  * Importing files using chunks to overcome any webserver upload size restriction
178
  * Fixed a bug where HTTP code error was shown to some users
179
 
180
  = 1.0.0 =
 
181
  * Export database as SQL file
182
  * Export media files
183
  * Export themes files
184
  * Export installed plugins
185
+ * Unlimited find/replace actions
186
  * Option to exclude spam comments
187
+ * Option to apply find/replace to GUIDs
188
  * Option to exclude post revisions
189
  * Option to exclude tables data
 
uninstall.php CHANGED
@@ -35,9 +35,10 @@ if ( defined( 'WP_UNINSTALL_PLUGIN' ) ) {
35
  global $wpdb, $wp_filesystem;
36
 
37
  // delete any options or other data stored in the database here
38
- delete_option( AI1WM_MAINTENANCE_MODE );
39
- delete_option( AI1WM_EXPORT_OPTIONS );
40
- delete_option( AI1WM_ERROR_HANDLER );
41
- delete_option( AI1WM_EXCEPTION_HANDLER );
42
- delete_option( AI1WM_MESSAGES );
 
43
  }
35
  global $wpdb, $wp_filesystem;
36
 
37
  // delete any options or other data stored in the database here
38
+ delete_site_option( AI1WM_MAINTENANCE_MODE );
39
+ delete_site_option( AI1WM_EXPORT_OPTIONS );
40
+ delete_site_option( AI1WM_ERROR_HANDLER );
41
+ delete_site_option( AI1WM_EXCEPTION_HANDLER );
42
+ delete_site_option( AI1WM_MESSAGES );
43
+ delete_site_option( AI1WM_SECRET_KEY );
44
  }