Version Description
Download this release
Release Info
Developer | cory@lamle.org |
Plugin | Duplicator – WordPress Migration Plugin |
Version | 1.3.36 |
Comparing to | |
See all releases |
Code changes from version 1.3.34 to 1.3.36
- assets/css/style.css +10 -17
- assets/js/javascript.php +1 -1
- classes/class.db.php +39 -8
- classes/class.logging.php +3 -3
- classes/class.plugin.upgrade.php +9 -3
- classes/class.server.php +104 -78
- classes/class.settings.php +104 -4
- classes/package/class.pack.archive.php +9 -3
- classes/package/class.pack.archive.zip.php +3 -3
- classes/package/class.pack.database.php +18 -13
- classes/package/class.pack.installer.php +100 -95
- classes/package/class.pack.php +96 -43
- classes/package/duparchive/class.pack.archive.duparchive.php +89 -93
- classes/ui/class.ui.notice.php +59 -12
- classes/utilities/class.u.php +24 -20
- classes/utilities/class.u.shell.php +1 -1
- ctrls/class.web.services.php +77 -66
- ctrls/ctrl.package.php +6 -105
- ctrls/ctrl.tools.php +1 -1
- define.php +5 -9
- duplicator.php +3 -3
- installer/dup-installer/classes/class.db.php +79 -25
- installer/dup-installer/classes/class.logging.php +1 -1
- installer/dup-installer/classes/config/class.constants.php +0 -1
- installer/dup-installer/ctrls/ctrl.s2.dbinstall.php +33 -24
- installer/dup-installer/ctrls/ctrl.s2.dbtest.php +37 -27
- installer/dup-installer/index.php +1 -1
- installer/dup-installer/main.installer.php +1 -1
- lib/snaplib/class.snaplib.u.io.php +334 -14
- lib/snaplib/class.snaplib.u.json.php +9 -0
- lib/snaplib/class.snaplib.u.string.php +57 -0
- readme.txt +3 -3
- uninstall.php +9 -13
- views/packages/controller.php +9 -15
- views/packages/details/controller.php +1 -1
- views/packages/details/detail.php +27 -43
- views/packages/main/packages.php +5 -6
- views/packages/main/s1.setup1.php +12 -2
- views/packages/main/s1.setup2.php +53 -38
- views/packages/main/s2.scan3.php +4 -4
- views/packages/main/s3.build.php +15 -5
- views/settings/general.php +164 -160
- views/settings/packages.php +1 -1
- views/settings/storage.php +166 -29
- views/tools/diagnostics/inc.data.php +1 -1
- views/tools/diagnostics/information.php +1 -1
- views/tools/diagnostics/logging.php +3 -3
assets/css/style.css
CHANGED
@@ -16,23 +16,11 @@ span.btn-separator {content: ''; display: inline-block; background: silver; marg
|
|
16 |
a.grey-icon i.fa {color:#777}
|
17 |
i.grey-icon {color:#777}
|
18 |
|
19 |
-
.no-display {
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
.
|
24 |
-
color: #0074ab;
|
25 |
-
cursor: pointer;
|
26 |
-
text-decoration: underline;
|
27 |
-
}
|
28 |
-
|
29 |
-
.link-style:hover {
|
30 |
-
color: #00a0d2;
|
31 |
-
}
|
32 |
-
|
33 |
-
.no-decoration {
|
34 |
-
text-decoration: none;
|
35 |
-
}
|
36 |
|
37 |
/*TABS*/
|
38 |
ul.category-tabs li {cursor: pointer}
|
@@ -238,3 +226,8 @@ div.dup-screen-hlp-info {line-height:26px; padding:10px 0 10px 0}
|
|
238 |
#dup-lite-inst-mode-details p {
|
239 |
margin: 1em 0;
|
240 |
}
|
|
|
|
|
|
|
|
|
|
16 |
a.grey-icon i.fa {color:#777}
|
17 |
i.grey-icon {color:#777}
|
18 |
|
19 |
+
.no-display {display: none !important;}
|
20 |
+
.link-style {color: #0074ab; cursor: pointer; text-decoration: underline;}
|
21 |
+
.link-style:hover {color: #00a0d2;}
|
22 |
+
.no-decoration {text-decoration: none;}
|
23 |
+
p.description {padding-top:3px}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
/*TABS*/
|
26 |
ul.category-tabs li {cursor: pointer}
|
226 |
#dup-lite-inst-mode-details p {
|
227 |
margin: 1em 0;
|
228 |
}
|
229 |
+
|
230 |
+
.storage_pos_fixed_label {
|
231 |
+
display: inline-block;
|
232 |
+
width: 90px;
|
233 |
+
}
|
assets/js/javascript.php
CHANGED
@@ -96,7 +96,7 @@ Duplicator.OpenLogWindow = function(target)
|
|
96 |
if (target != null) {
|
97 |
window.open('?page=duplicator-tools&tab=diagnostics§ion=log', 'log-win');
|
98 |
} else {
|
99 |
-
window.open('<?php echo esc_js(
|
100 |
}
|
101 |
};
|
102 |
|
96 |
if (target != null) {
|
97 |
window.open('?page=duplicator-tools&tab=diagnostics§ion=log', 'log-win');
|
98 |
} else {
|
99 |
+
window.open('<?php echo esc_js(DUP_Settings::getSsdirUrl()); ?>' + '/' + log)
|
100 |
}
|
101 |
};
|
102 |
|
classes/class.db.php
CHANGED
@@ -150,18 +150,26 @@ class DUP_DB extends wpdb
|
|
150 |
'/usr/mysql/bin/mysqldump',
|
151 |
'/usr/bin/mysqldump',
|
152 |
'/opt/local/lib/mysql6/bin/mysqldump',
|
153 |
-
|
|
|
154 |
);
|
155 |
}
|
156 |
|
|
|
157 |
foreach ($paths as $path) {
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
return false;
|
@@ -220,4 +228,27 @@ class DUP_DB extends wpdb
|
|
220 |
return @esc_sql($sql);
|
221 |
}
|
222 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
150 |
'/usr/mysql/bin/mysqldump',
|
151 |
'/usr/bin/mysqldump',
|
152 |
'/opt/local/lib/mysql6/bin/mysqldump',
|
153 |
+
'/opt/local/lib/mysql5/bin/mysqldump',
|
154 |
+
'/usr/bin/mysqldump',
|
155 |
);
|
156 |
}
|
157 |
|
158 |
+
$exec_available = function_exists('exec');
|
159 |
foreach ($paths as $path) {
|
160 |
+
if (@file_exists($path)) {
|
161 |
+
if (DUP_Util::isExecutable($path)) {
|
162 |
+
return $path;
|
163 |
+
}
|
164 |
+
} elseif ($exec_available) {
|
165 |
+
$out = array();
|
166 |
+
$rc = -1;
|
167 |
+
$cmd = $path . ' --help';
|
168 |
+
@exec($cmd, $out, $rc);
|
169 |
+
if ($rc === 0) {
|
170 |
+
return $path;
|
171 |
+
}
|
172 |
+
}
|
173 |
}
|
174 |
|
175 |
return false;
|
228 |
return @esc_sql($sql);
|
229 |
}
|
230 |
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* this function escape sql string without add and remove remove_placeholder_escape
|
234 |
+
* don't work on array
|
235 |
+
*
|
236 |
+
* @global type $wpdb
|
237 |
+
* @param mixed $sql
|
238 |
+
* @return string
|
239 |
+
*/
|
240 |
+
public static function escValueToQueryString($value)
|
241 |
+
{
|
242 |
+
global $wpdb;
|
243 |
+
|
244 |
+
if (is_null($value)) {
|
245 |
+
return 'NULL';
|
246 |
+
}
|
247 |
+
|
248 |
+
if ($wpdb->use_mysqli) {
|
249 |
+
return '"'.mysqli_real_escape_string($wpdb->dbh, $value).'"';
|
250 |
+
} else {
|
251 |
+
return '"'.mysql_real_escape_string($value, $wpdb->dbh).'"';
|
252 |
+
}
|
253 |
+
}
|
254 |
}
|
classes/class.logging.php
CHANGED
@@ -49,7 +49,7 @@ class DUP_Log
|
|
49 |
throw new Exception("A name value is required to open a file log.");
|
50 |
}
|
51 |
self::Close();
|
52 |
-
if ((self::$logFileHandle = @fopen(
|
53 |
self::$logFileHandle = null;
|
54 |
return false;
|
55 |
} else {
|
@@ -213,7 +213,7 @@ class DUP_Log
|
|
213 |
{
|
214 |
$default_key = self::getDefaultKey();
|
215 |
$backup_log_filename = "dup_$default_key.log1";
|
216 |
-
$backup_path =
|
217 |
return $backup_path;
|
218 |
}
|
219 |
|
@@ -226,7 +226,7 @@ class DUP_Log
|
|
226 |
{
|
227 |
$default_key = self::getDefaultKey();
|
228 |
$log_filename = "dup_$default_key.log";
|
229 |
-
$file_path =
|
230 |
return $file_path;
|
231 |
}
|
232 |
|
49 |
throw new Exception("A name value is required to open a file log.");
|
50 |
}
|
51 |
self::Close();
|
52 |
+
if ((self::$logFileHandle = @fopen(DUP_Settings::getSsdirPath()."/{$nameHash}.log", "a+")) === false) {
|
53 |
self::$logFileHandle = null;
|
54 |
return false;
|
55 |
} else {
|
213 |
{
|
214 |
$default_key = self::getDefaultKey();
|
215 |
$backup_log_filename = "dup_$default_key.log1";
|
216 |
+
$backup_path = DUP_Settings::getSsdirPath()."/".$backup_log_filename;
|
217 |
return $backup_path;
|
218 |
}
|
219 |
|
226 |
{
|
227 |
$default_key = self::getDefaultKey();
|
228 |
$log_filename = "dup_$default_key.log";
|
229 |
+
$file_path = DUP_Settings::getSsdirPath()."/".$log_filename;
|
230 |
return $file_path;
|
231 |
}
|
232 |
|
classes/class.plugin.upgrade.php
CHANGED
@@ -26,7 +26,7 @@ class DUP_LITE_Plugin_Upgrade
|
|
26 |
protected static function newInstallation()
|
27 |
{
|
28 |
self::updateDatabase();
|
29 |
-
|
30 |
update_option(DUP_UI_Notice::OPTION_KEY_INSTALLER_HASH_NOTICE, true);
|
31 |
|
32 |
//WordPress Options Hooks
|
@@ -36,11 +36,17 @@ class DUP_LITE_Plugin_Upgrade
|
|
36 |
protected static function updateInstallation($oldVersion)
|
37 |
{
|
38 |
self::updateDatabase();
|
39 |
-
|
40 |
if (version_compare($oldVersion, '1.3.30', '<=')) {
|
41 |
update_option(DUP_UI_Notice::OPTION_KEY_INSTALLER_HASH_NOTICE, true);
|
42 |
}
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
//WordPress Options Hooks
|
45 |
update_option(self::DUP_VERSION_OPT_KEY, DUPLICATOR_VERSION);
|
46 |
}
|
26 |
protected static function newInstallation()
|
27 |
{
|
28 |
self::updateDatabase();
|
29 |
+
|
30 |
update_option(DUP_UI_Notice::OPTION_KEY_INSTALLER_HASH_NOTICE, true);
|
31 |
|
32 |
//WordPress Options Hooks
|
36 |
protected static function updateInstallation($oldVersion)
|
37 |
{
|
38 |
self::updateDatabase();
|
39 |
+
|
40 |
if (version_compare($oldVersion, '1.3.30', '<=')) {
|
41 |
update_option(DUP_UI_Notice::OPTION_KEY_INSTALLER_HASH_NOTICE, true);
|
42 |
}
|
43 |
+
|
44 |
+
if (version_compare($oldVersion, '1.3.35', '<')) {
|
45 |
+
update_option(DUP_UI_Notice::OPTION_KEY_NEW_STORAGE_POSITION, true);
|
46 |
+
DUP_Settings::Set('storage_position', DUP_Settings::STORAGE_POSITION_LECAGY);
|
47 |
+
DUP_Settings::Save();
|
48 |
+
}
|
49 |
+
|
50 |
//WordPress Options Hooks
|
51 |
update_option(self::DUP_VERSION_OPT_KEY, DUPLICATOR_VERSION);
|
52 |
}
|
classes/class.server.php
CHANGED
@@ -13,11 +13,10 @@ require_once (DUPLICATOR_PLUGIN_PATH.'classes/utilities/class.u.php');
|
|
13 |
* @copyright (c) 2017, Snapcreek LLC
|
14 |
*
|
15 |
*/
|
16 |
-
// Exit if accessed directly
|
17 |
-
if (!defined('DUPLICATOR_VERSION')) exit;
|
18 |
|
19 |
class DUP_Server
|
20 |
{
|
|
|
21 |
const LockFileName = 'lockfile.txt';
|
22 |
|
23 |
// Possibly use in the future if we want to prevent double building
|
@@ -34,8 +33,8 @@ class DUP_Server
|
|
34 |
// Possibly use in the future if we want to prevent double building
|
35 |
public static function setEngineLock($shouldLock)
|
36 |
{
|
37 |
-
$success
|
38 |
-
$locking_file
|
39 |
if ($locking_file != false) {
|
40 |
if ($shouldLock) {
|
41 |
$success = @flock($locking_file, LOCK_EX | LOCK_NB);
|
@@ -48,6 +47,24 @@ class DUP_Server
|
|
48 |
return $success;
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
/**
|
52 |
* Gets the system requirements which must pass to build a package
|
53 |
*
|
@@ -62,8 +79,8 @@ class DUP_Server
|
|
62 |
$dup_tests['PHP']['SAFE_MODE'] = $safe_ini != 'on' || $safe_ini != 'yes' || $safe_ini != 'true' || ini_get("safe_mode") != 1 ? 'Pass' : 'Fail';
|
63 |
self::logRequirementFail($dup_tests['PHP']['SAFE_MODE'], 'SAFE_MODE is on.');
|
64 |
|
65 |
-
$dup_tests['PHP']['VERSION']
|
66 |
-
$phpversion
|
67 |
self::logRequirementFail($dup_tests['PHP']['VERSION'], 'PHP version('.$phpversion.') is lower than 5.2.9');
|
68 |
|
69 |
if (DUP_Settings::Get('archive_build_mode') == DUP_Archive_Build_Mode::ZipArchive) {
|
@@ -71,41 +88,45 @@ class DUP_Server
|
|
71 |
self::logRequirementFail($dup_tests['PHP']['ZIP'], 'ZipArchive class doesn\'t exist.');
|
72 |
}
|
73 |
|
74 |
-
$dup_tests['PHP']['FUNC_1']
|
75 |
self::logRequirementFail($dup_tests['PHP']['FUNC_1'], 'file_get_contents function doesn\'t exist.');
|
76 |
|
77 |
-
$dup_tests['PHP']['FUNC_2']
|
78 |
self::logRequirementFail($dup_tests['PHP']['FUNC_2'], 'file_put_contents function doesn\'t exist.');
|
79 |
|
80 |
-
$dup_tests['PHP']['FUNC_3']
|
81 |
self::logRequirementFail($dup_tests['PHP']['FUNC_3'], 'mb_strlen function doesn\'t exist.');
|
82 |
|
83 |
-
$dup_tests['PHP']['ALL']
|
84 |
|
85 |
//REQUIRED PATHS
|
86 |
-
$abs_path
|
87 |
$handle_test = @opendir($abs_path);
|
88 |
$dup_tests['IO']['WPROOT'] = is_writeable($abs_path) && $handle_test ? 'Pass' : 'Warn';
|
89 |
@closedir($handle_test);
|
90 |
self::logRequirementFail($dup_tests['IO']['WPROOT'], $abs_path.' (abs path) can\'t be opened.');
|
91 |
|
92 |
-
$dup_tests['IO']['SSDIR']
|
93 |
-
self::logRequirementFail($dup_tests['IO']['SSDIR'],
|
94 |
|
95 |
-
$dup_tests['IO']['SSTMP']
|
96 |
-
self::logRequirementFail($dup_tests['IO']['SSTMP'],
|
97 |
|
98 |
-
$dup_tests['IO']['ALL']
|
99 |
|
100 |
//SERVER SUPPORT
|
101 |
-
$dup_tests['SRV']['MYSQLi']
|
102 |
self::logRequirementFail($dup_tests['SRV']['MYSQLi'], 'mysqli_connect function doesn\'t exist.');
|
103 |
|
104 |
-
|
|
|
|
|
|
|
|
|
105 |
$dup_tests['SRV']['MYSQL_VER'] = version_compare($db_version, '5.0', '>=') ? 'Pass' : 'Fail';
|
106 |
self::logRequirementFail($dup_tests['SRV']['MYSQL_VER'], 'MySQL version '.$db_version.' is lower than 5.0.');
|
107 |
|
108 |
-
$dup_tests['SRV']['ALL']
|
109 |
|
110 |
//RESERVED FILES
|
111 |
$dup_tests['RES']['INSTALL'] = !(self::hasInstallerFiles()) ? 'Pass' : 'Fail';
|
@@ -118,31 +139,32 @@ class DUP_Server
|
|
118 |
}
|
119 |
|
120 |
/**
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
129 |
throw new Exception('Exception: Empty $testStatus [File: '.__FILE__.', Ln: '.__LINE__);
|
130 |
-
|
131 |
|
132 |
-
|
133 |
throw new Exception('Exception: Empty $errorMessage [File: '.__FILE__.', Ln: '.__LINE__);
|
134 |
-
|
135 |
|
136 |
-
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
|
142 |
-
|
143 |
DUP_LOG::trace($errorMessage);
|
144 |
-
|
145 |
-
|
146 |
|
147 |
/**
|
148 |
* Gets the system checks which are not required
|
@@ -168,19 +190,19 @@ class DUP_Server
|
|
168 |
$php_test1 = empty($php_test1) ? true : false;
|
169 |
self::logCheckFalse($php_test1, 'open_basedir is enabled.');
|
170 |
|
171 |
-
$max_execution_time
|
172 |
-
$php_test2
|
173 |
-
if
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
|
180 |
-
$php_test3
|
181 |
self::logCheckFalse($php_test3, 'mysqli_connect function doesn\'t exist.');
|
182 |
|
183 |
-
$php_test4
|
184 |
self::logCheckFalse($php_test4, 'PHP Version is lower than 5.3.');
|
185 |
|
186 |
$checks['SRV']['PHP']['websrv'] = $php_test0;
|
@@ -196,9 +218,9 @@ class DUP_Server
|
|
196 |
self::logCheckFalse($wp_test1, 'WP version ('.$wp_version.') is lower than the DUPLICATOR_SCAN_MIN_WP ('.DUPLICATOR_SCAN_MIN_WP.').');
|
197 |
|
198 |
//Core Files
|
199 |
-
$files
|
200 |
-
$proper_wp_config_file_path
|
201 |
-
$files['wp-config.php']
|
202 |
self::logCheckFalse($files['wp-config.php'], 'The wp-config.php file doesn\'t exist on the '.$proper_wp_config_file_path);
|
203 |
|
204 |
/** searching wp-config in working word press is not worthy
|
@@ -209,9 +231,11 @@ class DUP_Server
|
|
209 |
//Core dir and files logic
|
210 |
if (isset($_POST['file_notice']) && isset($_POST['dir_notice'])) {
|
211 |
//means if there are core directories excluded or core files excluded return false
|
212 |
-
if ((bool) $_POST['file_notice'] || (bool) $_POST['dir_notice'])
|
213 |
-
|
214 |
-
|
|
|
|
|
215 |
$wp_test2 = $files['wp-config.php'];
|
216 |
}
|
217 |
|
@@ -236,24 +260,25 @@ class DUP_Server
|
|
236 |
}
|
237 |
|
238 |
/**
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
|
|
249 |
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
}
|
258 |
|
259 |
/**
|
@@ -270,7 +295,8 @@ class DUP_Server
|
|
270 |
if (!empty($glob_files)) {
|
271 |
return true;
|
272 |
}
|
273 |
-
} elseif (file_exists($path))
|
|
|
274 |
}
|
275 |
return false;
|
276 |
}
|
@@ -290,16 +316,16 @@ class DUP_Server
|
|
290 |
public static function getInstallerFiles()
|
291 |
{
|
292 |
// alphanumeric 7 time, then -(dash), then 8 digits
|
293 |
-
$abs_path
|
294 |
$four_digit_glob_pattern = '[0-9][0-9][0-9][0-9]';
|
295 |
-
$retArr
|
296 |
basename(DUPLICATOR_INSTALLER_DIRECTORY).' '.esc_html__('(directory)', 'duplicator') => DUPLICATOR_INSTALLER_DIRECTORY,
|
297 |
-
DUPLICATOR_INSTALL_PHP
|
298 |
-
|
299 |
-
DUPLICATOR_INSTALL_BAK
|
300 |
-
|
301 |
-
|
302 |
-
'dup-installer-bootlog__[HASH].txt'
|
303 |
);
|
304 |
if (DUPLICATOR_INSTALL_SITE_OVERWRITE_ON) {
|
305 |
$retArr['dup-wp-config-arc__[HASH].txt'] = $abs_path.'/dup-wp-config-arc__'.DUPLICATOR_INSTALLER_HASH_PATTERN.'.txt';
|
13 |
* @copyright (c) 2017, Snapcreek LLC
|
14 |
*
|
15 |
*/
|
|
|
|
|
16 |
|
17 |
class DUP_Server
|
18 |
{
|
19 |
+
|
20 |
const LockFileName = 'lockfile.txt';
|
21 |
|
22 |
// Possibly use in the future if we want to prevent double building
|
33 |
// Possibly use in the future if we want to prevent double building
|
34 |
public static function setEngineLock($shouldLock)
|
35 |
{
|
36 |
+
$success = false;
|
37 |
+
$locking_file = @fopen(self::LockFileName, 'c+');
|
38 |
if ($locking_file != false) {
|
39 |
if ($shouldLock) {
|
40 |
$success = @flock($locking_file, LOCK_EX | LOCK_NB);
|
47 |
return $success;
|
48 |
}
|
49 |
|
50 |
+
public static function mysqlEscapeIsOk()
|
51 |
+
{
|
52 |
+
$escape_test_string = chr(0).chr(26)."\r\n'\"\\";
|
53 |
+
$escape_expected_result = "\"\\0\Z\\r\\n\\'\\\"\\\\\"";
|
54 |
+
$escape_actual_result = DUP_DB::escValueToQueryString($escape_test_string);
|
55 |
+
$result = $escape_expected_result === $escape_actual_result;
|
56 |
+
|
57 |
+
if (!$result) {
|
58 |
+
$msg = "mysqli_real_escape_string test results\n".
|
59 |
+
"Expected escape result: ".$escape_expected_result."\n".
|
60 |
+
"Actual escape result: ".$escape_actual_result;
|
61 |
+
DUP_Log::trace($msg);
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
return $result;
|
66 |
+
}
|
67 |
+
|
68 |
/**
|
69 |
* Gets the system requirements which must pass to build a package
|
70 |
*
|
79 |
$dup_tests['PHP']['SAFE_MODE'] = $safe_ini != 'on' || $safe_ini != 'yes' || $safe_ini != 'true' || ini_get("safe_mode") != 1 ? 'Pass' : 'Fail';
|
80 |
self::logRequirementFail($dup_tests['PHP']['SAFE_MODE'], 'SAFE_MODE is on.');
|
81 |
|
82 |
+
$dup_tests['PHP']['VERSION'] = DUP_Util::$on_php_529_plus ? 'Pass' : 'Fail';
|
83 |
+
$phpversion = phpversion();
|
84 |
self::logRequirementFail($dup_tests['PHP']['VERSION'], 'PHP version('.$phpversion.') is lower than 5.2.9');
|
85 |
|
86 |
if (DUP_Settings::Get('archive_build_mode') == DUP_Archive_Build_Mode::ZipArchive) {
|
88 |
self::logRequirementFail($dup_tests['PHP']['ZIP'], 'ZipArchive class doesn\'t exist.');
|
89 |
}
|
90 |
|
91 |
+
$dup_tests['PHP']['FUNC_1'] = function_exists("file_get_contents") ? 'Pass' : 'Fail';
|
92 |
self::logRequirementFail($dup_tests['PHP']['FUNC_1'], 'file_get_contents function doesn\'t exist.');
|
93 |
|
94 |
+
$dup_tests['PHP']['FUNC_2'] = function_exists("file_put_contents") ? 'Pass' : 'Fail';
|
95 |
self::logRequirementFail($dup_tests['PHP']['FUNC_2'], 'file_put_contents function doesn\'t exist.');
|
96 |
|
97 |
+
$dup_tests['PHP']['FUNC_3'] = function_exists("mb_strlen") ? 'Pass' : 'Fail';
|
98 |
self::logRequirementFail($dup_tests['PHP']['FUNC_3'], 'mb_strlen function doesn\'t exist.');
|
99 |
|
100 |
+
$dup_tests['PHP']['ALL'] = !in_array('Fail', $dup_tests['PHP']) ? 'Pass' : 'Fail';
|
101 |
|
102 |
//REQUIRED PATHS
|
103 |
+
$abs_path = duplicator_get_abs_path();
|
104 |
$handle_test = @opendir($abs_path);
|
105 |
$dup_tests['IO']['WPROOT'] = is_writeable($abs_path) && $handle_test ? 'Pass' : 'Warn';
|
106 |
@closedir($handle_test);
|
107 |
self::logRequirementFail($dup_tests['IO']['WPROOT'], $abs_path.' (abs path) can\'t be opened.');
|
108 |
|
109 |
+
$dup_tests['IO']['SSDIR'] = is_writeable(DUP_Settings::getSsdirPath()) ? 'Pass' : 'Fail';
|
110 |
+
self::logRequirementFail($dup_tests['IO']['SSDIR'], DUP_Settings::getSsdirPath().' (DUPLICATOR_SSDIR_PATH) can\'t be writeable.');
|
111 |
|
112 |
+
$dup_tests['IO']['SSTMP'] = is_writeable(DUP_Settings::getSsdirTmpPath()) ? 'Pass' : 'Fail';
|
113 |
+
self::logRequirementFail($dup_tests['IO']['SSTMP'], DUP_Settings::getSsdirTmpPath().' (DUPLICATOR_SSDIR_PATH_TMP) can\'t be writeable.');
|
114 |
|
115 |
+
$dup_tests['IO']['ALL'] = !in_array('Fail', $dup_tests['IO']) ? 'Pass' : 'Fail';
|
116 |
|
117 |
//SERVER SUPPORT
|
118 |
+
$dup_tests['SRV']['MYSQLi'] = function_exists('mysqli_connect') ? 'Pass' : 'Fail';
|
119 |
self::logRequirementFail($dup_tests['SRV']['MYSQLi'], 'mysqli_connect function doesn\'t exist.');
|
120 |
|
121 |
+
//mysqli_real_escape_string test
|
122 |
+
$dup_tests['SRV']['MYSQL_ESC'] = self::mysqlEscapeIsOk() ? 'Pass' : 'Fail';
|
123 |
+
self::logRequirementFail($dup_tests['SRV']['MYSQL_ESC'], "The function mysqli_real_escape_string is not escaping strings as expected.");
|
124 |
+
|
125 |
+
$db_version = DUP_DB::getVersion();
|
126 |
$dup_tests['SRV']['MYSQL_VER'] = version_compare($db_version, '5.0', '>=') ? 'Pass' : 'Fail';
|
127 |
self::logRequirementFail($dup_tests['SRV']['MYSQL_VER'], 'MySQL version '.$db_version.' is lower than 5.0.');
|
128 |
|
129 |
+
$dup_tests['SRV']['ALL'] = !in_array('Fail', $dup_tests['SRV']) ? 'Pass' : 'Fail';
|
130 |
|
131 |
//RESERVED FILES
|
132 |
$dup_tests['RES']['INSTALL'] = !(self::hasInstallerFiles()) ? 'Pass' : 'Fail';
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
+
* Logs requirement fail status informative message
|
143 |
+
*
|
144 |
+
* @param string $testStatus Either it is Pass or Fail
|
145 |
+
* @param string $errorMessage Error message which should be logged
|
146 |
+
* @return void
|
147 |
+
*/
|
148 |
+
private static function logRequirementFail($testStatus, $errorMessage)
|
149 |
+
{
|
150 |
+
if (empty($testStatus)) {
|
151 |
throw new Exception('Exception: Empty $testStatus [File: '.__FILE__.', Ln: '.__LINE__);
|
152 |
+
}
|
153 |
|
154 |
+
if (empty($errorMessage)) {
|
155 |
throw new Exception('Exception: Empty $errorMessage [File: '.__FILE__.', Ln: '.__LINE__);
|
156 |
+
}
|
157 |
|
158 |
+
$validTestStatuses = array('Pass', 'Fail', 'Warn');
|
159 |
|
160 |
+
if (!in_array($testStatus, $validTestStatuses)) {
|
161 |
+
throw new Exception('Exception: Invalid $testStatus value: '.$testStatus.' [File: '.__FILE__.', Ln: '.__LINE__);
|
162 |
+
}
|
163 |
|
164 |
+
if ('Fail' == $testStatus) {
|
165 |
DUP_LOG::trace($errorMessage);
|
166 |
+
}
|
167 |
+
}
|
168 |
|
169 |
/**
|
170 |
* Gets the system checks which are not required
|
190 |
$php_test1 = empty($php_test1) ? true : false;
|
191 |
self::logCheckFalse($php_test1, 'open_basedir is enabled.');
|
192 |
|
193 |
+
$max_execution_time = ini_get("max_execution_time");
|
194 |
+
$php_test2 = ($max_execution_time > DUPLICATOR_SCAN_TIMEOUT) || (strcmp($max_execution_time, 'Off') == 0 || $max_execution_time == 0) ? true : false;
|
195 |
+
if (strcmp($max_execution_time, 'Off') == 0) {
|
196 |
+
$max_execution_time_error_message = '$max_execution_time should not be'.$max_execution_time;
|
197 |
+
} else {
|
198 |
+
$max_execution_time_error_message = '$max_execution_time ('.$max_execution_time.') should not be lower than the DUPLICATOR_SCAN_TIMEOUT'.DUPLICATOR_SCAN_TIMEOUT;
|
199 |
+
}
|
200 |
+
self::logCheckFalse($php_test2, $max_execution_time_error_message);
|
201 |
|
202 |
+
$php_test3 = function_exists('mysqli_connect');
|
203 |
self::logCheckFalse($php_test3, 'mysqli_connect function doesn\'t exist.');
|
204 |
|
205 |
+
$php_test4 = DUP_Util::$on_php_53_plus ? true : false;
|
206 |
self::logCheckFalse($php_test4, 'PHP Version is lower than 5.3.');
|
207 |
|
208 |
$checks['SRV']['PHP']['websrv'] = $php_test0;
|
218 |
self::logCheckFalse($wp_test1, 'WP version ('.$wp_version.') is lower than the DUPLICATOR_SCAN_MIN_WP ('.DUPLICATOR_SCAN_MIN_WP.').');
|
219 |
|
220 |
//Core Files
|
221 |
+
$files = array();
|
222 |
+
$proper_wp_config_file_path = duplicator_get_abs_path().'/wp-config.php';
|
223 |
+
$files['wp-config.php'] = file_exists($proper_wp_config_file_path);
|
224 |
self::logCheckFalse($files['wp-config.php'], 'The wp-config.php file doesn\'t exist on the '.$proper_wp_config_file_path);
|
225 |
|
226 |
/** searching wp-config in working word press is not worthy
|
231 |
//Core dir and files logic
|
232 |
if (isset($_POST['file_notice']) && isset($_POST['dir_notice'])) {
|
233 |
//means if there are core directories excluded or core files excluded return false
|
234 |
+
if ((bool) $_POST['file_notice'] || (bool) $_POST['dir_notice'])
|
235 |
+
$wp_test2 = false;
|
236 |
+
else
|
237 |
+
$wp_test2 = true;
|
238 |
+
} else {
|
239 |
$wp_test2 = $files['wp-config.php'];
|
240 |
}
|
241 |
|
260 |
}
|
261 |
|
262 |
/**
|
263 |
+
* Logs checks false informative message
|
264 |
+
*
|
265 |
+
* @param boolean $check Either it is true or false
|
266 |
+
* @param string $errorMessage Error message which should be logged when check is false
|
267 |
+
* @return void
|
268 |
+
*/
|
269 |
+
private static function logCheckFalse($check, $errorMessage)
|
270 |
+
{
|
271 |
+
if (!is_bool($check)) {
|
272 |
+
throw new Exception('Exception: Not boolean $check [File: '.__FILE__.', Ln: '.__LINE__);
|
273 |
+
}
|
274 |
|
275 |
+
if (empty($errorMessage)) {
|
276 |
+
throw new Exception('Exception: Empty $errorMessage [File: '.__FILE__.', Ln: '.__LINE__);
|
277 |
+
}
|
278 |
|
279 |
+
if (false === $check) {
|
280 |
+
DUP_LOG::trace($errorMessage);
|
281 |
+
}
|
282 |
}
|
283 |
|
284 |
/**
|
295 |
if (!empty($glob_files)) {
|
296 |
return true;
|
297 |
}
|
298 |
+
} elseif (file_exists($path))
|
299 |
+
return true;
|
300 |
}
|
301 |
return false;
|
302 |
}
|
316 |
public static function getInstallerFiles()
|
317 |
{
|
318 |
// alphanumeric 7 time, then -(dash), then 8 digits
|
319 |
+
$abs_path = duplicator_get_abs_path();
|
320 |
$four_digit_glob_pattern = '[0-9][0-9][0-9][0-9]';
|
321 |
+
$retArr = array(
|
322 |
basename(DUPLICATOR_INSTALLER_DIRECTORY).' '.esc_html__('(directory)', 'duplicator') => DUPLICATOR_INSTALLER_DIRECTORY,
|
323 |
+
DUPLICATOR_INSTALL_PHP => $abs_path.'/'.DUPLICATOR_INSTALL_PHP,
|
324 |
+
'[HASH]'.'_'.DUPLICATOR_INSTALL_PHP => $abs_path.'/*_*'.$four_digit_glob_pattern.'_'.DUPLICATOR_INSTALL_PHP,
|
325 |
+
DUPLICATOR_INSTALL_BAK => $abs_path.'/'.DUPLICATOR_INSTALL_BAK,
|
326 |
+
'[HASH]'.'_'.DUPLICATOR_INSTALL_BAK => $abs_path.'/*_*'.$four_digit_glob_pattern.'_'.DUPLICATOR_INSTALL_BAK,
|
327 |
+
'[HASH]_archive.zip|daf' => $abs_path.'/*_*'.$four_digit_glob_pattern.'_archive.[zd][ia][pf]',
|
328 |
+
'dup-installer-bootlog__[HASH].txt' => $abs_path.'/dup-installer-bootlog__'.DUPLICATOR_INSTALLER_HASH_PATTERN.'.txt',
|
329 |
);
|
330 |
if (DUPLICATOR_INSTALL_SITE_OVERWRITE_ON) {
|
331 |
$retArr['dup-wp-config-arc__[HASH].txt'] = $abs_path.'/dup-wp-config-arc__'.DUPLICATOR_INSTALLER_HASH_PATTERN.'.txt';
|
classes/class.settings.php
CHANGED
@@ -21,9 +21,14 @@ class DUP_Settings
|
|
21 |
const OPT_SETTINGS = 'duplicator_settings';
|
22 |
const INSTALLER_NAME_MODE_WITH_HASH = 'withhash';
|
23 |
const INSTALLER_NAME_MODE_SIMPLE = 'simple';
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
/**
|
29 |
* Class used to manage all the settings for the plugin
|
@@ -32,7 +37,7 @@ class DUP_Settings
|
|
32 |
{
|
33 |
self::$Data = get_option(self::OPT_SETTINGS);
|
34 |
//when the plugin updated, this will be true
|
35 |
-
if (empty(self::$Data) || empty(self::$Data['version']) ||
|
36 |
self::SetDefaults();
|
37 |
}
|
38 |
}
|
@@ -71,6 +76,55 @@ class DUP_Settings
|
|
71 |
}
|
72 |
}
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
/**
|
75 |
* Saves all the setting values to the database
|
76 |
* @return True if option value has changed, false if not or if update failed.
|
@@ -114,7 +168,7 @@ class DUP_Settings
|
|
114 |
public static function GetAllDefaults()
|
115 |
{
|
116 |
$default = array();
|
117 |
-
$default['version'] =
|
118 |
|
119 |
//Flag used to remove the wp_options value duplicator_settings which are all the settings in this class
|
120 |
$default['uninstall_settings'] = isset(self::$Data['uninstall_settings']) ? self::$Data['uninstall_settings'] : true;
|
@@ -135,6 +189,8 @@ class DUP_Settings
|
|
135 |
$default['package_zip_flush'] = isset(self::$Data['package_zip_flush']) ? self::$Data['package_zip_flush'] : false;
|
136 |
//Optional mysqldump search path
|
137 |
$default['installer_name_mode'] = isset(self::$Data['installer_name_mode']) ? self::$Data['installer_name_mode'] : self::INSTALLER_NAME_MODE_SIMPLE;
|
|
|
|
|
138 |
|
139 |
//Flag for .htaccess file
|
140 |
$default['storage_htaccess_off'] = isset(self::$Data['storage_htaccess_off']) ? self::$Data['storage_htaccess_off'] : false;
|
@@ -165,4 +221,48 @@ class DUP_Settings
|
|
165 |
}
|
166 |
return $ui_create_frmt;
|
167 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
}
|
21 |
const OPT_SETTINGS = 'duplicator_settings';
|
22 |
const INSTALLER_NAME_MODE_WITH_HASH = 'withhash';
|
23 |
const INSTALLER_NAME_MODE_SIMPLE = 'simple';
|
24 |
+
const STORAGE_POSITION_LECAGY = 'legacy';
|
25 |
+
const STORAGE_POSITION_WP_CONTENT = 'wpcont';
|
26 |
+
const SSDIR_NAME_LEGACY = 'wp-snapshots';
|
27 |
+
const SSDIR_NAME_NEW = 'backups-dup-lite';
|
28 |
|
29 |
+
protected static $Data;
|
30 |
+
protected static $ssDirPath = null;
|
31 |
+
protected static $ssDirUrl = null;
|
32 |
|
33 |
/**
|
34 |
* Class used to manage all the settings for the plugin
|
37 |
{
|
38 |
self::$Data = get_option(self::OPT_SETTINGS);
|
39 |
//when the plugin updated, this will be true
|
40 |
+
if (empty(self::$Data) || empty(self::$Data['version']) || version_compare(DUPLICATOR_VERSION, self::$Data['version'], '>')) {
|
41 |
self::SetDefaults();
|
42 |
}
|
43 |
}
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
public static function setStoragePosition($newPosition)
|
80 |
+
{
|
81 |
+
$legacyPath = self::getSsdirPathLegacy();
|
82 |
+
$wpContPath = self::getSsdirPathWpCont();
|
83 |
+
|
84 |
+
$oldStoragePost = self::Get('storage_position');
|
85 |
+
|
86 |
+
self::resetPositionVars();
|
87 |
+
|
88 |
+
switch ($newPosition) {
|
89 |
+
case self::STORAGE_POSITION_LECAGY:
|
90 |
+
self::$Data['storage_position'] = self::STORAGE_POSITION_LECAGY;
|
91 |
+
if (!DUP_Util::initSnapshotDirectory()) {
|
92 |
+
self::resetPositionVars();
|
93 |
+
self::$Data['storage_position'] = $oldStoragePost;
|
94 |
+
return false;
|
95 |
+
}
|
96 |
+
if (is_dir($wpContPath)) {
|
97 |
+
if (DupLiteSnapLibIOU::moveContentDirToTarget($wpContPath, $legacyPath, true)) {
|
98 |
+
DupLiteSnapLibIOU::rrmdir($wpContPath);
|
99 |
+
}
|
100 |
+
}
|
101 |
+
break;
|
102 |
+
case self::STORAGE_POSITION_WP_CONTENT:
|
103 |
+
self::$Data['storage_position'] = self::STORAGE_POSITION_WP_CONTENT;
|
104 |
+
if (!DUP_Util::initSnapshotDirectory()) {
|
105 |
+
self::resetPositionVars();
|
106 |
+
self::$Data['storage_position'] = $oldStoragePost;
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
if (is_dir($legacyPath)) {
|
110 |
+
if (DupLiteSnapLibIOU::moveContentDirToTarget($legacyPath, $wpContPath, true)) {
|
111 |
+
DupLiteSnapLibIOU::rrmdir($legacyPath);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
break;
|
115 |
+
default:
|
116 |
+
throw new Exception('Unknown storage position');
|
117 |
+
}
|
118 |
+
|
119 |
+
return true;
|
120 |
+
}
|
121 |
+
|
122 |
+
protected static function resetPositionVars()
|
123 |
+
{
|
124 |
+
self::$ssDirPath = null;
|
125 |
+
self::$ssDirUrl = null;
|
126 |
+
}
|
127 |
+
|
128 |
/**
|
129 |
* Saves all the setting values to the database
|
130 |
* @return True if option value has changed, false if not or if update failed.
|
168 |
public static function GetAllDefaults()
|
169 |
{
|
170 |
$default = array();
|
171 |
+
$default['version'] = DUPLICATOR_VERSION;
|
172 |
|
173 |
//Flag used to remove the wp_options value duplicator_settings which are all the settings in this class
|
174 |
$default['uninstall_settings'] = isset(self::$Data['uninstall_settings']) ? self::$Data['uninstall_settings'] : true;
|
189 |
$default['package_zip_flush'] = isset(self::$Data['package_zip_flush']) ? self::$Data['package_zip_flush'] : false;
|
190 |
//Optional mysqldump search path
|
191 |
$default['installer_name_mode'] = isset(self::$Data['installer_name_mode']) ? self::$Data['installer_name_mode'] : self::INSTALLER_NAME_MODE_SIMPLE;
|
192 |
+
// storage position
|
193 |
+
$default['storage_position'] = isset(self::$Data['storage_position']) ? self::$Data['storage_position'] : self::STORAGE_POSITION_WP_CONTENT;
|
194 |
|
195 |
//Flag for .htaccess file
|
196 |
$default['storage_htaccess_off'] = isset(self::$Data['storage_htaccess_off']) ? self::$Data['storage_htaccess_off'] : false;
|
221 |
}
|
222 |
return $ui_create_frmt;
|
223 |
}
|
224 |
+
|
225 |
+
public static function getSsdirPathLegacy()
|
226 |
+
{
|
227 |
+
return DupLiteSnapLibIOU::safePathTrailingslashit(duplicator_get_abs_path()).self::SSDIR_NAME_LEGACY;
|
228 |
+
}
|
229 |
+
|
230 |
+
public static function getSsdirPathWpCont()
|
231 |
+
{
|
232 |
+
return DupLiteSnapLibIOU::safePathTrailingslashit(WP_CONTENT_DIR).self::SSDIR_NAME_NEW;
|
233 |
+
}
|
234 |
+
|
235 |
+
public static function getSsdirPath()
|
236 |
+
{
|
237 |
+
if (is_null(self::$ssDirPath)) {
|
238 |
+
if (self::Get('storage_position') === self::STORAGE_POSITION_LECAGY) {
|
239 |
+
self::$ssDirPath = self::getSsdirPathLegacy();
|
240 |
+
} else {
|
241 |
+
self::$ssDirPath = self::getSsdirPathWpCont();
|
242 |
+
}
|
243 |
+
}
|
244 |
+
return self::$ssDirPath;
|
245 |
+
}
|
246 |
+
|
247 |
+
public static function getSsdirUrl()
|
248 |
+
{
|
249 |
+
if (is_null(self::$ssDirUrl)) {
|
250 |
+
if (self::Get('storage_position') === self::STORAGE_POSITION_LECAGY) {
|
251 |
+
self::$ssDirUrl = DupLiteSnapLibIOU::trailingslashit(DUPLICATOR_SITE_URL).self::SSDIR_NAME_LEGACY;
|
252 |
+
} else {
|
253 |
+
self::$ssDirUrl = DupLiteSnapLibIOU::trailingslashit(WP_CONTENT_URL).self::SSDIR_NAME_NEW;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
return self::$ssDirUrl;
|
257 |
+
}
|
258 |
+
|
259 |
+
public static function getSsdirTmpPath()
|
260 |
+
{
|
261 |
+
return self::getSsdirPath().'/tmp';
|
262 |
+
}
|
263 |
+
|
264 |
+
public static function getSsdirInstallerPath()
|
265 |
+
{
|
266 |
+
return self::getSsdirPath().'/installer';
|
267 |
+
}
|
268 |
}
|
classes/package/class.pack.archive.php
CHANGED
@@ -113,7 +113,7 @@ class DUP_Archive
|
|
113 |
if ($this->Package->BuildProgress === null) {
|
114 |
// Zip path
|
115 |
DUP_LOG::Trace("Completed Zip");
|
116 |
-
$storePath = "
|
117 |
$this->Size = @filesize($storePath);
|
118 |
$this->Package->setStatus(DUP_PackageStatus::ARCDONE);
|
119 |
} else if ($completed) {
|
@@ -123,7 +123,7 @@ class DUP_Archive
|
|
123 |
DUP_LOG::Trace("Error building DupArchive");
|
124 |
$this->Package->setStatus(DUP_PackageStatus::ERROR);
|
125 |
} else {
|
126 |
-
$filepath =
|
127 |
$this->Size = @filesize($filepath);
|
128 |
$this->Package->setStatus(DUP_PackageStatus::ARCDONE);
|
129 |
DUP_LOG::Trace("Done building archive");
|
@@ -308,7 +308,8 @@ class DUP_Archive
|
|
308 |
$wp_content_upload = "{$wp_content}/{$upload_dir}";
|
309 |
$this->FilterInfo->Dirs->Core = array(
|
310 |
//WP-ROOT
|
311 |
-
|
|
|
312 |
$wp_root.'/.opcache',
|
313 |
//WP-CONTENT
|
314 |
$wp_content.'/backups-dup-pro',
|
@@ -762,6 +763,11 @@ class DUP_Archive
|
|
762 |
return $this->wpContentDirNormalizePath;
|
763 |
}
|
764 |
|
|
|
|
|
|
|
|
|
|
|
765 |
public function getLocalDirPath($dir, $basePath = '')
|
766 |
{
|
767 |
$isOuterWPContentDir = $this->isOuterWPContentDir();
|
113 |
if ($this->Package->BuildProgress === null) {
|
114 |
// Zip path
|
115 |
DUP_LOG::Trace("Completed Zip");
|
116 |
+
$storePath = DUP_Settings::getSsdirTmpPath()."/{$this->File}";
|
117 |
$this->Size = @filesize($storePath);
|
118 |
$this->Package->setStatus(DUP_PackageStatus::ARCDONE);
|
119 |
} else if ($completed) {
|
123 |
DUP_LOG::Trace("Error building DupArchive");
|
124 |
$this->Package->setStatus(DUP_PackageStatus::ERROR);
|
125 |
} else {
|
126 |
+
$filepath = DUP_Settings::getSsdirTmpPath()."/{$this->File}";
|
127 |
$this->Size = @filesize($filepath);
|
128 |
$this->Package->setStatus(DUP_PackageStatus::ARCDONE);
|
129 |
DUP_LOG::Trace("Done building archive");
|
308 |
$wp_content_upload = "{$wp_content}/{$upload_dir}";
|
309 |
$this->FilterInfo->Dirs->Core = array(
|
310 |
//WP-ROOT
|
311 |
+
DUP_Settings::getSsdirPathLegacy(),
|
312 |
+
DUP_Settings::getSsdirPathWpCont(),
|
313 |
$wp_root.'/.opcache',
|
314 |
//WP-CONTENT
|
315 |
$wp_content.'/backups-dup-pro',
|
763 |
return $this->wpContentDirNormalizePath;
|
764 |
}
|
765 |
|
766 |
+
public function getUrl()
|
767 |
+
{
|
768 |
+
return DUP_Settings::getSsdirUrl()."/".$this->File;
|
769 |
+
}
|
770 |
+
|
771 |
public function getLocalDirPath($dir, $basePath = '')
|
772 |
{
|
773 |
$isOuterWPContentDir = $this->isOuterWPContentDir();
|
classes/package/class.pack.archive.zip.php
CHANGED
@@ -32,8 +32,8 @@ class DUP_Zip extends DUP_Archive
|
|
32 |
$package_zip_flush = DUP_Settings::Get('package_zip_flush');
|
33 |
|
34 |
self::$compressDir = rtrim(wp_normalize_path(DUP_Util::safePath($archive->PackDir)), '/');
|
35 |
-
self::$sqlPath =
|
36 |
-
self::$zipPath =
|
37 |
self::$zipArchive = new ZipArchive();
|
38 |
self::$networkFlush = empty($package_zip_flush) ? false : $package_zip_flush;
|
39 |
|
@@ -46,7 +46,7 @@ class DUP_Zip extends DUP_Archive
|
|
46 |
$lastDirSuccess = self::$compressDir;
|
47 |
|
48 |
//LOAD SCAN REPORT
|
49 |
-
$json = file_get_contents(
|
50 |
self::$scanReport = json_decode($json);
|
51 |
|
52 |
DUP_Log::Info("\n********************************************************************************");
|
32 |
$package_zip_flush = DUP_Settings::Get('package_zip_flush');
|
33 |
|
34 |
self::$compressDir = rtrim(wp_normalize_path(DUP_Util::safePath($archive->PackDir)), '/');
|
35 |
+
self::$sqlPath = DUP_Settings::getSsdirTmpPath()."/{$archive->Package->Database->File}";
|
36 |
+
self::$zipPath = DUP_Settings::getSsdirTmpPath()."/{$archive->File}";
|
37 |
self::$zipArchive = new ZipArchive();
|
38 |
self::$networkFlush = empty($package_zip_flush) ? false : $package_zip_flush;
|
39 |
|
46 |
$lastDirSuccess = self::$compressDir;
|
47 |
|
48 |
//LOAD SCAN REPORT
|
49 |
+
$json = file_get_contents(DUP_Settings::getSsdirTmpPath()."/{$archive->Package->NameHash}_scan.json");
|
50 |
self::$scanReport = json_decode($json);
|
51 |
|
52 |
DUP_Log::Info("\n********************************************************************************");
|
classes/package/class.pack.database.php
CHANGED
@@ -127,7 +127,7 @@ class DUP_Database
|
|
127 |
//PROTECTED
|
128 |
protected $Package;
|
129 |
//PRIVATE
|
130 |
-
private $
|
131 |
private $EOFMarker;
|
132 |
private $networkFlush;
|
133 |
|
@@ -158,9 +158,9 @@ class DUP_Database
|
|
158 |
$this->Package = $package;
|
159 |
do_action('duplicator_lite_build_database_before_start', $package);
|
160 |
|
161 |
-
$time_start
|
162 |
$this->Package->setStatus(DUP_PackageStatus::DBSTART);
|
163 |
-
$this->
|
164 |
|
165 |
$package_mysqldump = DUP_Settings::Get('package_mysqldump');
|
166 |
$package_phpdump_qrylimit = DUP_Settings::Get('package_phpdump_qrylimit');
|
@@ -196,7 +196,7 @@ class DUP_Database
|
|
196 |
$time_sum = DUP_Util::elapsedTime($time_end, $time_start);
|
197 |
|
198 |
//File below 10k considered incomplete
|
199 |
-
$sql_file_size = filesize($this->
|
200 |
DUP_Log::Info("SQL FILE SIZE: ".DUP_Util::byteSize($sql_file_size)." ({$sql_file_size})");
|
201 |
|
202 |
if ($sql_file_size < 1350) {
|
@@ -204,7 +204,7 @@ class DUP_Database
|
|
204 |
$package->BuildProgress->set_failed($error_message);
|
205 |
$package->Status = DUP_PackageStatus::ERROR;
|
206 |
$package->Update();
|
207 |
-
DUP_Log::Error($error_message, "File does not look complete. Check permission on file and parent directory at [{$this->
|
208 |
do_action('duplicator_lite_build_database_fail', $package);
|
209 |
} else {
|
210 |
do_action('duplicator_lite_build_database_completed', $package);
|
@@ -213,7 +213,7 @@ class DUP_Database
|
|
213 |
DUP_Log::Info("SQL FILE TIME: ".date("Y-m-d H:i:s"));
|
214 |
DUP_Log::Info("SQL RUNTIME: {$time_sum}");
|
215 |
|
216 |
-
$this->Size = @filesize($this->
|
217 |
|
218 |
$this->Package->setStatus(DUP_PackageStatus::DBDONE);
|
219 |
}
|
@@ -430,7 +430,7 @@ class DUP_Database
|
|
430 |
$isPopenEnabled = DUP_Shell_U::isPopenEnabled();
|
431 |
|
432 |
if (!$isPopenEnabled) {
|
433 |
-
$cmd .= ' -r '.escapeshellarg($this->
|
434 |
}
|
435 |
|
436 |
$cmd .= ' '.escapeshellarg(DB_NAME);
|
@@ -462,7 +462,7 @@ class DUP_Database
|
|
462 |
$handle = popen($cmd, "r");
|
463 |
if ($handle) {
|
464 |
$sql_header = "/* DUPLICATOR-LITE (MYSQL-DUMP BUILD MODE) MYSQL SCRIPT CREATED ON : ".@date("Y-m-d H:i:s")." */\n\n";
|
465 |
-
file_put_contents($this->
|
466 |
while (!feof($handle)) {
|
467 |
$line = fgets($handle); //get ony one line
|
468 |
if ($line) {
|
@@ -496,7 +496,7 @@ class DUP_Database
|
|
496 |
}
|
497 |
}
|
498 |
|
499 |
-
file_put_contents($this->
|
500 |
$output = "Ran from {$exePath}";
|
501 |
}
|
502 |
}
|
@@ -532,7 +532,7 @@ class DUP_Database
|
|
532 |
|
533 |
$sql_footer = "\n\n/* Duplicator WordPress Timestamp: ".date("Y-m-d H:i:s")."*/\n";
|
534 |
$sql_footer .= "/* ".DUPLICATOR_DB_EOF_MARKER." */\n";
|
535 |
-
file_put_contents($this->
|
536 |
if ($mysqlResult !== 0) {
|
537 |
/**
|
538 |
* -1 error command shell
|
@@ -543,7 +543,7 @@ class DUP_Database
|
|
543 |
*/
|
544 |
DUP_Log::Info('MYSQL DUMP ERROR '.print_r($mysqlResult, true));
|
545 |
DUP_Log::error(__('Shell mysql dump error. Change Mysql dump engine in PHP mode', 'duplicator'),
|
546 |
-
|
547 |
return false;
|
548 |
}
|
549 |
|
@@ -560,8 +560,8 @@ class DUP_Database
|
|
560 |
global $wpdb;
|
561 |
|
562 |
$wpdb->query("SET session wait_timeout = ".DUPLICATOR_DB_MAX_TIME);
|
563 |
-
if (($handle = fopen($this->
|
564 |
-
DUP_Log::error('[PHP DUMP] ERROR Can\'t open sbStorePath "'.$this->
|
565 |
}
|
566 |
$tables = $wpdb->get_col("SHOW FULL TABLES WHERE Table_Type != 'VIEW'");
|
567 |
|
@@ -729,4 +729,9 @@ class DUP_Database
|
|
729 |
$table_prefix = (is_multisite() && !defined('MULTISITE')) ? $wpdb->base_prefix : $wpdb->get_blog_prefix(0);
|
730 |
return $table_prefix;
|
731 |
}
|
|
|
|
|
|
|
|
|
|
|
732 |
}
|
127 |
//PROTECTED
|
128 |
protected $Package;
|
129 |
//PRIVATE
|
130 |
+
private $tempDbPath;
|
131 |
private $EOFMarker;
|
132 |
private $networkFlush;
|
133 |
|
158 |
$this->Package = $package;
|
159 |
do_action('duplicator_lite_build_database_before_start', $package);
|
160 |
|
161 |
+
$time_start = DUP_Util::getMicrotime();
|
162 |
$this->Package->setStatus(DUP_PackageStatus::DBSTART);
|
163 |
+
$this->tempDbPath = DUP_Settings::getSsdirTmpPath()."/{$this->File}";
|
164 |
|
165 |
$package_mysqldump = DUP_Settings::Get('package_mysqldump');
|
166 |
$package_phpdump_qrylimit = DUP_Settings::Get('package_phpdump_qrylimit');
|
196 |
$time_sum = DUP_Util::elapsedTime($time_end, $time_start);
|
197 |
|
198 |
//File below 10k considered incomplete
|
199 |
+
$sql_file_size = filesize($this->tempDbPath);
|
200 |
DUP_Log::Info("SQL FILE SIZE: ".DUP_Util::byteSize($sql_file_size)." ({$sql_file_size})");
|
201 |
|
202 |
if ($sql_file_size < 1350) {
|
204 |
$package->BuildProgress->set_failed($error_message);
|
205 |
$package->Status = DUP_PackageStatus::ERROR;
|
206 |
$package->Update();
|
207 |
+
DUP_Log::Error($error_message, "File does not look complete. Check permission on file and parent directory at [{$this->tempDbPath}]", $errorBehavior);
|
208 |
do_action('duplicator_lite_build_database_fail', $package);
|
209 |
} else {
|
210 |
do_action('duplicator_lite_build_database_completed', $package);
|
213 |
DUP_Log::Info("SQL FILE TIME: ".date("Y-m-d H:i:s"));
|
214 |
DUP_Log::Info("SQL RUNTIME: {$time_sum}");
|
215 |
|
216 |
+
$this->Size = @filesize($this->tempDbPath);
|
217 |
|
218 |
$this->Package->setStatus(DUP_PackageStatus::DBDONE);
|
219 |
}
|
430 |
$isPopenEnabled = DUP_Shell_U::isPopenEnabled();
|
431 |
|
432 |
if (!$isPopenEnabled) {
|
433 |
+
$cmd .= ' -r '.escapeshellarg($this->tempDbPath);
|
434 |
}
|
435 |
|
436 |
$cmd .= ' '.escapeshellarg(DB_NAME);
|
462 |
$handle = popen($cmd, "r");
|
463 |
if ($handle) {
|
464 |
$sql_header = "/* DUPLICATOR-LITE (MYSQL-DUMP BUILD MODE) MYSQL SCRIPT CREATED ON : ".@date("Y-m-d H:i:s")." */\n\n";
|
465 |
+
file_put_contents($this->tempDbPath, $sql_header, FILE_APPEND);
|
466 |
while (!feof($handle)) {
|
467 |
$line = fgets($handle); //get ony one line
|
468 |
if ($line) {
|
496 |
}
|
497 |
}
|
498 |
|
499 |
+
file_put_contents($this->tempDbPath, $line, FILE_APPEND);
|
500 |
$output = "Ran from {$exePath}";
|
501 |
}
|
502 |
}
|
532 |
|
533 |
$sql_footer = "\n\n/* Duplicator WordPress Timestamp: ".date("Y-m-d H:i:s")."*/\n";
|
534 |
$sql_footer .= "/* ".DUPLICATOR_DB_EOF_MARKER." */\n";
|
535 |
+
file_put_contents($this->tempDbPath, $sql_footer, FILE_APPEND);
|
536 |
if ($mysqlResult !== 0) {
|
537 |
/**
|
538 |
* -1 error command shell
|
543 |
*/
|
544 |
DUP_Log::Info('MYSQL DUMP ERROR '.print_r($mysqlResult, true));
|
545 |
DUP_Log::error(__('Shell mysql dump error. Change Mysql dump engine in PHP mode', 'duplicator'),
|
546 |
+
implode("\n", DupLiteSnapLibIOU::getLastLinesOfFile($this->tempDbPath, DUPLICATOR_DB_MYSQLDUMP_ERROR_CONTAINING_LINE_COUNT)), Dup_ErrorBehavior::ThrowException);
|
547 |
return false;
|
548 |
}
|
549 |
|
560 |
global $wpdb;
|
561 |
|
562 |
$wpdb->query("SET session wait_timeout = ".DUPLICATOR_DB_MAX_TIME);
|
563 |
+
if (($handle = fopen($this->tempDbPath, 'w+')) == false) {
|
564 |
+
DUP_Log::error('[PHP DUMP] ERROR Can\'t open sbStorePath "'.$this->tempDbPath.'"', Dup_ErrorBehavior::ThrowException);
|
565 |
}
|
566 |
$tables = $wpdb->get_col("SHOW FULL TABLES WHERE Table_Type != 'VIEW'");
|
567 |
|
729 |
$table_prefix = (is_multisite() && !defined('MULTISITE')) ? $wpdb->base_prefix : $wpdb->get_blog_prefix(0);
|
730 |
return $table_prefix;
|
731 |
}
|
732 |
+
|
733 |
+
public function getUrl()
|
734 |
+
{
|
735 |
+
return DUP_Settings::getSsdirUrl()."/".$this->File;
|
736 |
+
}
|
737 |
}
|
classes/package/class.pack.installer.php
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
3 |
// Exit if accessed directly
|
4 |
/* @var $global DUP_Global_Entity */
|
5 |
-
if (!defined('DUPLICATOR_VERSION')) exit;
|
6 |
|
7 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/class.archive.config.php');
|
8 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/utilities/class.u.zip.php');
|
@@ -11,8 +10,9 @@ require_once(DUPLICATOR_PLUGIN_PATH.'/classes/class.password.php');
|
|
11 |
|
12 |
class DUP_Installer
|
13 |
{
|
14 |
-
|
15 |
-
|
|
|
16 |
//PUBLIC
|
17 |
public $File;
|
18 |
public $Size = 0;
|
@@ -52,7 +52,7 @@ class DUP_Installer
|
|
52 |
if ($success) {
|
53 |
$package->BuildProgress->installer_built = true;
|
54 |
} else {
|
55 |
-
$error_message
|
56 |
$package->BuildProgress->set_failed($error_message);
|
57 |
$package->Status = DUP_PackageStatus::ERROR;
|
58 |
$package->Update();
|
@@ -76,9 +76,9 @@ class DUP_Installer
|
|
76 |
|
77 |
private function create_enhanced_installer()
|
78 |
{
|
79 |
-
$success
|
80 |
-
$archive_filepath =
|
81 |
-
$installer_filepath = apply_filters('duplicator_installer_file_path',
|
82 |
$template_filepath = DUPLICATOR_PLUGIN_PATH.'/installer/installer.tpl';
|
83 |
$mini_expander_filepath = DUPLICATOR_PLUGIN_PATH.'/lib/dup_archive/classes/class.duparchive.mini.expander.php';
|
84 |
|
@@ -96,11 +96,11 @@ class DUP_Installer
|
|
96 |
$mini_expander_string = '';
|
97 |
}
|
98 |
|
99 |
-
$search_array
|
100 |
-
$package_hash
|
101 |
-
|
102 |
-
$replace_array
|
103 |
-
$installer_contents
|
104 |
|
105 |
if (@file_put_contents($installer_filepath, $installer_contents) === false) {
|
106 |
DUP_Log::error(esc_html__('Error writing installer contents', 'duplicator'), esc_html__("Couldn't write to $installer_filepath", 'duplicator'));
|
@@ -108,7 +108,7 @@ class DUP_Installer
|
|
108 |
}
|
109 |
|
110 |
if ($success) {
|
111 |
-
$storePath = "
|
112 |
$this->Size = @filesize($storePath);
|
113 |
}
|
114 |
|
@@ -122,14 +122,14 @@ class DUP_Installer
|
|
122 |
global $wpdb;
|
123 |
|
124 |
$success = true;
|
125 |
-
$archive_config_filepath =
|
126 |
$ac = new DUP_Archive_Config();
|
127 |
$extension = strtolower($this->Package->Archive->Format);
|
128 |
|
129 |
$hasher = new DUP_PasswordHash(8, FALSE);
|
130 |
$pass_hash = $hasher->HashPassword($this->Package->Installer->OptsSecurePass);
|
131 |
|
132 |
-
|
133 |
|
134 |
//READ-ONLY: COMPARE VALUES
|
135 |
$ac->created = $this->Package->Created;
|
@@ -142,22 +142,22 @@ class DUP_Installer
|
|
142 |
|
143 |
//READ-ONLY: GENERAL
|
144 |
// $ac->installer_base_name = $global->installer_base_name;
|
145 |
-
$ac->installer_base_name
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
$ac->blogname
|
152 |
-
|
153 |
-
$abs_path
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
$ac->secure_on = $this->Package->Installer->OptsSecureOn;
|
162 |
$ac->secure_pass = $pass_hash;
|
163 |
$ac->skipscan = false;
|
@@ -168,11 +168,11 @@ class DUP_Installer
|
|
168 |
$ac->wp_tableprefix = $wpdb->base_prefix;
|
169 |
|
170 |
$ac->mu_mode = DUP_MU::getMode();
|
171 |
-
$ac->is_outer_root_wp_config_file = (!file_exists($abs_path
|
172 |
$ac->is_outer_root_wp_content_dir = $this->Package->Archive->isOuterWPContentDir();
|
173 |
|
174 |
-
|
175 |
-
|
176 |
|
177 |
if (file_put_contents($archive_config_filepath, $json) === false) {
|
178 |
DUP_Log::error("Error writing archive config", "Couldn't write archive config at $archive_config_filepath", Dup_ErrorBehavior::LogOnly);
|
@@ -188,11 +188,11 @@ class DUP_Installer
|
|
188 |
private function add_extra_files($package)
|
189 |
{
|
190 |
$success = false;
|
191 |
-
$installer_filepath = apply_filters('duplicator_installer_file_path',
|
192 |
-
$scan_filepath =
|
193 |
-
$sql_filepath =
|
194 |
-
$archive_filepath =
|
195 |
-
$archive_config_filepath =
|
196 |
|
197 |
DUP_Log::Info("add_extra_files1");
|
198 |
|
@@ -251,7 +251,7 @@ class DUP_Installer
|
|
251 |
try {
|
252 |
DUP_Log::Info("add_extra_files_using_da1");
|
253 |
$htaccess_filepath = $this->getHtaccessFilePath();
|
254 |
-
$webconf_filepath = duplicator_get_abs_path()
|
255 |
|
256 |
$logger = new DUP_DupArchive_Logger();
|
257 |
|
@@ -266,7 +266,8 @@ class DUP_Installer
|
|
266 |
try {
|
267 |
DupArchiveEngine::addRelativeFileToArchiveST($archive_filepath, $htaccess_filepath, $htaccess_ark_file_path);
|
268 |
$this->numFilesAdded++;
|
269 |
-
}
|
|
|
270 |
// Non critical so bury exception
|
271 |
}
|
272 |
}
|
@@ -275,19 +276,20 @@ class DUP_Installer
|
|
275 |
try {
|
276 |
DupArchiveEngine::addRelativeFileToArchiveST($archive_filepath, $webconf_filepath, DUPLICATOR_WEBCONFIG_ORIG_FILENAME);
|
277 |
$this->numFilesAdded++;
|
278 |
-
}
|
|
|
279 |
// Non critical so bury exception
|
280 |
}
|
281 |
}
|
282 |
|
283 |
if (file_exists($wpconfig_filepath)) {
|
284 |
-
$conf_ark_file_path
|
285 |
$temp_conf_ark_file_path = $this->getTempWPConfArkFilePath();
|
286 |
if (copy($wpconfig_filepath, $temp_conf_ark_file_path)) {
|
287 |
-
|
288 |
DupArchiveEngine::addRelativeFileToArchiveST($archive_filepath, $temp_conf_ark_file_path, $conf_ark_file_path);
|
289 |
-
|
290 |
-
|
291 |
}
|
292 |
$this->numFilesAdded++;
|
293 |
}
|
@@ -295,7 +297,8 @@ class DUP_Installer
|
|
295 |
$this->add_installer_files_using_duparchive($archive_filepath, $installer_filepath, $archive_config_filepath);
|
296 |
|
297 |
$success = true;
|
298 |
-
}
|
|
|
299 |
DUP_Log::Error("Error adding installer files to archive. ", $ex->getMessage(), Dup_ErrorBehavior::ThrowException);
|
300 |
}
|
301 |
|
@@ -351,8 +354,8 @@ class DUP_Installer
|
|
351 |
|
352 |
private function add_extra_files_using_ziparchive($installer_filepath, $scan_filepath, $sql_filepath, $zip_filepath, $archive_config_filepath, $wpconfig_filepath)
|
353 |
{
|
354 |
-
$htaccess_filepath
|
355 |
-
$webconfig_filepath = duplicator_get_abs_path()
|
356 |
|
357 |
$success = false;
|
358 |
$zipArchive = new ZipArchive();
|
@@ -370,14 +373,14 @@ class DUP_Installer
|
|
370 |
}
|
371 |
|
372 |
if (!empty($wpconfig_filepath)) {
|
373 |
-
$conf_ark_file_path
|
374 |
$temp_conf_ark_file_path = $this->getTempWPConfArkFilePath();
|
375 |
-
|
376 |
-
|
377 |
DUP_Zip_U::addFileToZipArchive($zipArchive, $temp_conf_ark_file_path, $conf_ark_file_path, true);
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
}
|
382 |
|
383 |
$embedded_scan_file_path = $this->getEmbeddedScanFilePath();
|
@@ -422,11 +425,10 @@ class DUP_Installer
|
|
422 |
|
423 |
if (DUP_Zip_U::addFileToZipArchive($zip_archive, $archive_config_filepath, $archive_config_local_name, true)) {
|
424 |
|
425 |
-
$snaplib_directory
|
426 |
-
$config_directory
|
427 |
|
428 |
-
if (DUP_Zip_U::addDirWithZipArchive($zip_archive, $snaplib_directory, true, 'dup-installer/lib/', $is_compressed)
|
429 |
-
&&
|
430 |
DUP_Zip_U::addDirWithZipArchive($zip_archive, $config_directory, true, 'dup-installer/lib/', $is_compressed)
|
431 |
) {
|
432 |
$success = true;
|
@@ -447,25 +449,26 @@ class DUP_Installer
|
|
447 |
}
|
448 |
|
449 |
/**
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
|
|
469 |
|
470 |
/**
|
471 |
* Get wp-config.php file path along with name in archive file
|
@@ -482,30 +485,32 @@ class DUP_Installer
|
|
482 |
}
|
483 |
|
484 |
/**
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
|
|
|
|
498 |
if (function_exists('token_get_all')) {
|
499 |
-
require_once(DUPLICATOR_PLUGIN_PATH
|
500 |
$transformer = new WPConfigTransformer($temp_conf_ark_file_path);
|
501 |
-
$constants
|
502 |
foreach ($constants as $constant) {
|
503 |
if ($transformer->exists('constant', $constant)) {
|
504 |
$transformer->update('constant', $constant, '');
|
505 |
}
|
506 |
}
|
507 |
}
|
508 |
-
|
509 |
|
510 |
/**
|
511 |
* Get scan.json file path along with name in archive file
|
@@ -526,4 +531,4 @@ class DUP_Installer
|
|
526 |
$archive_txt_file_path = 'dup-installer/dup-archive__'.$package_hash.'.txt';
|
527 |
return $archive_txt_file_path;
|
528 |
}
|
529 |
-
}
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
3 |
// Exit if accessed directly
|
4 |
/* @var $global DUP_Global_Entity */
|
|
|
5 |
|
6 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/class.archive.config.php');
|
7 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/utilities/class.u.zip.php');
|
10 |
|
11 |
class DUP_Installer
|
12 |
{
|
13 |
+
|
14 |
+
const DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH = 'installer.php';
|
15 |
+
|
16 |
//PUBLIC
|
17 |
public $File;
|
18 |
public $Size = 0;
|
52 |
if ($success) {
|
53 |
$package->BuildProgress->installer_built = true;
|
54 |
} else {
|
55 |
+
$error_message = 'Error adding installer';
|
56 |
$package->BuildProgress->set_failed($error_message);
|
57 |
$package->Status = DUP_PackageStatus::ERROR;
|
58 |
$package->Update();
|
76 |
|
77 |
private function create_enhanced_installer()
|
78 |
{
|
79 |
+
$success = true;
|
80 |
+
$archive_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Archive->File}";
|
81 |
+
$installer_filepath = apply_filters('duplicator_installer_file_path', DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_installer.php");
|
82 |
$template_filepath = DUPLICATOR_PLUGIN_PATH.'/installer/installer.tpl';
|
83 |
$mini_expander_filepath = DUPLICATOR_PLUGIN_PATH.'/lib/dup_archive/classes/class.duparchive.mini.expander.php';
|
84 |
|
96 |
$mini_expander_string = '';
|
97 |
}
|
98 |
|
99 |
+
$search_array = array('@@ARCHIVE@@', '@@VERSION@@', '@@ARCHIVE_SIZE@@', '@@PACKAGE_HASH@@', '@@SECONDARY_PACKAGE_HASH@@', '@@DUPARCHIVE_MINI_EXPANDER@@');
|
100 |
+
$package_hash = $this->Package->getPackageHash();
|
101 |
+
$secondary_package_hash = $this->Package->getSecondaryPackageHash();
|
102 |
+
$replace_array = array($this->Package->Archive->File, DUPLICATOR_VERSION, @filesize($archive_filepath), $package_hash, $secondary_package_hash, $mini_expander_string);
|
103 |
+
$installer_contents = str_replace($search_array, $replace_array, $installer_contents);
|
104 |
|
105 |
if (@file_put_contents($installer_filepath, $installer_contents) === false) {
|
106 |
DUP_Log::error(esc_html__('Error writing installer contents', 'duplicator'), esc_html__("Couldn't write to $installer_filepath", 'duplicator'));
|
108 |
}
|
109 |
|
110 |
if ($success) {
|
111 |
+
$storePath = DUP_Settings::getSsdirTmpPath()."/{$this->File}";
|
112 |
$this->Size = @filesize($storePath);
|
113 |
}
|
114 |
|
122 |
global $wpdb;
|
123 |
|
124 |
$success = true;
|
125 |
+
$archive_config_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_archive.txt";
|
126 |
$ac = new DUP_Archive_Config();
|
127 |
$extension = strtolower($this->Package->Archive->Format);
|
128 |
|
129 |
$hasher = new DUP_PasswordHash(8, FALSE);
|
130 |
$pass_hash = $hasher->HashPassword($this->Package->Installer->OptsSecurePass);
|
131 |
|
132 |
+
$this->Package->Database->getScannerData();
|
133 |
|
134 |
//READ-ONLY: COMPARE VALUES
|
135 |
$ac->created = $this->Package->Created;
|
142 |
|
143 |
//READ-ONLY: GENERAL
|
144 |
// $ac->installer_base_name = $global->installer_base_name;
|
145 |
+
$ac->installer_base_name = 'installer.php';
|
146 |
+
$ac->package_name = "{$this->Package->NameHash}_archive.{$extension}";
|
147 |
+
$ac->package_hash = $this->Package->getPackageHash();
|
148 |
+
$ac->package_notes = $this->Package->Notes;
|
149 |
+
$ac->url_old = get_option('siteurl');
|
150 |
+
$ac->opts_delete = DupLiteSnapJsonU::wp_json_encode_pprint($GLOBALS['DUPLICATOR_OPTS_DELETE']);
|
151 |
+
$ac->blogname = esc_html(get_option('blogname'));
|
152 |
+
|
153 |
+
$abs_path = duplicator_get_abs_path();
|
154 |
+
$ac->wproot = $abs_path;
|
155 |
+
$ac->relative_content_dir = str_replace($abs_path, '', WP_CONTENT_DIR);
|
156 |
+
$ac->exportOnlyDB = $this->Package->Archive->ExportOnlyDB;
|
157 |
+
$ac->installSiteOverwriteOn = DUPLICATOR_INSTALL_SITE_OVERWRITE_ON;
|
158 |
+
$ac->wplogin_url = wp_login_url();
|
159 |
+
|
160 |
+
//PRE-FILLED: GENERAL
|
161 |
$ac->secure_on = $this->Package->Installer->OptsSecureOn;
|
162 |
$ac->secure_pass = $pass_hash;
|
163 |
$ac->skipscan = false;
|
168 |
$ac->wp_tableprefix = $wpdb->base_prefix;
|
169 |
|
170 |
$ac->mu_mode = DUP_MU::getMode();
|
171 |
+
$ac->is_outer_root_wp_config_file = (!file_exists($abs_path.'/wp-config.php')) ? true : false;
|
172 |
$ac->is_outer_root_wp_content_dir = $this->Package->Archive->isOuterWPContentDir();
|
173 |
|
174 |
+
$json = DupLiteSnapJsonU::wp_json_encode_pprint($ac);
|
175 |
+
DUP_Log::TraceObject('json', $json);
|
176 |
|
177 |
if (file_put_contents($archive_config_filepath, $json) === false) {
|
178 |
DUP_Log::error("Error writing archive config", "Couldn't write archive config at $archive_config_filepath", Dup_ErrorBehavior::LogOnly);
|
188 |
private function add_extra_files($package)
|
189 |
{
|
190 |
$success = false;
|
191 |
+
$installer_filepath = apply_filters('duplicator_installer_file_path', DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_installer.php");
|
192 |
+
$scan_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_scan.json";
|
193 |
+
$sql_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Database->File}";
|
194 |
+
$archive_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Archive->File}";
|
195 |
+
$archive_config_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_archive.txt";
|
196 |
|
197 |
DUP_Log::Info("add_extra_files1");
|
198 |
|
251 |
try {
|
252 |
DUP_Log::Info("add_extra_files_using_da1");
|
253 |
$htaccess_filepath = $this->getHtaccessFilePath();
|
254 |
+
$webconf_filepath = duplicator_get_abs_path().'/web.config';
|
255 |
|
256 |
$logger = new DUP_DupArchive_Logger();
|
257 |
|
266 |
try {
|
267 |
DupArchiveEngine::addRelativeFileToArchiveST($archive_filepath, $htaccess_filepath, $htaccess_ark_file_path);
|
268 |
$this->numFilesAdded++;
|
269 |
+
}
|
270 |
+
catch (Exception $ex) {
|
271 |
// Non critical so bury exception
|
272 |
}
|
273 |
}
|
276 |
try {
|
277 |
DupArchiveEngine::addRelativeFileToArchiveST($archive_filepath, $webconf_filepath, DUPLICATOR_WEBCONFIG_ORIG_FILENAME);
|
278 |
$this->numFilesAdded++;
|
279 |
+
}
|
280 |
+
catch (Exception $ex) {
|
281 |
// Non critical so bury exception
|
282 |
}
|
283 |
}
|
284 |
|
285 |
if (file_exists($wpconfig_filepath)) {
|
286 |
+
$conf_ark_file_path = $this->getWPConfArkFilePath();
|
287 |
$temp_conf_ark_file_path = $this->getTempWPConfArkFilePath();
|
288 |
if (copy($wpconfig_filepath, $temp_conf_ark_file_path)) {
|
289 |
+
$this->cleanTempWPConfArkFilePath($temp_conf_ark_file_path);
|
290 |
DupArchiveEngine::addRelativeFileToArchiveST($archive_filepath, $temp_conf_ark_file_path, $conf_ark_file_path);
|
291 |
+
} else {
|
292 |
+
DupArchiveEngine::addRelativeFileToArchiveST($archive_filepath, $wpconfig_filepath, $conf_ark_file_path);
|
293 |
}
|
294 |
$this->numFilesAdded++;
|
295 |
}
|
297 |
$this->add_installer_files_using_duparchive($archive_filepath, $installer_filepath, $archive_config_filepath);
|
298 |
|
299 |
$success = true;
|
300 |
+
}
|
301 |
+
catch (Exception $ex) {
|
302 |
DUP_Log::Error("Error adding installer files to archive. ", $ex->getMessage(), Dup_ErrorBehavior::ThrowException);
|
303 |
}
|
304 |
|
354 |
|
355 |
private function add_extra_files_using_ziparchive($installer_filepath, $scan_filepath, $sql_filepath, $zip_filepath, $archive_config_filepath, $wpconfig_filepath)
|
356 |
{
|
357 |
+
$htaccess_filepath = $this->getHtaccessFilePath();
|
358 |
+
$webconfig_filepath = duplicator_get_abs_path().'/web.config';
|
359 |
|
360 |
$success = false;
|
361 |
$zipArchive = new ZipArchive();
|
373 |
}
|
374 |
|
375 |
if (!empty($wpconfig_filepath)) {
|
376 |
+
$conf_ark_file_path = $this->getWPConfArkFilePath();
|
377 |
$temp_conf_ark_file_path = $this->getTempWPConfArkFilePath();
|
378 |
+
if (copy($wpconfig_filepath, $temp_conf_ark_file_path)) {
|
379 |
+
$this->cleanTempWPConfArkFilePath($temp_conf_ark_file_path);
|
380 |
DUP_Zip_U::addFileToZipArchive($zipArchive, $temp_conf_ark_file_path, $conf_ark_file_path, true);
|
381 |
+
} else {
|
382 |
+
DUP_Zip_U::addFileToZipArchive($zipArchive, $wpconfig_filepath, $conf_ark_file_path, true);
|
383 |
+
}
|
384 |
}
|
385 |
|
386 |
$embedded_scan_file_path = $this->getEmbeddedScanFilePath();
|
425 |
|
426 |
if (DUP_Zip_U::addFileToZipArchive($zip_archive, $archive_config_filepath, $archive_config_local_name, true)) {
|
427 |
|
428 |
+
$snaplib_directory = DUPLICATOR_PLUGIN_PATH.'lib/snaplib';
|
429 |
+
$config_directory = DUPLICATOR_PLUGIN_PATH.'lib/config';
|
430 |
|
431 |
+
if (DUP_Zip_U::addDirWithZipArchive($zip_archive, $snaplib_directory, true, 'dup-installer/lib/', $is_compressed) &&
|
|
|
432 |
DUP_Zip_U::addDirWithZipArchive($zip_archive, $config_directory, true, 'dup-installer/lib/', $is_compressed)
|
433 |
) {
|
434 |
$success = true;
|
449 |
}
|
450 |
|
451 |
/**
|
452 |
+
* Get .htaccess file path
|
453 |
+
*
|
454 |
+
* @return string
|
455 |
+
*/
|
456 |
+
private function getHtaccessFilePath()
|
457 |
+
{
|
458 |
+
return duplicator_get_abs_path().'/.htaccess';
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Get .htaccss in archive file
|
463 |
+
*
|
464 |
+
* @return string
|
465 |
+
*/
|
466 |
+
private function getHtaccessArkFilePath()
|
467 |
+
{
|
468 |
+
$packageHash = $this->Package->getPackageHash();
|
469 |
+
$htaccessArkFilePath = '.htaccess__'.$packageHash;
|
470 |
+
return $htaccessArkFilePath;
|
471 |
+
}
|
472 |
|
473 |
/**
|
474 |
* Get wp-config.php file path along with name in archive file
|
485 |
}
|
486 |
|
487 |
/**
|
488 |
+
* Get temp wp-config.php file path along with name in temp folder
|
489 |
+
*/
|
490 |
+
private function getTempWPConfArkFilePath()
|
491 |
+
{
|
492 |
+
$temp_conf_ark_file_path = DUP_Settings::getSsdirTmpPath().'/'.$this->Package->NameHash.'_wp-config.txt';
|
493 |
+
return $temp_conf_ark_file_path;
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Clear out sensitive database connection information
|
498 |
+
*
|
499 |
+
* @param $temp_conf_ark_file_path Temp config file path
|
500 |
+
*/
|
501 |
+
private static function cleanTempWPConfArkFilePath($temp_conf_ark_file_path)
|
502 |
+
{
|
503 |
if (function_exists('token_get_all')) {
|
504 |
+
require_once(DUPLICATOR_PLUGIN_PATH.'lib/config/class.wp.config.tranformer.php');
|
505 |
$transformer = new WPConfigTransformer($temp_conf_ark_file_path);
|
506 |
+
$constants = array('DB_NAME', 'DB_USER', 'DB_PASSWORD', 'DB_HOST');
|
507 |
foreach ($constants as $constant) {
|
508 |
if ($transformer->exists('constant', $constant)) {
|
509 |
$transformer->update('constant', $constant, '');
|
510 |
}
|
511 |
}
|
512 |
}
|
513 |
+
}
|
514 |
|
515 |
/**
|
516 |
* Get scan.json file path along with name in archive file
|
531 |
$archive_txt_file_path = 'dup-installer/dup-archive__'.$package_hash.'.txt';
|
532 |
return $archive_txt_file_path;
|
533 |
}
|
534 |
+
}
|
classes/package/class.pack.php
CHANGED
@@ -145,6 +145,7 @@ abstract class DUP_PackageFileType
|
|
145 |
const Archive = 1;
|
146 |
const SQL = 2;
|
147 |
const Log = 3;
|
|
|
148 |
}
|
149 |
|
150 |
/**
|
@@ -173,8 +174,6 @@ class DUP_Package
|
|
173 |
//Set to DUP_PackageType
|
174 |
public $Type;
|
175 |
public $Notes;
|
176 |
-
public $StorePath;
|
177 |
-
public $StoreURL;
|
178 |
public $ScanFile;
|
179 |
public $TimerStart = -1;
|
180 |
public $Runtime;
|
@@ -199,8 +198,6 @@ class DUP_Package
|
|
199 |
$this->Type = DUP_PackageType::MANUAL;
|
200 |
$this->Name = self::getDefaultName();
|
201 |
$this->Notes = null;
|
202 |
-
$this->StoreURL = DUP_Util::snapshotURL();
|
203 |
-
$this->StorePath = DUPLICATOR_SSDIR_PATH_TMP;
|
204 |
$this->Database = new DUP_Database($this);
|
205 |
$this->Archive = new DUP_Archive($this);
|
206 |
$this->Installer = new DUP_Installer($this);
|
@@ -252,7 +249,7 @@ class DUP_Package
|
|
252 |
$report['ARC']['Status']['Names'] = (count($this->Archive->FilterInfo->Files->Warning) + count($this->Archive->FilterInfo->Dirs->Warning)) ? 'Warn' : 'Good';
|
253 |
$report['ARC']['Status']['UnreadableItems'] = !empty($this->Archive->RecursiveLinks) || !empty($report['ARC']['UnreadableItems'])? 'Warn' : 'Good';
|
254 |
/*
|
255 |
-
$overwriteInstallerParams = apply_filters('
|
256 |
$package_can_be_migrate = !(isset($overwriteInstallerParams['mode_chunking']['value'])
|
257 |
&& $overwriteInstallerParams['mode_chunking']['value'] == 3
|
258 |
&& isset($overwriteInstallerParams['mode_chunking']['formStatus'])
|
@@ -309,7 +306,7 @@ class DUP_Package
|
|
309 |
$report['RPT']['Warnings'] = is_null($warn_counts['Warn']) ? 0 : $warn_counts['Warn'];
|
310 |
$report['RPT']['Success'] = is_null($warn_counts['Good']) ? 0 : $warn_counts['Good'];
|
311 |
$report['RPT']['ScanTime'] = DUP_Util::elapsedTime(DUP_Util::getMicrotime(), $timerStart);
|
312 |
-
$fp = fopen(
|
313 |
|
314 |
fwrite($fp, DupLiteSnapJsonU::wp_json_encode_pprint($report));
|
315 |
fclose($fp);
|
@@ -483,30 +480,33 @@ class DUP_Package
|
|
483 |
$delResult = $wpdb->query($wpdb->prepare("DELETE FROM `{$tblName}` WHERE id = %d", $this->ID));
|
484 |
|
485 |
if ($delResult != 0) {
|
|
|
|
|
|
|
486 |
//Perms
|
487 |
-
@chmod(
|
488 |
-
@chmod(
|
489 |
-
@chmod(
|
490 |
-
@chmod(
|
491 |
-
@chmod(
|
492 |
-
|
493 |
-
@chmod(
|
494 |
-
@chmod(
|
495 |
-
@chmod(
|
496 |
-
@chmod(
|
497 |
-
@chmod(
|
498 |
//Remove
|
499 |
-
@unlink(
|
500 |
-
@unlink(
|
501 |
-
@unlink(
|
502 |
-
@unlink(
|
503 |
-
@unlink(
|
504 |
-
|
505 |
-
@unlink(
|
506 |
-
@unlink(
|
507 |
-
@unlink(
|
508 |
-
@unlink(
|
509 |
-
@unlink(
|
510 |
}
|
511 |
}
|
512 |
}
|
@@ -523,7 +523,7 @@ class DUP_Package
|
|
523 |
if ($this->Status >= DUP_PackageStatus::COMPLETE) {
|
524 |
$size = $this->Archive->Size;
|
525 |
} else {
|
526 |
-
$tmpSearch = glob(
|
527 |
if (is_array($tmpSearch)) {
|
528 |
$result = array_map('filesize', $tmpSearch);
|
529 |
$size = array_sum($result);
|
@@ -817,7 +817,7 @@ class DUP_Package
|
|
817 |
|
818 |
//------------------------
|
819 |
//SQL CHECK: File should be at minimum 5K. A base WP install with only Create tables is about 9K
|
820 |
-
$sql_temp_path =
|
821 |
$sql_temp_size = @filesize($sql_temp_path);
|
822 |
$sql_easy_size = DUP_Util::byteSize($sql_temp_size);
|
823 |
$sql_done_txt = DUP_Util::tailFile($sql_temp_path, 3);
|
@@ -839,7 +839,7 @@ class DUP_Package
|
|
839 |
|
840 |
//------------------------
|
841 |
//INSTALLER CHECK:
|
842 |
-
$exe_temp_path =
|
843 |
|
844 |
$exe_temp_size = @filesize($exe_temp_path);
|
845 |
$exe_easy_size = DUP_Util::byteSize($exe_temp_size);
|
@@ -873,7 +873,7 @@ class DUP_Package
|
|
873 |
return;
|
874 |
}
|
875 |
|
876 |
-
$scan_filepath =
|
877 |
$json = '';
|
878 |
|
879 |
DUP_LOG::Trace("***********Does $scan_filepath exist?");
|
@@ -940,7 +940,7 @@ class DUP_Package
|
|
940 |
/* ------ ZIP CONSISTENCY CHECK ------ */
|
941 |
if ($this->Archive->getBuildMode() == DUP_Archive_Build_Mode::ZipArchive) {
|
942 |
DUP_LOG::trace("Running ZipArchive consistency check");
|
943 |
-
$zipPath =
|
944 |
|
945 |
$zip = new ZipArchive();
|
946 |
|
@@ -999,7 +999,7 @@ class DUP_Package
|
|
999 |
$file_name = $this->getLogFilename();
|
1000 |
}
|
1001 |
|
1002 |
-
$file_path =
|
1003 |
DUP_Log::Trace("File path $file_path");
|
1004 |
|
1005 |
if (file_exists($file_path)) {
|
@@ -1014,11 +1014,21 @@ class DUP_Package
|
|
1014 |
return $this->NameHash . '_scan.json';
|
1015 |
}
|
1016 |
|
|
|
|
|
|
|
|
|
|
|
1017 |
public function getLogFilename()
|
1018 |
{
|
1019 |
return $this->NameHash . '.log';
|
1020 |
}
|
1021 |
|
|
|
|
|
|
|
|
|
|
|
1022 |
public function getArchiveFilename()
|
1023 |
{
|
1024 |
$extension = strtolower($this->Archive->Format);
|
@@ -1036,17 +1046,60 @@ class DUP_Package
|
|
1036 |
return $this->NameHash . '_database.sql';
|
1037 |
}
|
1038 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1039 |
/**
|
1040 |
* Removes all files except those of active packages
|
1041 |
*/
|
1042 |
public static function not_active_files_tmp_cleanup()
|
1043 |
{
|
1044 |
//Check for the 'tmp' folder just for safe measures
|
1045 |
-
if (! is_dir(
|
1046 |
return;
|
1047 |
}
|
1048 |
|
1049 |
-
$globs = glob(
|
1050 |
if (! is_array($globs) || $globs === FALSE) {
|
1051 |
return;
|
1052 |
}
|
@@ -1123,17 +1176,17 @@ class DUP_Package
|
|
1123 |
public static function safeTmpCleanup($purge_temp_archives = false)
|
1124 |
{
|
1125 |
if ($purge_temp_archives) {
|
1126 |
-
$dir =
|
1127 |
foreach (glob($dir) as $file_path) {
|
1128 |
unlink($file_path);
|
1129 |
}
|
1130 |
-
$dir =
|
1131 |
foreach (glob($dir) as $file_path) {
|
1132 |
unlink($file_path);
|
1133 |
}
|
1134 |
} else {
|
1135 |
//Remove all temp files that are 24 hours old
|
1136 |
-
$dir =
|
1137 |
|
1138 |
$files = glob($dir);
|
1139 |
|
@@ -1564,14 +1617,14 @@ class DUP_Package
|
|
1564 |
{
|
1565 |
//Delete all files now
|
1566 |
if ($all) {
|
1567 |
-
$dir =
|
1568 |
foreach (glob($dir) as $file) {
|
1569 |
@unlink($file);
|
1570 |
}
|
1571 |
}
|
1572 |
//Remove scan files that are 24 hours old
|
1573 |
else {
|
1574 |
-
$dir =
|
1575 |
foreach (glob($dir) as $file) {
|
1576 |
if (filemtime($file) <= time() - 86400) {
|
1577 |
@unlink($file);
|
@@ -1630,8 +1683,8 @@ class DUP_Package
|
|
1630 |
*/
|
1631 |
public function buildCleanup()
|
1632 |
{
|
1633 |
-
$files = DUP_Util::listFiles(
|
1634 |
-
$newPath =
|
1635 |
|
1636 |
if (function_exists('rename')) {
|
1637 |
foreach ($files as $file) {
|
145 |
const Archive = 1;
|
146 |
const SQL = 2;
|
147 |
const Log = 3;
|
148 |
+
const Scan = 4;
|
149 |
}
|
150 |
|
151 |
/**
|
174 |
//Set to DUP_PackageType
|
175 |
public $Type;
|
176 |
public $Notes;
|
|
|
|
|
177 |
public $ScanFile;
|
178 |
public $TimerStart = -1;
|
179 |
public $Runtime;
|
198 |
$this->Type = DUP_PackageType::MANUAL;
|
199 |
$this->Name = self::getDefaultName();
|
200 |
$this->Notes = null;
|
|
|
|
|
201 |
$this->Database = new DUP_Database($this);
|
202 |
$this->Archive = new DUP_Archive($this);
|
203 |
$this->Installer = new DUP_Installer($this);
|
249 |
$report['ARC']['Status']['Names'] = (count($this->Archive->FilterInfo->Files->Warning) + count($this->Archive->FilterInfo->Dirs->Warning)) ? 'Warn' : 'Good';
|
250 |
$report['ARC']['Status']['UnreadableItems'] = !empty($this->Archive->RecursiveLinks) || !empty($report['ARC']['UnreadableItems'])? 'Warn' : 'Good';
|
251 |
/*
|
252 |
+
$overwriteInstallerParams = apply_filters('duplicator_overwrite_params_data', array());
|
253 |
$package_can_be_migrate = !(isset($overwriteInstallerParams['mode_chunking']['value'])
|
254 |
&& $overwriteInstallerParams['mode_chunking']['value'] == 3
|
255 |
&& isset($overwriteInstallerParams['mode_chunking']['formStatus'])
|
306 |
$report['RPT']['Warnings'] = is_null($warn_counts['Warn']) ? 0 : $warn_counts['Warn'];
|
307 |
$report['RPT']['Success'] = is_null($warn_counts['Good']) ? 0 : $warn_counts['Good'];
|
308 |
$report['RPT']['ScanTime'] = DUP_Util::elapsedTime(DUP_Util::getMicrotime(), $timerStart);
|
309 |
+
$fp = fopen(DUP_Settings::getSsdirTmpPath()."/{$this->ScanFile}", 'w');
|
310 |
|
311 |
fwrite($fp, DupLiteSnapJsonU::wp_json_encode_pprint($report));
|
312 |
fclose($fp);
|
480 |
$delResult = $wpdb->query($wpdb->prepare("DELETE FROM `{$tblName}` WHERE id = %d", $this->ID));
|
481 |
|
482 |
if ($delResult != 0) {
|
483 |
+
$tmpPath = DUP_Settings::getSsdirTmpPath();
|
484 |
+
$ssdPath = DUP_Settings::getSsdirPath();
|
485 |
+
|
486 |
//Perms
|
487 |
+
@chmod($tmpPath."/{$nameHash}_archive.zip", 0644);
|
488 |
+
@chmod($tmpPath."/{$nameHash}_database.sql", 0644);
|
489 |
+
@chmod($tmpPath."/{$nameHash}_installer.php", 0644);
|
490 |
+
@chmod($tmpPath."/{$nameHash}_scan.json", 0644);
|
491 |
+
@chmod($tmpPath."/{$nameHash}.log", 0644);
|
492 |
+
|
493 |
+
@chmod($ssdPath."/{$nameHash}_archive.zip", 0644);
|
494 |
+
@chmod($ssdPath."/{$nameHash}_database.sql", 0644);
|
495 |
+
@chmod($ssdPath."/{$nameHash}_installer.php", 0644);
|
496 |
+
@chmod($ssdPath."/{$nameHash}_scan.json", 0644);
|
497 |
+
@chmod($ssdPath."/{$nameHash}.log", 0644);
|
498 |
//Remove
|
499 |
+
@unlink($tmpPath."/{$nameHash}_archive.zip");
|
500 |
+
@unlink($tmpPath."/{$nameHash}_database.sql");
|
501 |
+
@unlink($tmpPath."/{$nameHash}_installer.php");
|
502 |
+
@unlink($tmpPath."/{$nameHash}_scan.json");
|
503 |
+
@unlink($tmpPath."/{$nameHash}.log");
|
504 |
+
|
505 |
+
@unlink($ssdPath."/{$nameHash}_archive.zip");
|
506 |
+
@unlink($ssdPath."/{$nameHash}_database.sql");
|
507 |
+
@unlink($ssdPath."/{$nameHash}_installer.php");
|
508 |
+
@unlink($ssdPath."/{$nameHash}_scan.json");
|
509 |
+
@unlink($ssdPath."/{$nameHash}.log");
|
510 |
}
|
511 |
}
|
512 |
}
|
523 |
if ($this->Status >= DUP_PackageStatus::COMPLETE) {
|
524 |
$size = $this->Archive->Size;
|
525 |
} else {
|
526 |
+
$tmpSearch = glob(DUP_Settings::getSsdirTmpPath() . "/{$this->NameHash}_*");
|
527 |
if (is_array($tmpSearch)) {
|
528 |
$result = array_map('filesize', $tmpSearch);
|
529 |
$size = array_sum($result);
|
817 |
|
818 |
//------------------------
|
819 |
//SQL CHECK: File should be at minimum 5K. A base WP install with only Create tables is about 9K
|
820 |
+
$sql_temp_path = DUP_Settings::getSsdirTmpPath() . '/' . $this->Database->File;
|
821 |
$sql_temp_size = @filesize($sql_temp_path);
|
822 |
$sql_easy_size = DUP_Util::byteSize($sql_temp_size);
|
823 |
$sql_done_txt = DUP_Util::tailFile($sql_temp_path, 3);
|
839 |
|
840 |
//------------------------
|
841 |
//INSTALLER CHECK:
|
842 |
+
$exe_temp_path = DUP_Settings::getSsdirTmpPath() . '/' . $this->Installer->File;
|
843 |
|
844 |
$exe_temp_size = @filesize($exe_temp_path);
|
845 |
$exe_easy_size = DUP_Util::byteSize($exe_temp_size);
|
873 |
return;
|
874 |
}
|
875 |
|
876 |
+
$scan_filepath = DUP_Settings::getSsdirTmpPath() . "/{$this->NameHash}_scan.json";
|
877 |
$json = '';
|
878 |
|
879 |
DUP_LOG::Trace("***********Does $scan_filepath exist?");
|
940 |
/* ------ ZIP CONSISTENCY CHECK ------ */
|
941 |
if ($this->Archive->getBuildMode() == DUP_Archive_Build_Mode::ZipArchive) {
|
942 |
DUP_LOG::trace("Running ZipArchive consistency check");
|
943 |
+
$zipPath = DUP_Settings::getSsdirTmpPath()."/{$this->Archive->File}";
|
944 |
|
945 |
$zip = new ZipArchive();
|
946 |
|
999 |
$file_name = $this->getLogFilename();
|
1000 |
}
|
1001 |
|
1002 |
+
$file_path = DUP_Settings::getSsdirPath() . "/$file_name";
|
1003 |
DUP_Log::Trace("File path $file_path");
|
1004 |
|
1005 |
if (file_exists($file_path)) {
|
1014 |
return $this->NameHash . '_scan.json';
|
1015 |
}
|
1016 |
|
1017 |
+
public function getScanUrl()
|
1018 |
+
{
|
1019 |
+
return DUP_Settings::getSsdirUrl()."/".$this->getScanFilename();
|
1020 |
+
}
|
1021 |
+
|
1022 |
public function getLogFilename()
|
1023 |
{
|
1024 |
return $this->NameHash . '.log';
|
1025 |
}
|
1026 |
|
1027 |
+
public function getLogUrl()
|
1028 |
+
{
|
1029 |
+
return DUP_Settings::getSsdirUrl()."/".$this->getLogFilename();
|
1030 |
+
}
|
1031 |
+
|
1032 |
public function getArchiveFilename()
|
1033 |
{
|
1034 |
$extension = strtolower($this->Archive->Format);
|
1046 |
return $this->NameHash . '_database.sql';
|
1047 |
}
|
1048 |
|
1049 |
+
/**
|
1050 |
+
* @param int $type
|
1051 |
+
* @return array
|
1052 |
+
*/
|
1053 |
+
public function getPackageFileDownloadInfo($type)
|
1054 |
+
{
|
1055 |
+
$result = array(
|
1056 |
+
"filename" => "",
|
1057 |
+
"url" => ""
|
1058 |
+
);
|
1059 |
+
|
1060 |
+
switch ($type){
|
1061 |
+
case DUP_PackageFileType::Archive;
|
1062 |
+
$result["filename"] = $this->Archive->File;
|
1063 |
+
$result["url"] = $this->Archive->getURL();
|
1064 |
+
break;
|
1065 |
+
case DUP_PackageFileType::SQL;
|
1066 |
+
$result["filename"] = $this->Database->File;
|
1067 |
+
$result["url"] = $this->Database->getURL();
|
1068 |
+
break;
|
1069 |
+
case DUP_PackageFileType::Log;
|
1070 |
+
$result["filename"] = $this->getLogFilename();
|
1071 |
+
$result["url"] = $this->getLogUrl();
|
1072 |
+
break;
|
1073 |
+
case DUP_PackageFileType::Scan;
|
1074 |
+
$result["filename"] = $this->getScanFilename();
|
1075 |
+
$result["url"] = $this->getScanUrl();
|
1076 |
+
break;
|
1077 |
+
default:
|
1078 |
+
break;
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
return $result;
|
1082 |
+
}
|
1083 |
+
|
1084 |
+
public function getInstallerDownloadInfo()
|
1085 |
+
{
|
1086 |
+
return array(
|
1087 |
+
"id" => $this->ID,
|
1088 |
+
"hash" => $this->Hash
|
1089 |
+
);
|
1090 |
+
}
|
1091 |
+
|
1092 |
/**
|
1093 |
* Removes all files except those of active packages
|
1094 |
*/
|
1095 |
public static function not_active_files_tmp_cleanup()
|
1096 |
{
|
1097 |
//Check for the 'tmp' folder just for safe measures
|
1098 |
+
if (! is_dir(DUP_Settings::getSsdirTmpPath()) && (strpos(DUP_Settings::getSsdirTmpPath(), 'tmp') !== false) ) {
|
1099 |
return;
|
1100 |
}
|
1101 |
|
1102 |
+
$globs = glob(DUP_Settings::getSsdirTmpPath().'/*.*');
|
1103 |
if (! is_array($globs) || $globs === FALSE) {
|
1104 |
return;
|
1105 |
}
|
1176 |
public static function safeTmpCleanup($purge_temp_archives = false)
|
1177 |
{
|
1178 |
if ($purge_temp_archives) {
|
1179 |
+
$dir = DUP_Settings::getSsdirTmpPath() . "/*_archive.zip.*";
|
1180 |
foreach (glob($dir) as $file_path) {
|
1181 |
unlink($file_path);
|
1182 |
}
|
1183 |
+
$dir = DUP_Settings::getSsdirTmpPath() . "/*_archive.daf.*";
|
1184 |
foreach (glob($dir) as $file_path) {
|
1185 |
unlink($file_path);
|
1186 |
}
|
1187 |
} else {
|
1188 |
//Remove all temp files that are 24 hours old
|
1189 |
+
$dir = DUP_Settings::getSsdirTmpPath() . "/*";
|
1190 |
|
1191 |
$files = glob($dir);
|
1192 |
|
1617 |
{
|
1618 |
//Delete all files now
|
1619 |
if ($all) {
|
1620 |
+
$dir = DUP_Settings::getSsdirTmpPath()."/*";
|
1621 |
foreach (glob($dir) as $file) {
|
1622 |
@unlink($file);
|
1623 |
}
|
1624 |
}
|
1625 |
//Remove scan files that are 24 hours old
|
1626 |
else {
|
1627 |
+
$dir = DUP_Settings::getSsdirTmpPath()."/*_scan.json";
|
1628 |
foreach (glob($dir) as $file) {
|
1629 |
if (filemtime($file) <= time() - 86400) {
|
1630 |
@unlink($file);
|
1683 |
*/
|
1684 |
public function buildCleanup()
|
1685 |
{
|
1686 |
+
$files = DUP_Util::listFiles(DUP_Settings::getSsdirTmpPath());
|
1687 |
+
$newPath = DUP_Settings::getSsdirPath();
|
1688 |
|
1689 |
if (function_exists('rename')) {
|
1690 |
foreach ($files as $file) {
|
classes/package/duparchive/class.pack.archive.duparchive.php
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
<?php
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
3 |
-
if (!defined('DUPLICATOR_VERSION')) exit; // Exit if accessed directly
|
4 |
|
5 |
-
|
6 |
//require_once (DUPLICATOR_PLUGIN_PATH.'classes/utilities/class.u.php');
|
7 |
require_once (DUPLICATOR_PLUGIN_PATH.'classes/package/duparchive/class.pack.archive.duparchive.state.expand.php');
|
8 |
require_once (DUPLICATOR_PLUGIN_PATH.'classes/package/duparchive/class.pack.archive.duparchive.state.create.php');
|
@@ -23,6 +22,7 @@ class DUP_DupArchive_Logger extends DupArchiveLoggerBase
|
|
23 |
|
24 |
class DUP_DupArchive
|
25 |
{
|
|
|
26 |
// Using a worker time override since evidence shorter time works much
|
27 |
const WorkerTimeInSec = 10;
|
28 |
|
@@ -34,54 +34,54 @@ class DUP_DupArchive
|
|
34 |
{
|
35 |
/* @var $buildProgress DUP_Build_Progress */
|
36 |
|
37 |
-
|
38 |
try {
|
39 |
DUP_Log::Open($package->NameHash);
|
40 |
-
|
41 |
-
|
42 |
if ($buildProgress->retries > DUPLICATOR_MAX_BUILD_RETRIES) {
|
43 |
-
|
44 |
-
$error_msg
|
45 |
DUP_Log::error(esc_html__('Build Failure', 'duplicator'), esc_html($error_msg), Dup_ErrorBehavior::LogOnly);
|
46 |
//$buildProgress->failed = true;
|
47 |
$buildProgress->set_failed($error_msg);
|
48 |
-
$package->setStatus(DUP_PackageStatus::ERROR)
|
|
|
49 |
return true;
|
50 |
} else {
|
51 |
-
|
52 |
// If all goes well retries will be reset to 0 at the end of this function.
|
53 |
$buildProgress->retries++;
|
54 |
$package->update();
|
55 |
}
|
56 |
|
57 |
-
$done
|
58 |
|
59 |
-
|
60 |
DupArchiveEngine::init(new DUP_DupArchive_Logger(), null, $archive);
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
$compressDir = rtrim(DUP_Util::safePath($archive->PackDir), '/');
|
66 |
-
$sqlPath = DUP_Util::safePath("{$package->StorePath}/{$package->Database->File}");
|
67 |
-
$archivePath = DUP_Util::safePath("{$package->StorePath}/{$archive->File}");
|
68 |
|
69 |
-
$
|
|
|
|
|
|
|
70 |
|
71 |
-
|
72 |
$skipArchiveFinalization = false;
|
73 |
$json = '';
|
74 |
|
75 |
-
|
76 |
if (file_exists($scanFilepath)) {
|
77 |
|
78 |
-
|
79 |
$json = file_get_contents($scanFilepath);
|
80 |
|
81 |
if (empty($json)) {
|
82 |
-
|
83 |
$errorText = __("Scan file $scanFilepath is empty!", 'duplicator');
|
84 |
-
$fixText
|
85 |
|
86 |
DUP_Log::Trace($errorText);
|
87 |
DUP_Log::error(esc_html($errorText)." **RECOMMENDATION: ".esc_html($fixText).".", '', Dup_ErrorBehavior::LogOnly);
|
@@ -92,7 +92,7 @@ class DUP_DupArchive
|
|
92 |
return true;
|
93 |
}
|
94 |
} else {
|
95 |
-
|
96 |
DUP_Log::trace("**** scan file $scanFilepath doesn't exist!!");
|
97 |
$errorMessage = sprintf(__("ERROR: Can't find Scanfile %s. Please ensure there no non-English characters in the package or schedule name.", 'duplicator'), $scanFilepath);
|
98 |
|
@@ -104,21 +104,21 @@ class DUP_DupArchive
|
|
104 |
return true;
|
105 |
}
|
106 |
|
107 |
-
|
108 |
Dup_Log::TraceObject("buildprogress object", $buildProgress, false);
|
109 |
|
110 |
$scanReport = json_decode($json);
|
111 |
|
112 |
if ($buildProgress->archive_started == false) {
|
113 |
|
114 |
-
$filterDirs
|
115 |
-
$filterExts
|
116 |
-
$filterFiles
|
117 |
-
$filterOn
|
118 |
-
|
119 |
-
|
120 |
|
121 |
-
|
122 |
DUP_Log::info("\n********************************************************************************");
|
123 |
DUP_Log::info("ARCHIVE Type=DUP Mode=DupArchive");
|
124 |
DUP_Log::info("********************************************************************************");
|
@@ -126,8 +126,8 @@ class DUP_DupArchive
|
|
126 |
DUP_Log::info("ARCHIVE FILE: ".basename($archivePath));
|
127 |
DUP_Log::info("FILTERS: *{$filterOn}*");
|
128 |
DUP_Log::Info("DIRS:\n\t{$filterDirsFormat}");
|
129 |
-
|
130 |
-
|
131 |
|
132 |
DUP_Log::info("----------------------------------------");
|
133 |
DUP_Log::info("COMPRESSING");
|
@@ -145,10 +145,11 @@ class DUP_DupArchive
|
|
145 |
}
|
146 |
|
147 |
try {
|
148 |
-
|
149 |
$sql_ark_file_path = $package->getSqlArkFilePath();
|
150 |
DupArchiveEngine::addRelativeFileToArchiveST($archivePath, $sqlPath, $sql_ark_file_path);
|
151 |
-
}
|
|
|
152 |
$error_message = 'Error adding database.sql to archive';
|
153 |
|
154 |
DUP_Log::error($error_message, $ex->getMessage(), Dup_ErrorBehavior::LogOnly);
|
@@ -162,36 +163,35 @@ class DUP_DupArchive
|
|
162 |
|
163 |
$buildProgress->retries = 0;
|
164 |
|
165 |
-
|
166 |
-
|
167 |
|
168 |
-
|
169 |
|
170 |
$package->Update();
|
171 |
}
|
172 |
|
173 |
try {
|
174 |
|
175 |
-
|
176 |
$createState = DUP_DupArchive_Create_State::get_instance();
|
177 |
-
|
178 |
-
if($buildProgress->retries > 1) {
|
179 |
// Indicates it had problems before so move into robustness mode
|
180 |
$createState->isRobust = true;
|
181 |
-
|
182 |
$createState->save();
|
183 |
}
|
184 |
|
185 |
if ($createState->working) {
|
186 |
-
|
187 |
//die(0);//rsr
|
188 |
-
|
189 |
// DupArchiveEngine::addItemsToArchive($createState, $scanReport->ARC, $archive);
|
190 |
DupArchiveEngine::addItemsToArchive($createState, $scanReport->ARC);
|
191 |
|
192 |
$buildProgress->set_build_failures($createState->failures);
|
193 |
|
194 |
-
if($createState->isCriticalFailurePresent()) {
|
195 |
|
196 |
throw new Exception($createState->getFailureSummary());
|
197 |
}
|
@@ -215,7 +215,7 @@ class DUP_DupArchive
|
|
215 |
}
|
216 |
}
|
217 |
catch (Exception $ex) {
|
218 |
-
|
219 |
$message = __('Problem adding items to archive.', 'duplicator').' '.$ex->getMessage();
|
220 |
|
221 |
DUP_Log::Error(__('Problems adding items to archive.', 'duplicator'), $message, Dup_ErrorBehavior::LogOnly);
|
@@ -226,68 +226,64 @@ class DUP_DupArchive
|
|
226 |
return true;
|
227 |
}
|
228 |
|
229 |
-
|
230 |
|
231 |
//-- Final Wrapup of the Archive
|
232 |
if ((!$skipArchiveFinalization) && ($createState->working == false)) {
|
233 |
|
234 |
-
|
235 |
|
236 |
-
|
237 |
|
238 |
-
if(!$buildProgress->installer_built) {
|
239 |
|
240 |
-
if($package->Installer->build($package, false))
|
241 |
-
{
|
242 |
$package->Runtime = -1;
|
243 |
$package->ExeSize = DUP_Util::byteSize($package->Installer->Size);
|
244 |
$package->ZipSize = DUP_Util::byteSize($package->Archive->Size);
|
245 |
$package->update();
|
246 |
-
}
|
247 |
-
else
|
248 |
-
{
|
249 |
$package->update();
|
250 |
return;
|
251 |
}
|
252 |
|
253 |
-
|
254 |
|
255 |
-
|
|
|
256 |
|
257 |
DUP_Log::Trace("Installer has been built so running expand now");
|
258 |
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
|
274 |
$sfc = count($scanReport->ARC->Files);
|
275 |
$nfa = $package->Installer->numFilesAdded;
|
276 |
Dup_Log::trace("####scan files {$sfc} skipped files {$createState->skippedFileCount} num files added {$nfa}");
|
277 |
-
|
278 |
-
}
|
279 |
-
else {
|
280 |
|
281 |
-
|
282 |
-
try {
|
283 |
|
284 |
-
|
285 |
-
|
286 |
-
if($buildProgress->retries > 1) {
|
287 |
|
288 |
// Indicates it had problems before so move into robustness mode
|
289 |
$expandState->isRobust = true;
|
290 |
-
|
291 |
$expandState->save();
|
292 |
}
|
293 |
|
@@ -296,7 +292,7 @@ class DUP_DupArchive
|
|
296 |
DupArchiveEngine::expandArchive($expandState);
|
297 |
|
298 |
$buildProgress->set_validation_failures($expandState->failures);
|
299 |
-
|
300 |
$totalFileCount = count($scanReport->ARC->Files);
|
301 |
$archiveSize = @filesize($expandState->archivePath);
|
302 |
|
@@ -304,8 +300,8 @@ class DUP_DupArchive
|
|
304 |
$expandState->archiveOffset);
|
305 |
DUP_LOG::TraceObject("package status after expand=", $package->Status);
|
306 |
DUP_LOG::Trace("archive size:{$archiveSize} expand offset:{$expandState->archiveOffset}");
|
307 |
-
|
308 |
-
|
309 |
DUP_Log::Trace('Exception:'.$ex->getMessage().':'.$ex->getTraceAsString());
|
310 |
//$buildProgress->failed = true;
|
311 |
$buildProgress->set_failed('Error validating archive');
|
@@ -313,9 +309,8 @@ class DUP_DupArchive
|
|
313 |
return true;
|
314 |
}
|
315 |
|
316 |
-
if($expandState->isCriticalFailurePresent())
|
317 |
-
|
318 |
-
DUP_LOG::trace("c20");
|
319 |
// Fail immediately if critical failure present - even if havent completed processing the entire archive.
|
320 |
|
321 |
$error_message = __('Critical failure present in validation', 'duplicator');
|
@@ -326,7 +321,7 @@ class DUP_DupArchive
|
|
326 |
$buildProgress->set_failed($error_message);
|
327 |
return true;
|
328 |
} else if (!$expandState->working) {
|
329 |
-
|
330 |
|
331 |
$buildProgress->archive_built = true;
|
332 |
$buildProgress->retries = 0;
|
@@ -350,16 +345,17 @@ class DUP_DupArchive
|
|
350 |
|
351 |
$package->update();
|
352 |
|
353 |
-
|
354 |
$done = true;
|
355 |
} else {
|
356 |
-
|
357 |
$expandState->save();
|
358 |
-
|
359 |
}
|
360 |
}
|
361 |
}
|
362 |
-
}
|
|
|
363 |
// Have to have a catchall since the main system that calls this function is not prepared to handle exceptions
|
364 |
DUP_Log::trace('Top level create Exception:'.$ex->getMessage().':'.$ex->getTraceAsString());
|
365 |
//$buildProgress->failed = true;
|
@@ -371,4 +367,4 @@ class DUP_DupArchive
|
|
371 |
|
372 |
return $done;
|
373 |
}
|
374 |
-
}
|
1 |
<?php
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
|
|
3 |
|
4 |
+
//require_once (DUPLICATOR_PLUGIN_PATH.'classes/package/class.pack.archive.php');
|
5 |
//require_once (DUPLICATOR_PLUGIN_PATH.'classes/utilities/class.u.php');
|
6 |
require_once (DUPLICATOR_PLUGIN_PATH.'classes/package/duparchive/class.pack.archive.duparchive.state.expand.php');
|
7 |
require_once (DUPLICATOR_PLUGIN_PATH.'classes/package/duparchive/class.pack.archive.duparchive.state.create.php');
|
22 |
|
23 |
class DUP_DupArchive
|
24 |
{
|
25 |
+
|
26 |
// Using a worker time override since evidence shorter time works much
|
27 |
const WorkerTimeInSec = 10;
|
28 |
|
34 |
{
|
35 |
/* @var $buildProgress DUP_Build_Progress */
|
36 |
|
37 |
+
DUP_LOG::trace("start");
|
38 |
try {
|
39 |
DUP_Log::Open($package->NameHash);
|
40 |
+
DUP_Log::trace("c2");
|
41 |
+
|
42 |
if ($buildProgress->retries > DUPLICATOR_MAX_BUILD_RETRIES) {
|
43 |
+
DUP_LOG::trace("c3");
|
44 |
+
$error_msg = __('Package build appears stuck so marking package as failed. Is the Max Worker Time set too high?.', 'duplicator');
|
45 |
DUP_Log::error(esc_html__('Build Failure', 'duplicator'), esc_html($error_msg), Dup_ErrorBehavior::LogOnly);
|
46 |
//$buildProgress->failed = true;
|
47 |
$buildProgress->set_failed($error_msg);
|
48 |
+
$package->setStatus(DUP_PackageStatus::ERROR);
|
49 |
+
;
|
50 |
return true;
|
51 |
} else {
|
52 |
+
DUP_LOG::trace("c4");
|
53 |
// If all goes well retries will be reset to 0 at the end of this function.
|
54 |
$buildProgress->retries++;
|
55 |
$package->update();
|
56 |
}
|
57 |
|
58 |
+
$done = false;
|
59 |
|
60 |
+
DUP_LOG::trace("c5");
|
61 |
DupArchiveEngine::init(new DUP_DupArchive_Logger(), null, $archive);
|
62 |
|
63 |
+
DUP_LOG::trace("c6");
|
64 |
+
DUP_Package::safeTmpCleanup(true);
|
|
|
|
|
|
|
|
|
65 |
|
66 |
+
$compressDir = rtrim(DUP_Util::safePath($archive->PackDir), '/');
|
67 |
+
$sqlPath = DUP_Settings::getSsdirTmpPath()."/{$package->Database->File}";
|
68 |
+
$archivePath = DUP_Settings::getSsdirTmpPath()."/{$archive->File}";
|
69 |
+
$scanFilepath = DUP_Settings::getSsdirTmpPath()."/{$package->NameHash}_scan.json";
|
70 |
|
71 |
+
DUP_LOG::trace("c7");
|
72 |
$skipArchiveFinalization = false;
|
73 |
$json = '';
|
74 |
|
75 |
+
DUP_LOG::trace("c8");
|
76 |
if (file_exists($scanFilepath)) {
|
77 |
|
78 |
+
DUP_LOG::trace("c9");
|
79 |
$json = file_get_contents($scanFilepath);
|
80 |
|
81 |
if (empty($json)) {
|
82 |
+
DUP_LOG::trace("c10");
|
83 |
$errorText = __("Scan file $scanFilepath is empty!", 'duplicator');
|
84 |
+
$fixText = __("Click on \"Resolve This\" button to fix the JSON settings.", 'duplicator');
|
85 |
|
86 |
DUP_Log::Trace($errorText);
|
87 |
DUP_Log::error(esc_html($errorText)." **RECOMMENDATION: ".esc_html($fixText).".", '', Dup_ErrorBehavior::LogOnly);
|
92 |
return true;
|
93 |
}
|
94 |
} else {
|
95 |
+
DUP_LOG::trace("c11");
|
96 |
DUP_Log::trace("**** scan file $scanFilepath doesn't exist!!");
|
97 |
$errorMessage = sprintf(__("ERROR: Can't find Scanfile %s. Please ensure there no non-English characters in the package or schedule name.", 'duplicator'), $scanFilepath);
|
98 |
|
104 |
return true;
|
105 |
}
|
106 |
|
107 |
+
DUP_LOG::trace("c12");
|
108 |
Dup_Log::TraceObject("buildprogress object", $buildProgress, false);
|
109 |
|
110 |
$scanReport = json_decode($json);
|
111 |
|
112 |
if ($buildProgress->archive_started == false) {
|
113 |
|
114 |
+
$filterDirs = empty($archive->FilterDirs) ? 'not set' : $archive->FilterDirs;
|
115 |
+
$filterExts = empty($archive->FilterExts) ? 'not set' : $archive->FilterExts;
|
116 |
+
$filterFiles = empty($archive->FilterFiles) ? 'not set' : $archive->FilterFiles;
|
117 |
+
$filterOn = ($archive->FilterOn) ? 'ON' : 'OFF';
|
118 |
+
$filterDirsFormat = rtrim(str_replace(';', "\n\t", $filterDirs));
|
119 |
+
$filterFilesFormat = rtrim(str_replace(';', "\n\t", $filterFiles));
|
120 |
|
121 |
+
DUP_LOG::trace("c13");
|
122 |
DUP_Log::info("\n********************************************************************************");
|
123 |
DUP_Log::info("ARCHIVE Type=DUP Mode=DupArchive");
|
124 |
DUP_Log::info("********************************************************************************");
|
126 |
DUP_Log::info("ARCHIVE FILE: ".basename($archivePath));
|
127 |
DUP_Log::info("FILTERS: *{$filterOn}*");
|
128 |
DUP_Log::Info("DIRS:\n\t{$filterDirsFormat}");
|
129 |
+
DUP_Log::Info("FILES:\n\t{$filterFilesFormat}");
|
130 |
+
DUP_Log::info("EXTS: {$filterExts}");
|
131 |
|
132 |
DUP_Log::info("----------------------------------------");
|
133 |
DUP_Log::info("COMPRESSING");
|
145 |
}
|
146 |
|
147 |
try {
|
148 |
+
DupArchiveEngine::createArchive($archivePath, true);
|
149 |
$sql_ark_file_path = $package->getSqlArkFilePath();
|
150 |
DupArchiveEngine::addRelativeFileToArchiveST($archivePath, $sqlPath, $sql_ark_file_path);
|
151 |
+
}
|
152 |
+
catch (Exception $ex) {
|
153 |
$error_message = 'Error adding database.sql to archive';
|
154 |
|
155 |
DUP_Log::error($error_message, $ex->getMessage(), Dup_ErrorBehavior::LogOnly);
|
163 |
|
164 |
$buildProgress->retries = 0;
|
165 |
|
166 |
+
$createState = DUP_DupArchive_Create_State::createNew($archivePath, $compressDir, self::WorkerTimeInSec, true, true);
|
167 |
+
$createState->throttleDelayInUs = 0;
|
168 |
|
169 |
+
$createState->save();
|
170 |
|
171 |
$package->Update();
|
172 |
}
|
173 |
|
174 |
try {
|
175 |
|
176 |
+
DUP_LOG::trace("c14");
|
177 |
$createState = DUP_DupArchive_Create_State::get_instance();
|
178 |
+
|
179 |
+
if ($buildProgress->retries > 1) {
|
180 |
// Indicates it had problems before so move into robustness mode
|
181 |
$createState->isRobust = true;
|
182 |
+
|
183 |
$createState->save();
|
184 |
}
|
185 |
|
186 |
if ($createState->working) {
|
187 |
+
DUP_LOG::Trace("Create state is working");
|
188 |
//die(0);//rsr
|
|
|
189 |
// DupArchiveEngine::addItemsToArchive($createState, $scanReport->ARC, $archive);
|
190 |
DupArchiveEngine::addItemsToArchive($createState, $scanReport->ARC);
|
191 |
|
192 |
$buildProgress->set_build_failures($createState->failures);
|
193 |
|
194 |
+
if ($createState->isCriticalFailurePresent()) {
|
195 |
|
196 |
throw new Exception($createState->getFailureSummary());
|
197 |
}
|
215 |
}
|
216 |
}
|
217 |
catch (Exception $ex) {
|
218 |
+
DUP_LOG::trace("c15");
|
219 |
$message = __('Problem adding items to archive.', 'duplicator').' '.$ex->getMessage();
|
220 |
|
221 |
DUP_Log::Error(__('Problems adding items to archive.', 'duplicator'), $message, Dup_ErrorBehavior::LogOnly);
|
226 |
return true;
|
227 |
}
|
228 |
|
229 |
+
DUP_LOG::trace("c16");
|
230 |
|
231 |
//-- Final Wrapup of the Archive
|
232 |
if ((!$skipArchiveFinalization) && ($createState->working == false)) {
|
233 |
|
234 |
+
DUP_LOG::Trace("Create state is not working and not skip archive finalization");
|
235 |
|
236 |
+
DUP_LOG::trace("c17");
|
237 |
|
238 |
+
if (!$buildProgress->installer_built) {
|
239 |
|
240 |
+
if ($package->Installer->build($package, false)) {
|
|
|
241 |
$package->Runtime = -1;
|
242 |
$package->ExeSize = DUP_Util::byteSize($package->Installer->Size);
|
243 |
$package->ZipSize = DUP_Util::byteSize($package->Archive->Size);
|
244 |
$package->update();
|
245 |
+
} else {
|
|
|
|
|
246 |
$package->update();
|
247 |
return;
|
248 |
}
|
249 |
|
|
|
250 |
|
251 |
+
|
252 |
+
//rsr todo need this somewhere $package->buildCleanup();
|
253 |
|
254 |
DUP_Log::Trace("Installer has been built so running expand now");
|
255 |
|
256 |
+
$expandState = DUP_DupArchive_Expand_State::getInstance(true);
|
257 |
+
|
258 |
+
$expandState->archivePath = $archivePath;
|
259 |
+
$expandState->working = true;
|
260 |
+
$expandState->timeSliceInSecs = self::WorkerTimeInSec;
|
261 |
+
$expandState->basePath = DUP_Settings::getSsdirTmpPath().'/validate';
|
262 |
+
$expandState->throttleDelayInUs = 0; // RSR TODO
|
263 |
+
$expandState->validateOnly = true;
|
264 |
+
$expandState->validationType = DupArchiveValidationTypes::Standard;
|
265 |
+
$expandState->working = true;
|
266 |
+
$expandState->expectedDirectoryCount = count($scanReport->ARC->Dirs) - $createState->skippedDirectoryCount + $package->Installer->numDirsAdded;
|
267 |
+
$expandState->expectedFileCount = count($scanReport->ARC->Files) + 1 - $createState->skippedFileCount + $package->Installer->numFilesAdded; // database.sql will be in there
|
268 |
+
|
269 |
+
$expandState->save();
|
270 |
|
271 |
$sfc = count($scanReport->ARC->Files);
|
272 |
$nfa = $package->Installer->numFilesAdded;
|
273 |
Dup_Log::trace("####scan files {$sfc} skipped files {$createState->skippedFileCount} num files added {$nfa}");
|
274 |
+
DUP_LOG::traceObject("EXPAND STATE AFTER SAVE", $expandState);
|
275 |
+
} else {
|
|
|
276 |
|
277 |
+
DUP_LOG::trace("c18");
|
278 |
+
try {
|
279 |
|
280 |
+
$expandState = DUP_DupArchive_Expand_State::getInstance();
|
281 |
+
|
282 |
+
if ($buildProgress->retries > 1) {
|
283 |
|
284 |
// Indicates it had problems before so move into robustness mode
|
285 |
$expandState->isRobust = true;
|
286 |
+
|
287 |
$expandState->save();
|
288 |
}
|
289 |
|
292 |
DupArchiveEngine::expandArchive($expandState);
|
293 |
|
294 |
$buildProgress->set_validation_failures($expandState->failures);
|
295 |
+
|
296 |
$totalFileCount = count($scanReport->ARC->Files);
|
297 |
$archiveSize = @filesize($expandState->archivePath);
|
298 |
|
300 |
$expandState->archiveOffset);
|
301 |
DUP_LOG::TraceObject("package status after expand=", $package->Status);
|
302 |
DUP_LOG::Trace("archive size:{$archiveSize} expand offset:{$expandState->archiveOffset}");
|
303 |
+
}
|
304 |
+
catch (Exception $ex) {
|
305 |
DUP_Log::Trace('Exception:'.$ex->getMessage().':'.$ex->getTraceAsString());
|
306 |
//$buildProgress->failed = true;
|
307 |
$buildProgress->set_failed('Error validating archive');
|
309 |
return true;
|
310 |
}
|
311 |
|
312 |
+
if ($expandState->isCriticalFailurePresent()) {
|
313 |
+
DUP_LOG::trace("c20");
|
|
|
314 |
// Fail immediately if critical failure present - even if havent completed processing the entire archive.
|
315 |
|
316 |
$error_message = __('Critical failure present in validation', 'duplicator');
|
321 |
$buildProgress->set_failed($error_message);
|
322 |
return true;
|
323 |
} else if (!$expandState->working) {
|
324 |
+
DUP_LOG::trace("c21");
|
325 |
|
326 |
$buildProgress->archive_built = true;
|
327 |
$buildProgress->retries = 0;
|
345 |
|
346 |
$package->update();
|
347 |
|
348 |
+
DUP_LOG::trace("c22");
|
349 |
$done = true;
|
350 |
} else {
|
351 |
+
DUP_LOG::trace("c23");
|
352 |
$expandState->save();
|
353 |
+
DUP_LOG::trace("c24");
|
354 |
}
|
355 |
}
|
356 |
}
|
357 |
+
}
|
358 |
+
catch (Exception $ex) {
|
359 |
// Have to have a catchall since the main system that calls this function is not prepared to handle exceptions
|
360 |
DUP_Log::trace('Top level create Exception:'.$ex->getMessage().':'.$ex->getTraceAsString());
|
361 |
//$buildProgress->failed = true;
|
367 |
|
368 |
return $done;
|
369 |
}
|
370 |
+
}
|
classes/ui/class.ui.notice.php
CHANGED
@@ -19,8 +19,9 @@ if (!defined('DUPLICATOR_VERSION'))
|
|
19 |
class DUP_UI_Notice
|
20 |
{
|
21 |
|
22 |
-
const OPTION_KEY_INSTALLER_HASH_NOTICE
|
23 |
-
const
|
|
|
24 |
|
25 |
/**
|
26 |
* init notice actions
|
@@ -31,7 +32,10 @@ class DUP_UI_Notice
|
|
31 |
'showReservedFilesNotice',
|
32 |
'installAutoDeactivatePlugins',
|
33 |
'showFeedBackNotice',
|
34 |
-
|
|
|
|
|
|
|
35 |
);
|
36 |
foreach ($methods as $method) {
|
37 |
add_action('admin_notices', array(__CLASS__, $method));
|
@@ -49,11 +53,13 @@ class DUP_UI_Notice
|
|
49 |
return;
|
50 |
}
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
57 |
}
|
58 |
|
59 |
if (DUP_Settings::get('installer_name_mode') == DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH) {
|
@@ -67,7 +73,48 @@ class DUP_UI_Notice
|
|
67 |
<?php esc_html_e('After this option is enabled, a security hash will be added to the name of the installer when it\'s downloaded.', 'duplicator'); ?>
|
68 |
</p>
|
69 |
<p>
|
70 |
-
<?php echo sprintf(__('To enable this option or to get more information, open the <a href="%s">Package Settings</a> and visit the Installer section.', 'duplicator'), 'admin.php?page=duplicator-settings&tab=package#installer-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
</p>
|
72 |
</div>
|
73 |
<?php
|
@@ -153,7 +200,7 @@ class DUP_UI_Notice
|
|
153 |
*/
|
154 |
public static function installAutoDeactivatePlugins()
|
155 |
{
|
156 |
-
$reactivatePluginsAfterInstallation = get_option(self::
|
157 |
if (is_array($reactivatePluginsAfterInstallation)) {
|
158 |
$installedPlugins = array_keys(get_plugins());
|
159 |
$shouldBeActivated = array();
|
@@ -164,7 +211,7 @@ class DUP_UI_Notice
|
|
164 |
}
|
165 |
|
166 |
if (empty($shouldBeActivated)) {
|
167 |
-
delete_option(self::
|
168 |
} else {
|
169 |
$activatePluginsAnchors = array();
|
170 |
foreach ($shouldBeActivated as $slug => $title) {
|
@@ -176,7 +223,7 @@ class DUP_UI_Notice
|
|
176 |
}
|
177 |
?>
|
178 |
<div class="update-nag duplicator-plugin-activation-admin-notice notice notice-warning duplicator-admin-notice is-dismissible"
|
179 |
-
data-to-dismiss="<?php echo esc_attr(self::
|
180 |
<p>
|
181 |
<?php
|
182 |
echo "<b>".esc_html__("Warning!", "duplicator")."</b> ".esc_html__("Migration Almost Complete!", "duplicator")." <br/>";
|
19 |
class DUP_UI_Notice
|
20 |
{
|
21 |
|
22 |
+
const OPTION_KEY_INSTALLER_HASH_NOTICE = 'duplicator_lite_inst_hash_notice';
|
23 |
+
const OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL = 'duplicator_reactivate_plugins_after_installation';
|
24 |
+
const OPTION_KEY_NEW_STORAGE_POSITION = 'duplicator_new_storage_position';
|
25 |
|
26 |
/**
|
27 |
* init notice actions
|
32 |
'showReservedFilesNotice',
|
33 |
'installAutoDeactivatePlugins',
|
34 |
'showFeedBackNotice',
|
35 |
+
//Disalbe in 1.3.38
|
36 |
+
'newInstallerHashOption',
|
37 |
+
//Enable in 1.3.38
|
38 |
+
//'newStoragePositionOption'
|
39 |
);
|
40 |
foreach ($methods as $method) {
|
41 |
add_action('admin_notices', array(__CLASS__, $method));
|
53 |
return;
|
54 |
}
|
55 |
|
56 |
+
if ($screen->id == 'duplicator_page_duplicator-settings') {
|
57 |
+
$action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
|
58 |
+
$installerMode = filter_input(INPUT_POST, 'installer_name_mode', FILTER_SANITIZE_STRING);
|
59 |
+
if ($action == 'save' && $installerMode == DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH) {
|
60 |
+
delete_option(self::OPTION_KEY_INSTALLER_HASH_NOTICE);
|
61 |
+
return;
|
62 |
+
}
|
63 |
}
|
64 |
|
65 |
if (DUP_Settings::get('installer_name_mode') == DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH) {
|
73 |
<?php esc_html_e('After this option is enabled, a security hash will be added to the name of the installer when it\'s downloaded.', 'duplicator'); ?>
|
74 |
</p>
|
75 |
<p>
|
76 |
+
<?php echo sprintf(__('To enable this option or to get more information, open the <a href="%s">Package Settings</a> and visit the Installer section.', 'duplicator'), 'admin.php?page=duplicator-settings&tab=package#duplicator-installer-settings'); ?>
|
77 |
+
</p>
|
78 |
+
</div>
|
79 |
+
<?php
|
80 |
+
}
|
81 |
+
|
82 |
+
public static function newStoragePositionOption()
|
83 |
+
{
|
84 |
+
if (get_option(self::OPTION_KEY_NEW_STORAGE_POSITION) != true) {
|
85 |
+
return;
|
86 |
+
}
|
87 |
+
|
88 |
+
$screen = get_current_screen();
|
89 |
+
if (!in_array($screen->parent_base, array('plugins', 'duplicator'))) {
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
|
93 |
+
if ($screen->id == 'duplicator_page_duplicator-settings') {
|
94 |
+
$action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
|
95 |
+
$storagePostion = filter_input(INPUT_POST, 'storage_position', FILTER_SANITIZE_STRING);
|
96 |
+
if ($action == 'save' && $storagePostion == DUP_Settings::STORAGE_POSITION_WP_CONTENT) {
|
97 |
+
delete_option(self::OPTION_KEY_INSTALLER_HASH_NOTICE);
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
if (DUP_Settings::get('storage_position') == DUP_Settings::STORAGE_POSITION_WP_CONTENT) {
|
103 |
+
delete_option(self::OPTION_KEY_NEW_STORAGE_POSITION);
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
?>
|
107 |
+
<div class="notice notice-success duplicator-admin-notice is-dismissible" data-to-dismiss="<?php echo esc_attr(self::OPTION_KEY_NEW_STORAGE_POSITION); ?>" >
|
108 |
+
<p>
|
109 |
+
<?php esc_html_e('Duplicator can now have a new storage location inside the wp-content folder.', 'duplicator'); ?><br>
|
110 |
+
<?php
|
111 |
+
echo sprintf(__('If this option is enabled all packages will be moved from <i>%s</i> to <i>%s</i>', 'duplicator'),
|
112 |
+
esc_html(DUP_Settings::getSsdirPathLegacy()),
|
113 |
+
esc_html(DUP_Settings::getSsdirPathWpCont()));
|
114 |
+
?>
|
115 |
+
</p>
|
116 |
+
<p>
|
117 |
+
<?php echo sprintf(__('To enable this option or to get more information, open the <a href="%s">General Settings</a>', 'duplicator'), 'admin.php?page=duplicator-settings'); ?>
|
118 |
</p>
|
119 |
</div>
|
120 |
<?php
|
200 |
*/
|
201 |
public static function installAutoDeactivatePlugins()
|
202 |
{
|
203 |
+
$reactivatePluginsAfterInstallation = get_option(self::OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL, false);
|
204 |
if (is_array($reactivatePluginsAfterInstallation)) {
|
205 |
$installedPlugins = array_keys(get_plugins());
|
206 |
$shouldBeActivated = array();
|
211 |
}
|
212 |
|
213 |
if (empty($shouldBeActivated)) {
|
214 |
+
delete_option(self::OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL);
|
215 |
} else {
|
216 |
$activatePluginsAnchors = array();
|
217 |
foreach ($shouldBeActivated as $slug => $title) {
|
223 |
}
|
224 |
?>
|
225 |
<div class="update-nag duplicator-plugin-activation-admin-notice notice notice-warning duplicator-admin-notice is-dismissible"
|
226 |
+
data-to-dismiss="<?php echo esc_attr(self::OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL); ?>" >
|
227 |
<p>
|
228 |
<?php
|
229 |
echo "<b>".esc_html__("Warning!", "duplicator")."</b> ".esc_html__("Migration Almost Complete!", "duplicator")." <br/>";
|
classes/utilities/class.u.php
CHANGED
@@ -176,16 +176,6 @@ class DUP_Util
|
|
176 |
return defined('WP_DEBUG') && WP_DEBUG;
|
177 |
}
|
178 |
|
179 |
-
/**
|
180 |
-
* Returns the wp-snapshot URL
|
181 |
-
*
|
182 |
-
* @return string The full URL of the duplicators snapshot storage directory
|
183 |
-
*/
|
184 |
-
public static function snapshotURL()
|
185 |
-
{
|
186 |
-
return get_site_url(null, '', is_ssl() ? 'https' : 'http').'/'.DUPLICATOR_SSDIR_NAME.'/';
|
187 |
-
}
|
188 |
-
|
189 |
/**
|
190 |
* Returns the last N lines of a file. Equivalent to tail command
|
191 |
*
|
@@ -420,25 +410,25 @@ class DUP_Util
|
|
420 |
*/
|
421 |
public static function hasShellExec()
|
422 |
{
|
423 |
-
$cmds = array('shell_exec', 'escapeshellarg', 'escapeshellcmd', 'extension_loaded'
|
424 |
|
425 |
//Function disabled at server level
|
426 |
if (array_intersect($cmds, array_map('trim', explode(',', @ini_get('disable_functions')))))
|
427 |
-
return false;
|
428 |
|
429 |
//Suhosin: http://www.hardened-php.net/suhosin/
|
430 |
//Will cause PHP to silently fail
|
431 |
if (extension_loaded('suhosin')) {
|
432 |
$suhosin_ini = @ini_get("suhosin.executor.func.blacklist");
|
433 |
if (array_intersect($cmds, array_map('trim', explode(',', $suhosin_ini))))
|
434 |
-
return false;
|
435 |
}
|
436 |
|
437 |
// Can we issue a simple echo command?
|
438 |
if (!@shell_exec('echo duplicator'))
|
439 |
-
return false;
|
440 |
|
441 |
-
return true;
|
442 |
}
|
443 |
|
444 |
/**
|
@@ -562,12 +552,14 @@ class DUP_Util
|
|
562 |
/**
|
563 |
* Creates the snapshot directory if it doesn't already exist
|
564 |
*
|
565 |
-
* @return
|
566 |
*/
|
567 |
public static function initSnapshotDirectory()
|
568 |
{
|
|
|
|
|
569 |
$path_wproot = duplicator_get_abs_path();
|
570 |
-
$path_ssdir =
|
571 |
$path_plugin = DUP_Util::safePath(DUPLICATOR_PLUGIN_PATH);
|
572 |
|
573 |
if (!file_exists($path_ssdir)) {
|
@@ -579,14 +571,21 @@ class DUP_Util
|
|
579 |
DupLiteSnapLibIOU::chmod($path_wproot, 'u+rwx');
|
580 |
|
581 |
//snapshot directory
|
582 |
-
DupLiteSnapLibIOU::dirWriteCheckOrMkdir($path_ssdir, 'u+rwx,go+rx')
|
|
|
|
|
583 |
|
584 |
// restore original root perms
|
585 |
DupLiteSnapLibIOU::chmod($path_wproot, $old_root_perm);
|
|
|
|
|
|
|
|
|
586 |
}
|
587 |
|
588 |
DupLiteSnapLibIOU::chmod($path_ssdir, 'u+rwx,go+rx');
|
589 |
-
|
|
|
590 |
|
591 |
//plugins dir/files
|
592 |
DupLiteSnapLibIOU::dirWriteCheckOrMkdir($path_plugin.'files', 'u+rwx');
|
@@ -618,9 +617,14 @@ class DUP_Util
|
|
618 |
$fileName = $path_ssdir.'/robots.txt';
|
619 |
if (!file_exists($fileName)) {
|
620 |
$robotfile = @fopen($fileName, 'w');
|
621 |
-
@fwrite($robotfile,
|
|
|
|
|
|
|
622 |
@fclose($robotfile);
|
623 |
}
|
|
|
|
|
624 |
}
|
625 |
|
626 |
/**
|
176 |
return defined('WP_DEBUG') && WP_DEBUG;
|
177 |
}
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
/**
|
180 |
* Returns the last N lines of a file. Equivalent to tail command
|
181 |
*
|
410 |
*/
|
411 |
public static function hasShellExec()
|
412 |
{
|
413 |
+
$cmds = array('shell_exec', 'escapeshellarg', 'escapeshellcmd', 'extension_loaded');
|
414 |
|
415 |
//Function disabled at server level
|
416 |
if (array_intersect($cmds, array_map('trim', explode(',', @ini_get('disable_functions')))))
|
417 |
+
return apply_filters('duplicator_is_shellzip_available', false);
|
418 |
|
419 |
//Suhosin: http://www.hardened-php.net/suhosin/
|
420 |
//Will cause PHP to silently fail
|
421 |
if (extension_loaded('suhosin')) {
|
422 |
$suhosin_ini = @ini_get("suhosin.executor.func.blacklist");
|
423 |
if (array_intersect($cmds, array_map('trim', explode(',', $suhosin_ini))))
|
424 |
+
return apply_filters('duplicator_is_shellzip_available', false);
|
425 |
}
|
426 |
|
427 |
// Can we issue a simple echo command?
|
428 |
if (!@shell_exec('echo duplicator'))
|
429 |
+
return apply_filters('duplicator_is_shellzip_available', false);
|
430 |
|
431 |
+
return apply_filters('duplicator_is_shellzip_available', true);
|
432 |
}
|
433 |
|
434 |
/**
|
552 |
/**
|
553 |
* Creates the snapshot directory if it doesn't already exist
|
554 |
*
|
555 |
+
* @return bool
|
556 |
*/
|
557 |
public static function initSnapshotDirectory()
|
558 |
{
|
559 |
+
$error = false;
|
560 |
+
|
561 |
$path_wproot = duplicator_get_abs_path();
|
562 |
+
$path_ssdir = DUP_Settings::getSsdirPath();
|
563 |
$path_plugin = DUP_Util::safePath(DUPLICATOR_PLUGIN_PATH);
|
564 |
|
565 |
if (!file_exists($path_ssdir)) {
|
571 |
DupLiteSnapLibIOU::chmod($path_wproot, 'u+rwx');
|
572 |
|
573 |
//snapshot directory
|
574 |
+
if (DupLiteSnapLibIOU::dirWriteCheckOrMkdir($path_ssdir, 'u+rwx,go+rx') == false) {
|
575 |
+
$error = true;
|
576 |
+
}
|
577 |
|
578 |
// restore original root perms
|
579 |
DupLiteSnapLibIOU::chmod($path_wproot, $old_root_perm);
|
580 |
+
|
581 |
+
if ($error) {
|
582 |
+
return false;
|
583 |
+
}
|
584 |
}
|
585 |
|
586 |
DupLiteSnapLibIOU::chmod($path_ssdir, 'u+rwx,go+rx');
|
587 |
+
|
588 |
+
DupLiteSnapLibIOU::dirWriteCheckOrMkdir(DUP_Settings::getSsdirTmpPath(), 'u+rwx');
|
589 |
|
590 |
//plugins dir/files
|
591 |
DupLiteSnapLibIOU::dirWriteCheckOrMkdir($path_plugin.'files', 'u+rwx');
|
617 |
$fileName = $path_ssdir.'/robots.txt';
|
618 |
if (!file_exists($fileName)) {
|
619 |
$robotfile = @fopen($fileName, 'w');
|
620 |
+
@fwrite($robotfile,
|
621 |
+
"User-agent: * \n"
|
622 |
+
."Disallow: /".DUP_Settings::SSDIR_NAME_LEGACY."/\n"
|
623 |
+
."Disallow: /".DUP_Settings::SSDIR_NAME_NEW."/");
|
624 |
@fclose($robotfile);
|
625 |
}
|
626 |
+
|
627 |
+
return true;
|
628 |
}
|
629 |
|
630 |
/**
|
classes/utilities/class.u.shell.php
CHANGED
@@ -39,7 +39,7 @@ class DUP_Shell_U
|
|
39 |
$ret = true;
|
40 |
}
|
41 |
|
42 |
-
$ret = apply_filters('
|
43 |
return $ret;
|
44 |
}
|
45 |
}
|
39 |
$ret = true;
|
40 |
}
|
41 |
|
42 |
+
$ret = apply_filters('duplicator_is_popen_enabled', $ret);
|
43 |
return $ret;
|
44 |
}
|
45 |
}
|
ctrls/class.web.services.php
CHANGED
@@ -12,8 +12,7 @@ class DUP_Web_Services
|
|
12 |
add_action('wp_ajax_duplicator_reset_all_settings', array(__CLASS__, 'ajax_reset_all'));
|
13 |
add_action('wp_ajax_duplicator_set_admin_notice_viewed', array(__CLASS__, 'set_admin_notice_viewed'));
|
14 |
add_action('wp_ajax_duplicator_admin_notice_to_dismiss', array(__CLASS__, 'admin_notice_to_dismiss'));
|
15 |
-
add_action('
|
16 |
-
add_action('wp_ajax_nopriv_duplicator_download', array(__CLASS__, 'duplicator_download'));
|
17 |
}
|
18 |
|
19 |
/**
|
@@ -85,80 +84,91 @@ class DUP_Web_Services
|
|
85 |
}
|
86 |
}
|
87 |
|
88 |
-
public static function
|
89 |
{
|
90 |
-
|
91 |
-
|
92 |
-
$
|
93 |
-
$
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
}
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
break;
|
112 |
-
case 'archive':
|
113 |
-
$format = strtolower($package->Archive->Format);
|
114 |
-
$fileName = "{$package->NameHash}_archive.{$format}";
|
115 |
-
break;
|
116 |
-
case 'installer':
|
117 |
-
$fileName = $package->NameHash.'_installer.php';
|
118 |
-
break;
|
119 |
-
default:
|
120 |
-
$error = true;
|
121 |
-
}
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
126 |
|
127 |
// Process download
|
128 |
-
if (file_exists($filepath)) {
|
129 |
-
|
130 |
-
|
131 |
-
@ob_clean();
|
132 |
-
}
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
}
|
153 |
-
|
154 |
-
|
155 |
}
|
156 |
-
|
157 |
-
} else {
|
158 |
-
// if the request is wrong wait to avoid brute force attack
|
159 |
-
sleep(2);
|
160 |
-
wp_die('Invalid request');
|
161 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
}
|
163 |
}
|
164 |
|
@@ -200,7 +210,8 @@ class DUP_Web_Services
|
|
200 |
$noticeToDismiss = filter_input(INPUT_POST, 'notice', FILTER_SANITIZE_STRING);
|
201 |
switch ($noticeToDismiss) {
|
202 |
case DUP_UI_Notice::OPTION_KEY_INSTALLER_HASH_NOTICE:
|
203 |
-
case DUP_UI_Notice::
|
|
|
204 |
delete_option($noticeToDismiss);
|
205 |
break;
|
206 |
default:
|
@@ -213,4 +224,4 @@ class DUP_Web_Services
|
|
213 |
|
214 |
wp_send_json_success();
|
215 |
}
|
216 |
-
}
|
12 |
add_action('wp_ajax_duplicator_reset_all_settings', array(__CLASS__, 'ajax_reset_all'));
|
13 |
add_action('wp_ajax_duplicator_set_admin_notice_viewed', array(__CLASS__, 'set_admin_notice_viewed'));
|
14 |
add_action('wp_ajax_duplicator_admin_notice_to_dismiss', array(__CLASS__, 'admin_notice_to_dismiss'));
|
15 |
+
add_action('wp_ajax_duplicator_download_installer', array(__CLASS__, 'duplicator_download_installer'));
|
|
|
16 |
}
|
17 |
|
18 |
/**
|
84 |
}
|
85 |
}
|
86 |
|
87 |
+
public static function duplicator_download_installer()
|
88 |
{
|
89 |
+
check_ajax_referer('duplicator_download_installer', 'nonce');
|
90 |
+
|
91 |
+
$isValid = true;
|
92 |
+
$inputData = filter_input_array(INPUT_GET, array(
|
93 |
+
'id' => array(
|
94 |
+
'filter' => FILTER_VALIDATE_INT,
|
95 |
+
'flags' => FILTER_REQUIRE_SCALAR,
|
96 |
+
'options' => array(
|
97 |
+
'default' => false
|
98 |
+
)
|
99 |
+
),
|
100 |
+
'hash' => array(
|
101 |
+
'filter' => FILTER_SANITIZE_STRING,
|
102 |
+
'flags' => FILTER_REQUIRE_SCALAR,
|
103 |
+
'options' => array(
|
104 |
+
'default' => false
|
105 |
+
)
|
106 |
+
)
|
107 |
+
));
|
108 |
+
|
109 |
+
$packageId = $inputData['id'];
|
110 |
+
$hash = $inputData['hash'];
|
111 |
+
|
112 |
+
if (!$packageId || !$hash) {
|
113 |
+
$isValid = false;
|
114 |
}
|
115 |
|
116 |
+
try {
|
117 |
+
DUP_Util::hasCapability('export', DUP_Util::SECURE_ISSUE_THROW);
|
|
|
118 |
|
119 |
+
if (!$isValid) {
|
120 |
+
throw new Exception(__("Invalid request"));
|
121 |
+
}
|
122 |
|
123 |
+
if (($package = DUP_Package::getByID($packageId)) == null) {
|
124 |
+
throw new Exception(__("Invalid request."));
|
125 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
+
if ($hash !== $package->Hash) {
|
128 |
+
throw new Exception(__("Invalid request."));
|
129 |
+
}
|
130 |
+
|
131 |
+
$fileName = $package->getInstDownloadName();
|
132 |
+
$filepath = DUP_Settings::getSsdirPath().'/'.$package->Installer->File;
|
133 |
|
134 |
// Process download
|
135 |
+
if (!file_exists($filepath)) {
|
136 |
+
throw new Exception(__("Invalid request."));
|
137 |
+
}
|
|
|
|
|
138 |
|
139 |
+
// Clean output buffer
|
140 |
+
if (ob_get_level() !== 0 && @ob_end_clean() === FALSE) {
|
141 |
+
@ob_clean();
|
142 |
+
}
|
143 |
+
|
144 |
+
header('Content-Description: File Transfer');
|
145 |
+
header('Content-Type: application/octet-stream');
|
146 |
+
header('Content-Disposition: attachment; filename="'.$fileName.'"');
|
147 |
+
header('Expires: 0');
|
148 |
+
header('Cache-Control: must-revalidate');
|
149 |
+
header('Pragma: public');
|
150 |
+
header('Content-Length: '.filesize($filepath));
|
151 |
+
flush(); // Flush system output buffer
|
152 |
+
|
153 |
+
try {
|
154 |
+
$fp = @fopen($filepath, 'r');
|
155 |
+
if (false === $fp) {
|
156 |
+
throw new Exception('Fail to open the file '.$filepath);
|
157 |
}
|
158 |
+
while (!feof($fp) && ($data = fread($fp, DUPLICATOR_BUFFER_READ_WRITE_SIZE)) !== FALSE) {
|
159 |
+
echo $data;
|
160 |
}
|
161 |
+
@fclose($fp);
|
|
|
|
|
|
|
|
|
162 |
}
|
163 |
+
catch (Exception $e) {
|
164 |
+
readfile($filepath);
|
165 |
+
}
|
166 |
+
exit;
|
167 |
+
}
|
168 |
+
catch (Exception $ex) {
|
169 |
+
//Prevent brute force
|
170 |
+
sleep(2);
|
171 |
+
wp_die($ex->getMessage());
|
172 |
}
|
173 |
}
|
174 |
|
210 |
$noticeToDismiss = filter_input(INPUT_POST, 'notice', FILTER_SANITIZE_STRING);
|
211 |
switch ($noticeToDismiss) {
|
212 |
case DUP_UI_Notice::OPTION_KEY_INSTALLER_HASH_NOTICE:
|
213 |
+
case DUP_UI_Notice::OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL:
|
214 |
+
case DUP_UI_Notice::OPTION_KEY_NEW_STORAGE_POSITION:
|
215 |
delete_option($noticeToDismiss);
|
216 |
break;
|
217 |
default:
|
224 |
|
225 |
wp_send_json_success();
|
226 |
}
|
227 |
+
}
|
ctrls/ctrl.package.php
CHANGED
@@ -90,7 +90,7 @@ function duplicator_package_build()
|
|
90 |
DUP_Settings::Set('active_package_id', $Package->ID);
|
91 |
DUP_Settings::Save();
|
92 |
|
93 |
-
if (!is_readable(
|
94 |
die("The scan result file was not found. Please run the scan step before building the package.");
|
95 |
}
|
96 |
|
@@ -169,7 +169,7 @@ function duplicator_duparchive_package_build()
|
|
169 |
// DUP_Log::TraceObject("getting active package by id {$active_package_id}", $package);
|
170 |
}
|
171 |
|
172 |
-
if (!is_readable(
|
173 |
DUP_Log::Info('[CTRL DUP ARCIVE] ERROR: The scan result file was not found. Please run the scan step before building the package.');
|
174 |
die("The scan result file was not found. Please run the scan step before building the package.");
|
175 |
}
|
@@ -287,20 +287,20 @@ function duplicator_package_delete()
|
|
287 |
$delResult = $wpdb->query($wpdb->prepare("DELETE FROM `{$tblName}` WHERE id = %d", $id));
|
288 |
if ($delResult != 0) {
|
289 |
//TMP FILES
|
290 |
-
$globTmpFiles = glob(
|
291 |
foreach ($globTmpFiles as $globTmpFile) {
|
292 |
_unlinkFile($globTmpFile);
|
293 |
}
|
294 |
|
295 |
//WP-SNAPSHOT FILES
|
296 |
-
$globSnapshotFiles = glob(
|
297 |
foreach ($globSnapshotFiles as $globSnapshotFile) {
|
298 |
_unlinkFile($globSnapshotFile);
|
299 |
}
|
300 |
-
// _unlinkFile(
|
301 |
//Unfinished Zip files
|
302 |
/*
|
303 |
-
$tmpZip =
|
304 |
if ($tmpZip !== false) {
|
305 |
array_map('unlink', glob($tmpZip));
|
306 |
}
|
@@ -448,105 +448,6 @@ class DUP_CTRL_Package extends DUP_CTRL_Base
|
|
448 |
}
|
449 |
}
|
450 |
|
451 |
-
/**
|
452 |
-
* Download the requested package file
|
453 |
-
*
|
454 |
-
* @param string $_POST['which']
|
455 |
-
* @param string $_POST['package_id']
|
456 |
-
*
|
457 |
-
* @return downloadable file
|
458 |
-
*/
|
459 |
-
function getPackageFile($post)
|
460 |
-
{
|
461 |
-
DUP_Handler::init_error_handler();
|
462 |
-
|
463 |
-
check_ajax_referer('DUP_CTRL_Package_getPackageFile', 'nonce');
|
464 |
-
DUP_Util::hasCapability('export');
|
465 |
-
$params = $this->postParamMerge($post);
|
466 |
-
|
467 |
-
$params = $this->getParamMerge($params);
|
468 |
-
$result = new DUP_CTRL_Result($this);
|
469 |
-
|
470 |
-
try {
|
471 |
-
//CONTROLLER LOGIC
|
472 |
-
$request = stripslashes_deep($_REQUEST);
|
473 |
-
$which = (int) $request['which'];
|
474 |
-
$packageId = (int) $request['package_id'];
|
475 |
-
$package = DUP_Package::getByID($packageId);
|
476 |
-
$isBinary = ($which != DUP_PackageFileType::Log);
|
477 |
-
$filePath = $package->getLocalPackageFile($which);
|
478 |
-
|
479 |
-
//OUTPUT: Installer, Archive, SQL File
|
480 |
-
if ($isBinary) {
|
481 |
-
@session_write_close();
|
482 |
-
// @ob_flush();
|
483 |
-
//flush seems to cause issues on some PHP version where the download prompt
|
484 |
-
//is no longer called but the contents of the installer are dumped to the browser.
|
485 |
-
//@flush();
|
486 |
-
|
487 |
-
header("Pragma: public");
|
488 |
-
header("Expires: 0");
|
489 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
490 |
-
header("Cache-Control: private", false);
|
491 |
-
header("Content-Transfer-Encoding: binary");
|
492 |
-
|
493 |
-
if ($filePath != null) {
|
494 |
-
$fp = fopen($filePath, 'rb');
|
495 |
-
if ($fp !== false) {
|
496 |
-
if ($which == DUP_PackageFileType::Installer) {
|
497 |
-
$fileName = $package->getInstDownloadName();
|
498 |
-
} else {
|
499 |
-
$fileName = basename($filePath);
|
500 |
-
}
|
501 |
-
|
502 |
-
header("Content-Type: application/octet-stream");
|
503 |
-
header("Content-Disposition: attachment; filename=\"{$fileName}\";");
|
504 |
-
|
505 |
-
DUP_LOG::trace("streaming $filePath");
|
506 |
-
|
507 |
-
while (!feof($fp)) {
|
508 |
-
$buffer = fread($fp, 2048);
|
509 |
-
print $buffer;
|
510 |
-
}
|
511 |
-
|
512 |
-
fclose($fp);
|
513 |
-
exit;
|
514 |
-
} else {
|
515 |
-
header("Content-Type: text/plain");
|
516 |
-
header("Content-Disposition: attachment; filename=\"error.txt\";");
|
517 |
-
$message = "Couldn't open $filePath.";
|
518 |
-
DUP_Log::Trace($message);
|
519 |
-
echo esc_html($message);
|
520 |
-
}
|
521 |
-
} else {
|
522 |
-
$message = __("Couldn't find a local copy of the file requested.", 'duplicator');
|
523 |
-
|
524 |
-
header("Content-Type: text/plain");
|
525 |
-
header("Content-Disposition: attachment; filename=\"error.txt\";");
|
526 |
-
|
527 |
-
// Report that we couldn't find the file
|
528 |
-
DUP_Log::Trace($message);
|
529 |
-
echo esc_html($message);
|
530 |
-
}
|
531 |
-
|
532 |
-
//OUTPUT: Log File
|
533 |
-
} else {
|
534 |
-
if ($filePath != null) {
|
535 |
-
header("Content-Type: text/plain");
|
536 |
-
$text = file_get_contents($filePath);
|
537 |
-
|
538 |
-
die($text);
|
539 |
-
} else {
|
540 |
-
$message = __("Couldn't find a local copy of the file requested.", 'duplicator');
|
541 |
-
echo esc_html($message);
|
542 |
-
}
|
543 |
-
}
|
544 |
-
}
|
545 |
-
catch (Exception $exc) {
|
546 |
-
$result->processError($exc);
|
547 |
-
}
|
548 |
-
}
|
549 |
-
|
550 |
/**
|
551 |
* Get active package status
|
552 |
*
|
90 |
DUP_Settings::Set('active_package_id', $Package->ID);
|
91 |
DUP_Settings::Save();
|
92 |
|
93 |
+
if (!is_readable(DUP_Settings::getSsdirTmpPath()."/{$Package->ScanFile}")) {
|
94 |
die("The scan result file was not found. Please run the scan step before building the package.");
|
95 |
}
|
96 |
|
169 |
// DUP_Log::TraceObject("getting active package by id {$active_package_id}", $package);
|
170 |
}
|
171 |
|
172 |
+
if (!is_readable(DUP_Settings::getSsdirTmpPath()."/{$package->ScanFile}")) {
|
173 |
DUP_Log::Info('[CTRL DUP ARCIVE] ERROR: The scan result file was not found. Please run the scan step before building the package.');
|
174 |
die("The scan result file was not found. Please run the scan step before building the package.");
|
175 |
}
|
287 |
$delResult = $wpdb->query($wpdb->prepare("DELETE FROM `{$tblName}` WHERE id = %d", $id));
|
288 |
if ($delResult != 0) {
|
289 |
//TMP FILES
|
290 |
+
$globTmpFiles = glob(DUP_Settings::getSsdirTmpPath()."/{$nameHash}*");
|
291 |
foreach ($globTmpFiles as $globTmpFile) {
|
292 |
_unlinkFile($globTmpFile);
|
293 |
}
|
294 |
|
295 |
//WP-SNAPSHOT FILES
|
296 |
+
$globSnapshotFiles = glob(DUP_Settings::getSsdirPath()."/{$nameHash}*");
|
297 |
foreach ($globSnapshotFiles as $globSnapshotFile) {
|
298 |
_unlinkFile($globSnapshotFile);
|
299 |
}
|
300 |
+
// _unlinkFile(DUP_Settings::getSsdirPath()."/{$nameHash}.log");
|
301 |
//Unfinished Zip files
|
302 |
/*
|
303 |
+
$tmpZip = DUP_Settings::getSsdirTmpPath()."/{$nameHash}_archive.zip.*";
|
304 |
if ($tmpZip !== false) {
|
305 |
array_map('unlink', glob($tmpZip));
|
306 |
}
|
448 |
}
|
449 |
}
|
450 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
/**
|
452 |
* Get active package status
|
453 |
*
|
ctrls/ctrl.tools.php
CHANGED
@@ -77,7 +77,7 @@ class DUP_CTRL_Tools extends DUP_CTRL_Base
|
|
77 |
|
78 |
$file_path = DUP_Log::GetTraceFilepath();
|
79 |
$backup_path = DUP_Log::GetBackupTraceFilepath();
|
80 |
-
$zip_path =
|
81 |
$zipped = DUP_Zip_U::zipFile($file_path, $zip_path, true, null, true);
|
82 |
|
83 |
if ($zipped && file_exists($backup_path)) {
|
77 |
|
78 |
$file_path = DUP_Log::GetTraceFilepath();
|
79 |
$backup_path = DUP_Log::GetBackupTraceFilepath();
|
80 |
+
$zip_path = DUP_Settings::getSsdirPath()."/".DUPLICATOR_ZIPPED_LOG_FILENAME;
|
81 |
$zipped = DUP_Zip_U::zipFile($file_path, $zip_path, true, null, true);
|
82 |
|
83 |
if ($zipped && file_exists($backup_path)) {
|
define.php
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
<?php
|
|
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
3 |
|
4 |
-
|
5 |
if (function_exists('plugin_dir_url'))
|
6 |
{
|
7 |
-
define('DUPLICATOR_VERSION', '1.3.
|
8 |
-
define('DUPLICATOR_VERSION_BUILD', '2020-
|
9 |
define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
|
10 |
define('DUPLICATOR_SITE_URL', get_site_url());
|
11 |
|
@@ -23,11 +24,6 @@ if (function_exists('plugin_dir_url'))
|
|
23 |
}
|
24 |
|
25 |
define('DUPLICATOR_PLUGIN_PATH', str_replace("\\", "/", plugin_dir_path(__FILE__)));
|
26 |
-
define('DUPLICATOR_SSDIR_NAME', 'wp-snapshots');
|
27 |
-
define('DUPLICATOR_SSDIR_PATH', duplicator_get_abs_path() . '/' . DUPLICATOR_SSDIR_NAME);
|
28 |
-
define('DUPLICATOR_SSDIR_PATH_TMP', DUPLICATOR_SSDIR_PATH . '/tmp');
|
29 |
-
define("DUPLICATOR_SSDIR_PATH_INSTALLER", DUPLICATOR_SSDIR_PATH . '/installer');
|
30 |
-
define('DUPLICATOR_SSDIR_URL', DUPLICATOR_SITE_URL . "/" . DUPLICATOR_SSDIR_NAME);
|
31 |
define('DUPLICATOR_ZIPPED_LOG_FILENAME', 'duplicator_lite_log.zip');
|
32 |
define('DUPLICATOR_INSTALL_PHP', 'installer.php');
|
33 |
define('DUPLICATOR_INSTALL_BAK', 'installer-backup.php');
|
@@ -104,4 +100,4 @@ if (function_exists('plugin_dir_url'))
|
|
104 |
header("HTTP/1.1 404 Not Found", true, 404);
|
105 |
header("Status: 404 Not Found");
|
106 |
exit();
|
107 |
-
}
|
1 |
<?php
|
2 |
+
//Prevent directly browsing to the file
|
3 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
4 |
|
5 |
+
|
6 |
if (function_exists('plugin_dir_url'))
|
7 |
{
|
8 |
+
define('DUPLICATOR_VERSION', '1.3.36');
|
9 |
+
define('DUPLICATOR_VERSION_BUILD', '2020-06-15_07:00');
|
10 |
define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
|
11 |
define('DUPLICATOR_SITE_URL', get_site_url());
|
12 |
|
24 |
}
|
25 |
|
26 |
define('DUPLICATOR_PLUGIN_PATH', str_replace("\\", "/", plugin_dir_path(__FILE__)));
|
|
|
|
|
|
|
|
|
|
|
27 |
define('DUPLICATOR_ZIPPED_LOG_FILENAME', 'duplicator_lite_log.zip');
|
28 |
define('DUPLICATOR_INSTALL_PHP', 'installer.php');
|
29 |
define('DUPLICATOR_INSTALL_BAK', 'installer-backup.php');
|
100 |
header("HTTP/1.1 404 Not Found", true, 404);
|
101 |
header("Status: 404 Not Found");
|
102 |
exit();
|
103 |
+
}
|
duplicator.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Duplicator
|
4 |
Plugin URI: https://snapcreek.com/duplicator/duplicator-free/
|
5 |
Description: Migrate and backup a copy of your WordPress files and database. Duplicate and move a site from one location to another quickly.
|
6 |
-
Version: 1.3.
|
7 |
Author: Snap Creek
|
8 |
Author URI: http://www.snapcreek.com/duplicator/
|
9 |
Text Domain: duplicator
|
@@ -100,7 +100,7 @@ if (is_admin() == true)
|
|
100 |
{
|
101 |
if (DUPLICATOR_VERSION != get_option(DUP_LITE_Plugin_Upgrade::DUP_VERSION_OPT_KEY)) {
|
102 |
DUP_LITE_Plugin_Upgrade::onActivationAction();
|
103 |
-
// $snapShotDirPerm = substr(sprintf("%o", fileperms(
|
104 |
}
|
105 |
load_plugin_textdomain( 'duplicator' );
|
106 |
}
|
@@ -431,4 +431,4 @@ if (is_admin() == true)
|
|
431 |
}
|
432 |
}
|
433 |
}
|
434 |
-
}
|
3 |
Plugin Name: Duplicator
|
4 |
Plugin URI: https://snapcreek.com/duplicator/duplicator-free/
|
5 |
Description: Migrate and backup a copy of your WordPress files and database. Duplicate and move a site from one location to another quickly.
|
6 |
+
Version: 1.3.36
|
7 |
Author: Snap Creek
|
8 |
Author URI: http://www.snapcreek.com/duplicator/
|
9 |
Text Domain: duplicator
|
100 |
{
|
101 |
if (DUPLICATOR_VERSION != get_option(DUP_LITE_Plugin_Upgrade::DUP_VERSION_OPT_KEY)) {
|
102 |
DUP_LITE_Plugin_Upgrade::onActivationAction();
|
103 |
+
// $snapShotDirPerm = substr(sprintf("%o", fileperms(DUP_Settings::getSsdirPath())),-4);
|
104 |
}
|
105 |
load_plugin_textdomain( 'duplicator' );
|
106 |
}
|
431 |
}
|
432 |
}
|
433 |
}
|
434 |
+
}
|
installer/dup-installer/classes/class.db.php
CHANGED
@@ -14,46 +14,100 @@ class DUPX_DB
|
|
14 |
{
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
*
|
19 |
-
* @param string
|
20 |
-
* @param string
|
21 |
-
* @param string
|
22 |
-
* @param string
|
23 |
-
*
|
24 |
-
* @return database connection handle
|
25 |
*/
|
26 |
-
public static function connect($host, $username, $password, $dbname =
|
27 |
{
|
28 |
$dbh = null;
|
29 |
try {
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$dbh = @mysqli_connect('localhost', $username, $password, $dbname, null, $url_parts['path']);
|
34 |
-
} else {
|
35 |
-
if (strpos($host, ':') !== false) {
|
36 |
-
$port = parse_url($host, PHP_URL_PORT);
|
37 |
-
$host = parse_url($host, PHP_URL_HOST);
|
38 |
-
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
|
|
|
|
|
|
46 |
if (!$dbh) {
|
47 |
DUPX_Log::info('DATABASE CONNECTION ERROR: '.mysqli_connect_error().'[ERRNO:'.mysqli_connect_errno().']');
|
48 |
-
} else
|
49 |
-
$dbh
|
|
|
|
|
50 |
}
|
51 |
-
}
|
|
|
52 |
DUPX_Log::info('DATABASE CONNECTION EXCEPTION ERROR: '.$e->getMessage());
|
53 |
}
|
54 |
return $dbh;
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
/**
|
58 |
* Count the tables in a given database
|
59 |
*
|
14 |
{
|
15 |
|
16 |
/**
|
17 |
+
* Modified version of https://developer.wordpress.org/reference/classes/wpdb/db_connect/
|
18 |
*
|
19 |
+
* @param string $host The server host name
|
20 |
+
* @param string $username The server DB user name
|
21 |
+
* @param string $password The server DB password
|
22 |
+
* @param string $dbname The server DB name
|
23 |
+
* @return mysqli Database connection handle
|
|
|
24 |
*/
|
25 |
+
public static function connect($host, $username, $password, $dbname = null)
|
26 |
{
|
27 |
$dbh = null;
|
28 |
try {
|
29 |
+
$port = null;
|
30 |
+
$socket = null;
|
31 |
+
$is_ipv6 = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
$host_data = self::parseDBHost($host);
|
34 |
+
if ($host_data) {
|
35 |
+
list($host, $port, $socket, $is_ipv6) = $host_data;
|
36 |
+
}
|
37 |
+
|
38 |
+
/*
|
39 |
+
* If using the `mysqlnd` library, the IPv6 address needs to be
|
40 |
+
* enclosed in square brackets, whereas it doesn't while using the
|
41 |
+
* `libmysqlclient` library.
|
42 |
+
* @see https://bugs.php.net/bug.php?id=67563
|
43 |
+
*/
|
44 |
+
if ($is_ipv6 && extension_loaded('mysqlnd')) {
|
45 |
+
$host = "[$host]";
|
46 |
}
|
47 |
+
|
48 |
+
$dbh = @mysqli_connect($host, $username, $password, $dbname, $port, $socket);
|
49 |
+
|
50 |
if (!$dbh) {
|
51 |
DUPX_Log::info('DATABASE CONNECTION ERROR: '.mysqli_connect_error().'[ERRNO:'.mysqli_connect_errno().']');
|
52 |
+
} else {
|
53 |
+
if (method_exists($dbh, 'options')) {
|
54 |
+
$dbh->options(MYSQLI_OPT_LOCAL_INFILE, false);
|
55 |
+
}
|
56 |
}
|
57 |
+
}
|
58 |
+
catch (Exception $e) {
|
59 |
DUPX_Log::info('DATABASE CONNECTION EXCEPTION ERROR: '.$e->getMessage());
|
60 |
}
|
61 |
return $dbh;
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
+
* Modified version of https://developer.wordpress.org/reference/classes/wpdb/parse_db_host/
|
66 |
+
*
|
67 |
+
* @param string $host The DB_HOST setting to parse
|
68 |
+
* @return array|bool Array containing the host, the port, the socket and whether it is an IPv6 address, in that order. If $host couldn't be parsed, returns false
|
69 |
+
*/
|
70 |
+
public static function parseDBHost($host)
|
71 |
+
{
|
72 |
+
$port = null;
|
73 |
+
$socket = null;
|
74 |
+
$is_ipv6 = false;
|
75 |
+
|
76 |
+
// First peel off the socket parameter from the right, if it exists.
|
77 |
+
$socket_pos = strpos($host, ':/');
|
78 |
+
if (false !== $socket_pos) {
|
79 |
+
$socket = substr($host, $socket_pos + 1);
|
80 |
+
$host = substr($host, 0, $socket_pos);
|
81 |
+
}
|
82 |
+
|
83 |
+
// We need to check for an IPv6 address first.
|
84 |
+
// An IPv6 address will always contain at least two colons.
|
85 |
+
if (substr_count($host, ':') > 1) {
|
86 |
+
$pattern = '#^(?:\[)?(?P<host>[0-9a-fA-F:]+)(?:\]:(?P<port>[\d]+))?#';
|
87 |
+
$is_ipv6 = true;
|
88 |
+
} else {
|
89 |
+
// We seem to be dealing with an IPv4 address.
|
90 |
+
$pattern = '#^(?P<host>[^:/]*)(?::(?P<port>[\d]+))?#';
|
91 |
+
}
|
92 |
+
|
93 |
+
$matches = array();
|
94 |
+
$result = preg_match($pattern, $host, $matches);
|
95 |
+
|
96 |
+
if (1 !== $result) {
|
97 |
+
// Couldn't parse the address, bail.
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
|
101 |
+
$host = '';
|
102 |
+
foreach (array('host', 'port') as $component) {
|
103 |
+
if (!empty($matches[$component])) {
|
104 |
+
$$component = $matches[$component];
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
return array($host, $port, $socket, $is_ipv6);
|
109 |
+
}
|
110 |
+
|
111 |
/**
|
112 |
* Count the tables in a given database
|
113 |
*
|
installer/dup-installer/classes/class.logging.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
3 |
|
4 |
-
define('ERR_ZIPNOTFOUND', 'The packaged zip file was not found or has become unreadable. Be sure the zip package is in the same directory as the installer file. If you are trying to reinstall a package you can copy the package from the
|
5 |
define('ERR_SHELLEXEC_ZIPOPEN', 'Failed to extract the archive using shell_exec unzip');
|
6 |
define('ERR_ZIPOPEN', 'Failed to open the zip archive file. Please be sure the archive is completely downloaded before running the installer. Try to extract the archive manually to make sure the file is not corrupted.');
|
7 |
define('ERR_ZIPEXTRACTION', 'Errors extracting the zip file. Portions or part of the zip archive did not extract correctly. Try to extract the archive manually with a client side program like unzip/win-zip/winrar to make sure the file is not corrupted. If the file extracts correctly then there is an invalid file or directory that PHP is unable to extract. This can happen if your moving from one operating system to another where certain naming conventions work on one environment and not another. <br/><br/> Workarounds: <br/> 1. Create a new package and be sure to exclude any directories that have name checks or files in them. This warning will be displayed on the scan results under "Name Checks". <br/> 2. Manually extract the zip file with a client side program. Then under options in step 1 of the installer select the "Manual Archive Extraction" option and perform the install.');
|
1 |
<?php
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
3 |
|
4 |
+
define('ERR_ZIPNOTFOUND', 'The packaged zip file was not found or has become unreadable. Be sure the zip package is in the same directory as the installer file. If you are trying to reinstall a package you can copy the package from the storage directory back up to your root which is the same location as your installer file.');
|
5 |
define('ERR_SHELLEXEC_ZIPOPEN', 'Failed to extract the archive using shell_exec unzip');
|
6 |
define('ERR_ZIPOPEN', 'Failed to open the zip archive file. Please be sure the archive is completely downloaded before running the installer. Try to extract the archive manually to make sure the file is not corrupted.');
|
7 |
define('ERR_ZIPEXTRACTION', 'Errors extracting the zip file. Portions or part of the zip archive did not extract correctly. Try to extract the archive manually with a client side program like unzip/win-zip/winrar to make sure the file is not corrupted. If the file extracts correctly then there is an invalid file or directory that PHP is unable to extract. This can happen if your moving from one operating system to another where certain naming conventions work on one environment and not another. <br/><br/> Workarounds: <br/> 1. Create a new package and be sure to exclude any directories that have name checks or files in them. This warning will be displayed on the scan results under "Name Checks". <br/> 2. Manually extract the zip file with a client side program. Then under options in step 1 of the installer select the "Manual Archive Extraction" option and perform the install.');
|
installer/dup-installer/classes/config/class.constants.php
CHANGED
@@ -73,7 +73,6 @@ class DUPX_Constants
|
|
73 |
|
74 |
//CONSTANTS
|
75 |
define("DUPLICATOR_INIT", 1);
|
76 |
-
define("DUPLICATOR_SSDIR_NAME", 'wp-snapshots-dup-pro'); //This should match DUPLICATOR_SSDIR_NAME in duplicator.php
|
77 |
|
78 |
//SHARED POST PARMS
|
79 |
$_GET['debug'] = isset($_GET['debug']) ? true : false;
|
73 |
|
74 |
//CONSTANTS
|
75 |
define("DUPLICATOR_INIT", 1);
|
|
|
76 |
|
77 |
//SHARED POST PARMS
|
78 |
$_GET['debug'] = isset($_GET['debug']) ? true : false;
|
installer/dup-installer/ctrls/ctrl.s2.dbinstall.php
CHANGED
@@ -3,6 +3,10 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
|
3 |
|
4 |
class DUPX_DBInstall
|
5 |
{
|
|
|
|
|
|
|
|
|
6 |
private $dbh;
|
7 |
private $post;
|
8 |
public $sql_result_data;
|
@@ -35,6 +39,7 @@ class DUPX_DBInstall
|
|
35 |
public $dbobj_views;
|
36 |
public $dbobj_procs;
|
37 |
public $dbFileSize = 0;
|
|
|
38 |
|
39 |
public function __construct($post, $start_microtime)
|
40 |
{
|
@@ -59,23 +64,24 @@ class DUPX_DBInstall
|
|
59 |
@mysqli_query($this->dbh, "SET GLOBAL max_allowed_packet = ".mysqli_real_escape_string($this->dbh, $GLOBALS['DB_MAX_PACKETS']));
|
60 |
@mysqli_query($this->dbh, "SET max_allowed_packet = ".mysqli_real_escape_string($this->dbh, $GLOBALS['DB_MAX_PACKETS']));
|
61 |
|
62 |
-
$this->profile_start
|
63 |
-
$this->start_microtime
|
64 |
-
$this->dbvar_maxtime
|
65 |
-
$this->dbvar_maxpacks
|
66 |
-
$this->dbvar_sqlmode
|
67 |
-
$this->dbvar_version
|
68 |
-
$this->dbvar_maxtime
|
69 |
-
$this->dbvar_maxpacks
|
70 |
-
$this->dbvar_sqlmode
|
71 |
-
$this->
|
72 |
-
$this->
|
73 |
-
$this->
|
74 |
-
$this->
|
75 |
-
$this->
|
76 |
-
$this->
|
77 |
-
$this->
|
78 |
-
$this->
|
|
|
79 |
}
|
80 |
|
81 |
public function prepareDB()
|
@@ -248,7 +254,7 @@ class DUPX_DBInstall
|
|
248 |
} elseif ($query_strlen > 0) {
|
249 |
$query = $this->nbspFix($query);
|
250 |
$query = $this->applyQueryCollationFallback($query);
|
251 |
-
$query = $this->
|
252 |
|
253 |
// $query = $this->queryDelimiterFix($query);
|
254 |
$query = trim($query);
|
@@ -528,12 +534,15 @@ class DUPX_DBInstall
|
|
528 |
}
|
529 |
}
|
530 |
|
531 |
-
private function
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
|
|
|
|
|
|
537 |
}
|
538 |
|
539 |
private function delimiterFix($counter)
|
3 |
|
4 |
class DUPX_DBInstall
|
5 |
{
|
6 |
+
const USER_DEFINER_PATTERN = "/^(\s*(?:\/\*!\d+\s)?\s*(?:CREATE.+)?DEFINER\s*=)(\S+)(.*)$/m";
|
7 |
+
const SQL_SECURITY_INVOKER_PATTERN = "/^([\s\t]*CREATE.+PROCEDURE[\s\S]*)(BEGIN)([\s\S]*)$/";
|
8 |
+
const SQL_SECURITY_INVOKER_REPLACE = "$1SQL SECURITY INVOKER\n$2$3";
|
9 |
+
|
10 |
private $dbh;
|
11 |
private $post;
|
12 |
public $sql_result_data;
|
39 |
public $dbobj_views;
|
40 |
public $dbobj_procs;
|
41 |
public $dbFileSize = 0;
|
42 |
+
public $dbDefinerReplace;
|
43 |
|
44 |
public function __construct($post, $start_microtime)
|
45 |
{
|
64 |
@mysqli_query($this->dbh, "SET GLOBAL max_allowed_packet = ".mysqli_real_escape_string($this->dbh, $GLOBALS['DB_MAX_PACKETS']));
|
65 |
@mysqli_query($this->dbh, "SET max_allowed_packet = ".mysqli_real_escape_string($this->dbh, $GLOBALS['DB_MAX_PACKETS']));
|
66 |
|
67 |
+
$this->profile_start = isset($post['profile_start']) ? DUPX_U::sanitize_text_field($post['profile_start']) : DUPX_U::getMicrotime();
|
68 |
+
$this->start_microtime = isset($post['start_microtime']) ? DUPX_U::sanitize_text_field($post['start_microtime']) : $start_microtime;
|
69 |
+
$this->dbvar_maxtime = DUPX_DB::getVariable($this->dbh, 'wait_timeout');
|
70 |
+
$this->dbvar_maxpacks = DUPX_DB::getVariable($this->dbh, 'max_allowed_packet');
|
71 |
+
$this->dbvar_sqlmode = DUPX_DB::getVariable($this->dbh, 'sql_mode');
|
72 |
+
$this->dbvar_version = DUPX_DB::getVersion($this->dbh);
|
73 |
+
$this->dbvar_maxtime = is_null($this->dbvar_maxtime) ? 300 : $this->dbvar_maxtime;
|
74 |
+
$this->dbvar_maxpacks = is_null($this->dbvar_maxpacks) ? 1048576 : $this->dbvar_maxpacks;
|
75 |
+
$this->dbvar_sqlmode = empty($this->dbvar_sqlmode) ? 'NOT_SET' : $this->dbvar_sqlmode;
|
76 |
+
$this->dbDefinerReplace = '$1' . addcslashes("`" . $this->post["dbuser"] . "`@`" . $this->post["dbhost"] . "`", '\\$') . '$3';
|
77 |
+
$this->dbquery_errs = isset($post['dbquery_errs']) ? DUPX_U::sanitize_text_field($post['dbquery_errs']) : 0;
|
78 |
+
$this->drop_tbl_log = isset($post['drop_tbl_log']) ? DUPX_U::sanitize_text_field($post['drop_tbl_log']) : 0;
|
79 |
+
$this->rename_tbl_log = isset($post['rename_tbl_log']) ? DUPX_U::sanitize_text_field($post['rename_tbl_log']) : 0;
|
80 |
+
$this->dbquery_rows = isset($post['dbquery_rows']) ? DUPX_U::sanitize_text_field($post['dbquery_rows']) : 0;
|
81 |
+
$this->dbdelete_count = isset($post['dbdelete_count']) ? DUPX_U::sanitize_text_field($post['dbdelete_count']) : 0;
|
82 |
+
$this->dbcollatefb = isset($post['dbcollatefb']) ? DUPX_U::sanitize_text_field($post['dbcollatefb']) : 0;
|
83 |
+
$this->dbobj_views = isset($post['dbobj_views']) ? DUPX_U::sanitize_text_field($post['dbobj_views']) : 0;
|
84 |
+
$this->dbobj_procs = isset($post['dbobj_procs']) ? DUPX_U::sanitize_text_field($post['dbobj_procs']) : 0;
|
85 |
}
|
86 |
|
87 |
public function prepareDB()
|
254 |
} elseif ($query_strlen > 0) {
|
255 |
$query = $this->nbspFix($query);
|
256 |
$query = $this->applyQueryCollationFallback($query);
|
257 |
+
$query = $this->applyQueryProcAndViewFix($query);
|
258 |
|
259 |
// $query = $this->queryDelimiterFix($query);
|
260 |
$query = trim($query);
|
534 |
}
|
535 |
}
|
536 |
|
537 |
+
private function applyQueryProcAndViewFix($query)
|
538 |
+
{
|
539 |
+
return preg_replace(array(
|
540 |
+
self::USER_DEFINER_PATTERN,
|
541 |
+
self::SQL_SECURITY_INVOKER_PATTERN
|
542 |
+
), array(
|
543 |
+
$this->dbDefinerReplace,
|
544 |
+
self::SQL_SECURITY_INVOKER_REPLACE
|
545 |
+
), $query);
|
546 |
}
|
547 |
|
548 |
private function delimiterFix($counter)
|
installer/dup-installer/ctrls/ctrl.s2.dbtest.php
CHANGED
@@ -148,36 +148,46 @@ class DUPX_DBTest
|
|
148 |
$this->basicCleanup();
|
149 |
}
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
163 |
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
$test['pass'] = 0;
|
171 |
-
$test['info'] = (mysqli_connect_error())
|
172 |
-
? "{$msg}. The server error response was: <i>" . htmlentities(mysqli_connect_error()) . '</i>'
|
173 |
-
: "{$msg}. Please contact your hosting provider or server administrator.";
|
174 |
-
}
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
/**
|
183 |
* Check Server Version
|
148 |
$this->basicCleanup();
|
149 |
}
|
150 |
|
151 |
+
/**
|
152 |
+
* Verify Host Connection
|
153 |
+
*
|
154 |
+
* @return null
|
155 |
+
*/
|
156 |
+
private function r10All(&$test)
|
157 |
+
{
|
158 |
+
try {
|
159 |
+
|
160 |
+
if ($this->isFailedState($test)) {
|
161 |
+
return;
|
162 |
+
}
|
163 |
|
164 |
+
//Host check
|
165 |
+
$parsed_host_info = DUPX_DB::parseDBHost($this->in->dbhost);
|
166 |
+
$parsed_host = $parsed_host_info[0];
|
167 |
+
$isInvalidHost = $parsed_host == 'http' || $parsed_host == "https";
|
168 |
|
169 |
+
if ($isInvalidHost) {
|
170 |
+
$fixed_host = DupLiteSnapLibIOU::untrailingslashit(str_replace($parsed_host."://","",$this->in->dbhost));
|
171 |
+
$test['pass'] = 0;
|
172 |
+
$test['info'] = "<b>[".htmlentities($this->in->dbhost)."]</b> is not a valid input. Try using <b>[$fixed_host]</b> instead.";
|
173 |
+
return;
|
174 |
+
}
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
+
$this->dbh = DUPX_DB::connect($this->in->dbhost, $this->in->dbuser, $this->in->dbpass, null);
|
177 |
+
if ($this->dbh) {
|
178 |
+
$test['pass'] = 1;
|
179 |
+
$test['info'] = "The user <b>[".htmlentities($this->in->dbuser)."]</b> successfully connected to the database server on host <b>[".htmlentities($this->in->dbhost)."]</b>.";
|
180 |
+
} else {
|
181 |
+
$msg = "Unable to connect the user <b>[".htmlentities($this->in->dbuser)."]</b> to the host <b>[".htmlentities($this->in->dbhost)."]</b>";
|
182 |
+
$test['pass'] = 0;
|
183 |
+
$test['info'] = (mysqli_connect_error()) ? "{$msg}. The server error response was: <i>".htmlentities(mysqli_connect_error()).'</i>' : "{$msg}. Please contact your hosting provider or server administrator.";
|
184 |
+
}
|
185 |
+
}
|
186 |
+
catch (Exception $ex) {
|
187 |
+
$test['pass'] = 0;
|
188 |
+
$test['info'] = "Unable to connect the user <b>[".htmlentities($this->in->dbuser)."]</b> to the host <b>[".htmlentities($this->in->dbhost)."]</b>.<br/>".$this->formatError($ex);
|
189 |
+
}
|
190 |
+
}
|
191 |
|
192 |
/**
|
193 |
* Check Server Version
|
installer/dup-installer/index.php
CHANGED
@@ -13,7 +13,7 @@ if (isset($_SERVER['HTTP_X_ORIGINAL_HOST'])) {
|
|
13 |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
14 |
$_SERVER ['HTTPS'] = 'on';
|
15 |
}
|
16 |
-
$serverDomain = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 's' : '').'://'.$host;
|
17 |
$serverUrlSelf = preg_match('/^[\\\\\/]?$/', dirname($_SERVER['SCRIPT_NAME'])) ? '' : dirname($_SERVER['SCRIPT_NAME']);
|
18 |
|
19 |
define('DUPX_INIT', str_replace('\\', '/', dirname(__FILE__)));
|
13 |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
14 |
$_SERVER ['HTTPS'] = 'on';
|
15 |
}
|
16 |
+
$serverDomain = 'http'.((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) === 'on') ? 's' : '').'://'.$host;
|
17 |
$serverUrlSelf = preg_match('/^[\\\\\/]?$/', dirname($_SERVER['SCRIPT_NAME'])) ? '' : dirname($_SERVER['SCRIPT_NAME']);
|
18 |
|
19 |
define('DUPX_INIT', str_replace('\\', '/', dirname(__FILE__)));
|
installer/dup-installer/main.installer.php
CHANGED
@@ -41,7 +41,7 @@ try {
|
|
41 |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
42 |
$_SERVER ['HTTPS'] = 'on';
|
43 |
}
|
44 |
-
$serverDomain = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 's' : '').'://'.$host;
|
45 |
$serverUrlSelf = preg_match('/^[\\\\\/]?$/', dirname($_SERVER['SCRIPT_NAME'])) ? '' : dirname($_SERVER['SCRIPT_NAME']);
|
46 |
|
47 |
$GLOBALS['DUPX_INIT'] = str_replace('\\', '/', dirname(__FILE__));
|
41 |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
42 |
$_SERVER ['HTTPS'] = 'on';
|
43 |
}
|
44 |
+
$serverDomain = 'http'.((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) === 'on') ? 's' : '').'://'.$host;
|
45 |
$serverUrlSelf = preg_match('/^[\\\\\/]?$/', dirname($_SERVER['SCRIPT_NAME'])) ? '' : dirname($_SERVER['SCRIPT_NAME']);
|
46 |
|
47 |
$GLOBALS['DUPX_INIT'] = str_replace('\\', '/', dirname(__FILE__));
|
lib/snaplib/class.snaplib.u.io.php
CHANGED
@@ -54,15 +54,128 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
54 |
if (copy($source, $dest) === false) {
|
55 |
throw new Exception("Error copying {$source} to {$dest}");
|
56 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
|
59 |
public static function safePath($path, $real = false)
|
60 |
{
|
61 |
if ($real) {
|
62 |
-
$
|
|
|
|
|
63 |
}
|
|
|
|
|
64 |
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
}
|
67 |
|
68 |
public static function massMove($fileSystemObjects, $destination, $exclusions = null, $exceptionOnError = true)
|
@@ -122,6 +235,8 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
122 |
if (!@rename($oldname, $newname)) {
|
123 |
throw new Exception("Couldn't rename {$oldname} to {$newname}");
|
124 |
}
|
|
|
|
|
125 |
}
|
126 |
|
127 |
public static function fopen($filepath, $mode, $throwOnError = true)
|
@@ -171,7 +286,7 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
171 |
{
|
172 |
if (file_exists($dirname)) {
|
173 |
self::chmod($dirname, 'u+rwx');
|
174 |
-
if (
|
175 |
throw new Exception("Couldn't remove {$dirname}");
|
176 |
}
|
177 |
} else if ($mustExist) {
|
@@ -290,6 +405,12 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
290 |
$filepath = stream_get_meta_data($handle);
|
291 |
$filepath = $filepath["uri"];
|
292 |
$filesize = self::filesize($filepath);
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
if ($ret_val === false) {
|
294 |
throw new Exception("Trying to fseek($offset, $whence) and came back false");
|
295 |
}
|
@@ -315,7 +436,7 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
315 |
|
316 |
/**
|
317 |
* exetute a file put contents after some checks. throw exception if fail.
|
318 |
-
*
|
319 |
* @param string $filename
|
320 |
* @param mixed $data
|
321 |
* @return boolean
|
@@ -482,7 +603,7 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
482 |
/**
|
483 |
* this function creates a folder if it does not exist and performs a chmod.
|
484 |
* it is different from the normal mkdir function to which an umask is applied to the input permissions.
|
485 |
-
*
|
486 |
* this function handles the variable MODE in a way similar to the chmod of lunux
|
487 |
* So the MODE variable can be
|
488 |
* 1) an octal number (0755)
|
@@ -492,7 +613,7 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
492 |
* @param string $path
|
493 |
* @param int|string $mode
|
494 |
* @param bool $recursive
|
495 |
-
* @param resource $context // not used
|
496 |
* @return boolean bool TRUE on success or FALSE on failure.
|
497 |
*
|
498 |
* @todo check recursive true and multiple chmod
|
@@ -500,7 +621,7 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
500 |
public static function mkdir($path, $mode = 0777, $recursive = false, $context = null)
|
501 |
{
|
502 |
if (strlen($path) > DupLiteSnapLibOSU::maxPathLen()) {
|
503 |
-
throw new Exception('Skipping a file that exceeds allowed max path length ['.DupLiteSnapLibOSU::maxPathLen().']. File: '.$
|
504 |
}
|
505 |
|
506 |
if (!file_exists($path)) {
|
@@ -529,13 +650,212 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
529 |
*/
|
530 |
public static function dirWriteCheckOrMkdir($path, $mode = 'u+rwx', $recursive = false, $context = null)
|
531 |
{
|
532 |
-
if (!
|
533 |
return self::mkdir($path, $mode, $recursive, $context);
|
|
|
|
|
534 |
} else {
|
535 |
return true;
|
536 |
}
|
537 |
}
|
538 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
/**
|
540 |
* @param string $path Path to the file
|
541 |
* @param int $n Number of lines to get
|
@@ -551,23 +871,23 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
551 |
return false;
|
552 |
}
|
553 |
|
554 |
-
$result
|
555 |
-
$pos
|
556 |
$currentLine = '';
|
557 |
-
$counter
|
558 |
|
559 |
while ($counter < $n && -1 !== fseek($handle, $pos, SEEK_END)) {
|
560 |
$char = fgetc($handle);
|
561 |
if (PHP_EOL == $char) {
|
562 |
$trimmedValue = trim($currentLine);
|
563 |
-
|
564 |
if (!empty($trimmedValue)) {
|
565 |
$result[] = $currentLine;
|
566 |
$counter++;
|
567 |
}
|
568 |
$currentLine = '';
|
569 |
} else {
|
570 |
-
$currentLine = $char
|
571 |
}
|
572 |
$pos--;
|
573 |
}
|
@@ -576,4 +896,4 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
576 |
return array_reverse($result);
|
577 |
}
|
578 |
}
|
579 |
-
}
|
54 |
if (copy($source, $dest) === false) {
|
55 |
throw new Exception("Error copying {$source} to {$dest}");
|
56 |
}
|
57 |
+
|
58 |
+
return true;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
*
|
63 |
+
* @param string $source
|
64 |
+
* @param string $dest
|
65 |
+
* @return boolean false if fail
|
66 |
+
*/
|
67 |
+
public static function rcopy($source, $dest)
|
68 |
+
{
|
69 |
+
if (!is_readable($source)) {
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
|
73 |
+
if (is_dir($source)) {
|
74 |
+
if (!file_exists($dest)) {
|
75 |
+
if (!self::mkdir($dest)) {
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
if (($handle = opendir($source)) != false) {
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
|
84 |
+
while ($file = readdir($handle)) {
|
85 |
+
if ($file == "." && $file == "..") {
|
86 |
+
continue;
|
87 |
+
}
|
88 |
+
|
89 |
+
if (is_dir($source.'/'.$file)) {
|
90 |
+
if (!self::rcopy($source.'/'.$file, $dest.'/'.$file)) {
|
91 |
+
return false;
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
if (!self::copy($source.'/'.$file, $dest.'/'.$file)) {
|
95 |
+
return false;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
closedir($handle);
|
100 |
+
return true;
|
101 |
+
} else {
|
102 |
+
return self::copy($source, $dest);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
public static function untrailingslashit($path)
|
107 |
+
{
|
108 |
+
return rtrim($path, '/\\');
|
109 |
+
}
|
110 |
+
|
111 |
+
public static function trailingslashit($path)
|
112 |
+
{
|
113 |
+
return self::untrailingslashit($path).'/';
|
114 |
}
|
115 |
|
116 |
public static function safePath($path, $real = false)
|
117 |
{
|
118 |
if ($real) {
|
119 |
+
$res = realpath($path);
|
120 |
+
} else {
|
121 |
+
$res = $path;
|
122 |
}
|
123 |
+
return self::normalize_path($path);
|
124 |
+
}
|
125 |
|
126 |
+
public static function safePathUntrailingslashit($path, $real = false)
|
127 |
+
{
|
128 |
+
if ($real) {
|
129 |
+
$res = realpath($path);
|
130 |
+
} else {
|
131 |
+
$res = $path;
|
132 |
+
}
|
133 |
+
return rtrim(self::normalize_path($res), '/');
|
134 |
+
}
|
135 |
+
|
136 |
+
public static function safePathTrailingslashit($path, $real = false)
|
137 |
+
{
|
138 |
+
return self::safePathUntrailingslashit($path, $real).'/';
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
*
|
143 |
+
* @param string $sourceFolder
|
144 |
+
* @param string $destFolder
|
145 |
+
* @param bool $skipIfExists
|
146 |
+
* @return boolean
|
147 |
+
*/
|
148 |
+
public static function moveContentDirToTarget($sourceFolder, $destFolder, $skipIfExists = false)
|
149 |
+
{
|
150 |
+
if (!is_dir($sourceFolder) || !is_readable($sourceFolder)) {
|
151 |
+
return false;
|
152 |
+
}
|
153 |
+
|
154 |
+
if (!is_dir($destFolder) || !is_writable($destFolder)) {
|
155 |
+
return false;
|
156 |
+
}
|
157 |
+
|
158 |
+
$sourceIterator = new DirectoryIterator($sourceFolder);
|
159 |
+
foreach ($sourceIterator as $fileinfo) {
|
160 |
+
if ($fileinfo->isDot()) {
|
161 |
+
continue;
|
162 |
+
}
|
163 |
+
$destPath = $destFolder.'/'.$fileinfo->getBasename();
|
164 |
+
|
165 |
+
if (file_exists($destPath)) {
|
166 |
+
if ($skipIfExists) {
|
167 |
+
continue;
|
168 |
+
} else {
|
169 |
+
return false;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
if (self::rename($fileinfo->getPathname(), $destPath) == false) {
|
174 |
+
return false;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
return true;
|
179 |
}
|
180 |
|
181 |
public static function massMove($fileSystemObjects, $destination, $exclusions = null, $exceptionOnError = true)
|
235 |
if (!@rename($oldname, $newname)) {
|
236 |
throw new Exception("Couldn't rename {$oldname} to {$newname}");
|
237 |
}
|
238 |
+
|
239 |
+
return true;
|
240 |
}
|
241 |
|
242 |
public static function fopen($filepath, $mode, $throwOnError = true)
|
286 |
{
|
287 |
if (file_exists($dirname)) {
|
288 |
self::chmod($dirname, 'u+rwx');
|
289 |
+
if (self::rrmdir($dirname) === false) {
|
290 |
throw new Exception("Couldn't remove {$dirname}");
|
291 |
}
|
292 |
} else if ($mustExist) {
|
405 |
$filepath = stream_get_meta_data($handle);
|
406 |
$filepath = $filepath["uri"];
|
407 |
$filesize = self::filesize($filepath);
|
408 |
+
// For future debug
|
409 |
+
/*
|
410 |
+
error_log('$offset: '.$offset);
|
411 |
+
error_log('$filesize: '.$filesize);
|
412 |
+
error_log($whence. ' == '. SEEK_SET);
|
413 |
+
*/
|
414 |
if ($ret_val === false) {
|
415 |
throw new Exception("Trying to fseek($offset, $whence) and came back false");
|
416 |
}
|
436 |
|
437 |
/**
|
438 |
* exetute a file put contents after some checks. throw exception if fail.
|
439 |
+
*
|
440 |
* @param string $filename
|
441 |
* @param mixed $data
|
442 |
* @return boolean
|
603 |
/**
|
604 |
* this function creates a folder if it does not exist and performs a chmod.
|
605 |
* it is different from the normal mkdir function to which an umask is applied to the input permissions.
|
606 |
+
*
|
607 |
* this function handles the variable MODE in a way similar to the chmod of lunux
|
608 |
* So the MODE variable can be
|
609 |
* 1) an octal number (0755)
|
613 |
* @param string $path
|
614 |
* @param int|string $mode
|
615 |
* @param bool $recursive
|
616 |
+
* @param resource $context // not used for windows bug
|
617 |
* @return boolean bool TRUE on success or FALSE on failure.
|
618 |
*
|
619 |
* @todo check recursive true and multiple chmod
|
621 |
public static function mkdir($path, $mode = 0777, $recursive = false, $context = null)
|
622 |
{
|
623 |
if (strlen($path) > DupLiteSnapLibOSU::maxPathLen()) {
|
624 |
+
throw new Exception('Skipping a file that exceeds allowed max path length ['.DupLiteSnapLibOSU::maxPathLen().']. File: '.$path);
|
625 |
}
|
626 |
|
627 |
if (!file_exists($path)) {
|
650 |
*/
|
651 |
public static function dirWriteCheckOrMkdir($path, $mode = 'u+rwx', $recursive = false, $context = null)
|
652 |
{
|
653 |
+
if (!file_exists($path)) {
|
654 |
return self::mkdir($path, $mode, $recursive, $context);
|
655 |
+
} else if (!is_writable($path) || !is_executable($path)) {
|
656 |
+
return self::chmod($path, $mode);
|
657 |
} else {
|
658 |
return true;
|
659 |
}
|
660 |
}
|
661 |
|
662 |
+
/**
|
663 |
+
* from wordpress function wp_is_stream
|
664 |
+
*
|
665 |
+
* @param string $path The resource path or URL.
|
666 |
+
* @return bool True if the path is a stream URL.
|
667 |
+
*/
|
668 |
+
public static function is_stream($path)
|
669 |
+
{
|
670 |
+
$scheme_separator = strpos($path, '://');
|
671 |
+
|
672 |
+
if (false === $scheme_separator) {
|
673 |
+
// $path isn't a stream
|
674 |
+
return false;
|
675 |
+
}
|
676 |
+
|
677 |
+
$stream = substr($path, 0, $scheme_separator);
|
678 |
+
|
679 |
+
return in_array($stream, stream_get_wrappers(), true);
|
680 |
+
}
|
681 |
+
|
682 |
+
/**
|
683 |
+
* From Wordpress function: wp_mkdir_p
|
684 |
+
*
|
685 |
+
* Recursive directory creation based on full path.
|
686 |
+
*
|
687 |
+
* Will attempt to set permissions on folders.
|
688 |
+
*
|
689 |
+
* @param string $target Full path to attempt to create.
|
690 |
+
* @return bool Whether the path was created. True if path already exists.
|
691 |
+
*/
|
692 |
+
public static function mkdir_p($target)
|
693 |
+
{
|
694 |
+
$wrapper = null;
|
695 |
+
|
696 |
+
// Strip the protocol.
|
697 |
+
if (self::is_stream($target)) {
|
698 |
+
list( $wrapper, $target ) = explode('://', $target, 2);
|
699 |
+
}
|
700 |
+
|
701 |
+
// From php.net/mkdir user contributed notes.
|
702 |
+
$target = str_replace('//', '/', $target);
|
703 |
+
|
704 |
+
// Put the wrapper back on the target.
|
705 |
+
if ($wrapper !== null) {
|
706 |
+
$target = $wrapper.'://'.$target;
|
707 |
+
}
|
708 |
+
|
709 |
+
/*
|
710 |
+
* Safe mode fails with a trailing slash under certain PHP versions.
|
711 |
+
* Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
|
712 |
+
*/
|
713 |
+
$target = rtrim($target, '/');
|
714 |
+
if (empty($target)) {
|
715 |
+
$target = '/';
|
716 |
+
}
|
717 |
+
|
718 |
+
if (file_exists($target)) {
|
719 |
+
return @is_dir($target);
|
720 |
+
}
|
721 |
+
|
722 |
+
// We need to find the permissions of the parent folder that exists and inherit that.
|
723 |
+
$target_parent = dirname($target);
|
724 |
+
while ('.' != $target_parent && !is_dir($target_parent) && dirname($target_parent) !== $target_parent) {
|
725 |
+
$target_parent = dirname($target_parent);
|
726 |
+
}
|
727 |
+
|
728 |
+
// Get the permission bits.
|
729 |
+
if ($stat = @stat($target_parent)) {
|
730 |
+
$dir_perms = $stat['mode'] & 0007777;
|
731 |
+
} else {
|
732 |
+
$dir_perms = 0777;
|
733 |
+
}
|
734 |
+
|
735 |
+
if (@mkdir($target, $dir_perms, true)) {
|
736 |
+
|
737 |
+
/*
|
738 |
+
* If a umask is set that modifies $dir_perms, we'll have to re-set
|
739 |
+
* the $dir_perms correctly with chmod()
|
740 |
+
*/
|
741 |
+
if ($dir_perms != ( $dir_perms & ~umask() )) {
|
742 |
+
$folder_parts = explode('/', substr($target, strlen($target_parent) + 1));
|
743 |
+
for ($i = 1, $c = count($folder_parts); $i <= $c; $i++) {
|
744 |
+
@chmod($target_parent.'/'.implode('/', array_slice($folder_parts, 0, $i)), $dir_perms);
|
745 |
+
}
|
746 |
+
}
|
747 |
+
|
748 |
+
return true;
|
749 |
+
}
|
750 |
+
|
751 |
+
return false;
|
752 |
+
}
|
753 |
+
|
754 |
+
/**
|
755 |
+
*
|
756 |
+
* @param string|bool $path // return false if path isn't a sub path of main path or return the relative path
|
757 |
+
*/
|
758 |
+
public static function getRelativePath($path, $mainPath)
|
759 |
+
{
|
760 |
+
$safePath = self::safePathUntrailingslashit($path);
|
761 |
+
$safeMainPath = self::safePathUntrailingslashit($mainPath);
|
762 |
+
|
763 |
+
if (empty($mainPath)) {
|
764 |
+
return ltrim($safePath, '/');
|
765 |
+
} else if (strpos($safePath, $safeMainPath) === 0) {
|
766 |
+
return ltrim(substr($safePath, strlen($safeMainPath)), '/');
|
767 |
+
} else {
|
768 |
+
return false;
|
769 |
+
}
|
770 |
+
}
|
771 |
+
|
772 |
+
/**
|
773 |
+
* from wp_normalize_path
|
774 |
+
*
|
775 |
+
* @param string $path Path to normalize.
|
776 |
+
* @return string Normalized path.
|
777 |
+
*/
|
778 |
+
public static function normalize_path($path)
|
779 |
+
{
|
780 |
+
$wrapper = '';
|
781 |
+
if (self::is_stream($path)) {
|
782 |
+
list( $wrapper, $path ) = explode('://', $path, 2);
|
783 |
+
$wrapper .= '://';
|
784 |
+
}
|
785 |
+
|
786 |
+
// Standardise all paths to use /
|
787 |
+
$path = str_replace('\\', '/', $path);
|
788 |
+
|
789 |
+
// Replace multiple slashes down to a singular, allowing for network shares having two slashes.
|
790 |
+
$path = preg_replace('|(?<=.)/+|', '/', $path);
|
791 |
+
if (strpos($path, '//') === 0) {
|
792 |
+
$path = substr($path, 1);
|
793 |
+
}
|
794 |
+
|
795 |
+
// Windows paths should uppercase the drive letter
|
796 |
+
if (':' === substr($path, 1, 1)) {
|
797 |
+
$path = ucfirst($path);
|
798 |
+
}
|
799 |
+
|
800 |
+
return $wrapper.$path;
|
801 |
+
}
|
802 |
+
|
803 |
+
/**
|
804 |
+
* Get common parent path from given paths
|
805 |
+
*
|
806 |
+
* @param array $paths - array of paths
|
807 |
+
* @return common parent path
|
808 |
+
*/
|
809 |
+
public static function getCommonPath($paths = array())
|
810 |
+
{
|
811 |
+
if (empty($paths)) {
|
812 |
+
return '';
|
813 |
+
} if (!is_array($paths)) {
|
814 |
+
$paths = array($paths);
|
815 |
+
} else {
|
816 |
+
$paths = array_values($paths);
|
817 |
+
}
|
818 |
+
|
819 |
+
$pathAssoc = array();
|
820 |
+
$numPaths = count($paths);
|
821 |
+
$minPathCouts = PHP_INT_MAX;
|
822 |
+
|
823 |
+
for ($i = 0; $i < $numPaths; $i++) {
|
824 |
+
$pathAssoc[$i] = explode('/', self::safePathUntrailingslashit($paths[$i]));
|
825 |
+
$pathCount = count($pathAssoc[$i]);
|
826 |
+
if ($minPathCouts > $pathCount) {
|
827 |
+
$minPathCouts = $pathCount;
|
828 |
+
}
|
829 |
+
}
|
830 |
+
|
831 |
+
for ($partIndex = 0; $partIndex < $minPathCouts; $partIndex++) {
|
832 |
+
$currentPart = $pathAssoc[0][$partIndex];
|
833 |
+
for ($currentPath = 1; $currentPath < $numPaths; $currentPath++) {
|
834 |
+
if ($pathAssoc[$currentPath][$partIndex] != $currentPart) {
|
835 |
+
break 2;
|
836 |
+
}
|
837 |
+
}
|
838 |
+
}
|
839 |
+
|
840 |
+
$resultParts = array_slice($pathAssoc[0], 0, $partIndex);
|
841 |
+
|
842 |
+
return implode('/', $resultParts);
|
843 |
+
}
|
844 |
+
|
845 |
+
/**
|
846 |
+
* remove root path transforming the current path into a relative path
|
847 |
+
*
|
848 |
+
* ex. /aaa/bbb become aaa/bbb
|
849 |
+
* ex. C:\aaa\bbb become aaa\bbb
|
850 |
+
*
|
851 |
+
* @param string $path
|
852 |
+
* @return string
|
853 |
+
*/
|
854 |
+
public static function removeRootPath($path)
|
855 |
+
{
|
856 |
+
return preg_replace('/^(?:[A-Za-z]:)?[\/](.*)/', '$1', $path);
|
857 |
+
}
|
858 |
+
|
859 |
/**
|
860 |
* @param string $path Path to the file
|
861 |
* @param int $n Number of lines to get
|
871 |
return false;
|
872 |
}
|
873 |
|
874 |
+
$result = array();
|
875 |
+
$pos = -1;
|
876 |
$currentLine = '';
|
877 |
+
$counter = 0;
|
878 |
|
879 |
while ($counter < $n && -1 !== fseek($handle, $pos, SEEK_END)) {
|
880 |
$char = fgetc($handle);
|
881 |
if (PHP_EOL == $char) {
|
882 |
$trimmedValue = trim($currentLine);
|
883 |
+
|
884 |
if (!empty($trimmedValue)) {
|
885 |
$result[] = $currentLine;
|
886 |
$counter++;
|
887 |
}
|
888 |
$currentLine = '';
|
889 |
} else {
|
890 |
+
$currentLine = $char.$currentLine;
|
891 |
}
|
892 |
$pos--;
|
893 |
}
|
896 |
return array_reverse($result);
|
897 |
}
|
898 |
}
|
899 |
+
}
|
lib/snaplib/class.snaplib.u.json.php
CHANGED
@@ -89,6 +89,15 @@ if (!class_exists('DupLiteSnapJsonU', false)) {
|
|
89 |
return call_user_func_array('json_encode', $args);
|
90 |
}
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
/**
|
93 |
* wp_json_encode with pretty print if define exists
|
94 |
*
|
89 |
return call_user_func_array('json_encode', $args);
|
90 |
}
|
91 |
|
92 |
+
/**
|
93 |
+
* @param mixed $val object to be encoded
|
94 |
+
* @return string escaped json string
|
95 |
+
*/
|
96 |
+
public static function json_encode_esc_attr($val)
|
97 |
+
{
|
98 |
+
return esc_attr(json_encode($val));
|
99 |
+
}
|
100 |
+
|
101 |
/**
|
102 |
* wp_json_encode with pretty print if define exists
|
103 |
*
|
lib/snaplib/class.snaplib.u.string.php
CHANGED
@@ -45,6 +45,24 @@ if (!class_exists('DupLiteSnapLibStringU', false)) {
|
|
45 |
return (substr($haystack, 0, $length) === $needle);
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* Returns true if the $needle is found in the $haystack
|
50 |
*
|
@@ -58,5 +76,44 @@ if (!class_exists('DupLiteSnapLibStringU', false)) {
|
|
58 |
$pos = strpos($haystack, $needle);
|
59 |
return ($pos !== false);
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
}
|
45 |
return (substr($haystack, 0, $length) === $needle);
|
46 |
}
|
47 |
|
48 |
+
/**
|
49 |
+
* Returns true if the $haystack string end with the $needle
|
50 |
+
*
|
51 |
+
* @param string $haystack The full string to search in
|
52 |
+
* @param string $needle The string to for
|
53 |
+
*
|
54 |
+
* @return bool Returns true if the $haystack string starts with the $needle
|
55 |
+
*/
|
56 |
+
public static function endsWith($haystack, $needle)
|
57 |
+
{
|
58 |
+
$length = strlen($needle);
|
59 |
+
if ($length == 0) {
|
60 |
+
return true;
|
61 |
+
}
|
62 |
+
|
63 |
+
return (substr($haystack, -$length) === $needle);
|
64 |
+
}
|
65 |
+
|
66 |
/**
|
67 |
* Returns true if the $needle is found in the $haystack
|
68 |
*
|
76 |
$pos = strpos($haystack, $needle);
|
77 |
return ($pos !== false);
|
78 |
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
*
|
82 |
+
* @param string $glue
|
83 |
+
* @param array $pieces
|
84 |
+
* @param string $format
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public static function implodeKeyVals($glue, $pieces, $format = '%s="%s"')
|
88 |
+
{
|
89 |
+
$strList = array();
|
90 |
+
foreach ($pieces as $key => $value) {
|
91 |
+
if (is_scalar($value)) {
|
92 |
+
$strList[] = sprintf($format, $key, $value);
|
93 |
+
} else {
|
94 |
+
$strList[] = sprintf($format, $key, print_r($value, true));
|
95 |
+
}
|
96 |
+
}
|
97 |
+
return implode($glue, $strList);
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Replace last occurrence
|
102 |
+
*
|
103 |
+
* @param String $search The value being searched for
|
104 |
+
* @param String $replace The replacement value that replaces found search values
|
105 |
+
* @param String $str The string or array being searched and replaced on, otherwise known as the haystack
|
106 |
+
* @param Boolean $caseSensitive Whether the replacement should be case sensitive or not
|
107 |
+
*
|
108 |
+
* @return String
|
109 |
+
*/
|
110 |
+
public static function strLastReplace($search, $replace, $str, $caseSensitive = true)
|
111 |
+
{
|
112 |
+
$pos = $caseSensitive ? strrpos($str, $search) : strripos($str, $search);
|
113 |
+
if (false !== $pos) {
|
114 |
+
$str = substr_replace($str, $replace, $pos, strlen($search));
|
115 |
+
}
|
116 |
+
return $str;
|
117 |
+
}
|
118 |
}
|
119 |
}
|
readme.txt
CHANGED
@@ -2,16 +2,16 @@
|
|
2 |
Contributors: corylamleorg, bobriley
|
3 |
Tags: migration, backup, duplicate, move, migrate, restore, transfer, clone, automate, copy site, migrator
|
4 |
Requires at least: 4.0
|
5 |
-
Tested up to: 5.
|
6 |
Requires PHP: 5.2.17
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPLv2
|
9 |
|
10 |
WordPress migration and backups are much easier with Duplicator! Clone, backup, move and transfer an entire site from one location to another.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
> With over **
|
15 |
|
16 |
For complete details visit [snapcreek.com](https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wp_org&utm_content=desc_details&utm_campaign=duplicator_free).
|
17 |
|
2 |
Contributors: corylamleorg, bobriley
|
3 |
Tags: migration, backup, duplicate, move, migrate, restore, transfer, clone, automate, copy site, migrator
|
4 |
Requires at least: 4.0
|
5 |
+
Tested up to: 5.5
|
6 |
Requires PHP: 5.2.17
|
7 |
+
Stable tag: 1.3.36
|
8 |
License: GPLv2
|
9 |
|
10 |
WordPress migration and backups are much easier with Duplicator! Clone, backup, move and transfer an entire site from one location to another.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
> With over **20 million downloads** Duplicator successfully gives WordPress users the ability to migrate, copy, move or clone a site from one location to another and also serves as a simple backup utility. Duplicator handles serialized and base64 serialized replacements. Standard WordPress migration and WordPress backups are easily handled by this plugin as are **zero downtime migrations**.
|
15 |
|
16 |
For complete details visit [snapcreek.com](https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wp_org&utm_content=desc_details&utm_campaign=duplicator_free).
|
17 |
|
uninstall.php
CHANGED
@@ -8,6 +8,7 @@ if (!defined('WP_UNINSTALL_PLUGIN')) {
|
|
8 |
}
|
9 |
require_once 'helper.php';
|
10 |
require_once 'define.php';
|
|
|
11 |
require_once 'classes/class.settings.php';
|
12 |
require_once 'classes/utilities/class.u.php';
|
13 |
require_once 'classes/class.plugin.upgrade.php';
|
@@ -17,18 +18,16 @@ DUP_Settings::init();
|
|
17 |
|
18 |
$table_name = $wpdb->prefix."duplicator_packages";
|
19 |
$wpdb->query("DROP TABLE IF EXISTS `{$table_name}`");
|
20 |
-
|
21 |
$wpdb->query("DELETE FROM ".$wpdb->usermeta." WHERE meta_key='".DUPLICATOR_ADMIN_NOTICES_USER_META_KEY."'");
|
22 |
|
23 |
delete_option(DUP_LITE_Plugin_Upgrade::DUP_VERSION_OPT_KEY);
|
24 |
delete_option('duplicator_usage_id');
|
25 |
|
26 |
-
//Remove entire
|
27 |
if (DUP_Settings::Get('uninstall_files')) {
|
28 |
-
|
29 |
-
$
|
30 |
-
$
|
31 |
-
$ssdir_installer = DUP_Util::safePath(DUPLICATOR_SSDIR_PATH.'/installer');
|
32 |
|
33 |
//Sanity check for strange setup
|
34 |
$check = glob("{$ssdir}/wp-config.php");
|
@@ -88,11 +87,9 @@ if (DUP_Settings::Get('uninstall_files')) {
|
|
88 |
@unlink("{$file}");
|
89 |
}
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
@rmdir($ssdir);
|
95 |
-
}
|
96 |
}
|
97 |
}
|
98 |
}
|
@@ -104,5 +101,4 @@ if (DUP_Settings::Get('uninstall_settings')) {
|
|
104 |
delete_option('duplicator_ui_view_state');
|
105 |
delete_option('duplicator_package_active');
|
106 |
delete_option("duplicator_exe_safe_mode");
|
107 |
-
}
|
108 |
-
?>
|
8 |
}
|
9 |
require_once 'helper.php';
|
10 |
require_once 'define.php';
|
11 |
+
require_once 'lib/snaplib/snaplib.all.php';
|
12 |
require_once 'classes/class.settings.php';
|
13 |
require_once 'classes/utilities/class.u.php';
|
14 |
require_once 'classes/class.plugin.upgrade.php';
|
18 |
|
19 |
$table_name = $wpdb->prefix."duplicator_packages";
|
20 |
$wpdb->query("DROP TABLE IF EXISTS `{$table_name}`");
|
|
|
21 |
$wpdb->query("DELETE FROM ".$wpdb->usermeta." WHERE meta_key='".DUPLICATOR_ADMIN_NOTICES_USER_META_KEY."'");
|
22 |
|
23 |
delete_option(DUP_LITE_Plugin_Upgrade::DUP_VERSION_OPT_KEY);
|
24 |
delete_option('duplicator_usage_id');
|
25 |
|
26 |
+
//Remove entire storage directory
|
27 |
if (DUP_Settings::Get('uninstall_files')) {
|
28 |
+
$ssdir = DUP_Settings::getSsdirPath();
|
29 |
+
$ssdir_tmp = DUP_Settings::getSsdirTmpPath();
|
30 |
+
$ssdir_installer = DUP_Settings::getSsdirInstallerPath();
|
|
|
31 |
|
32 |
//Sanity check for strange setup
|
33 |
$check = glob("{$ssdir}/wp-config.php");
|
87 |
@unlink("{$file}");
|
88 |
}
|
89 |
|
90 |
+
@rmdir($ssdir_installer);
|
91 |
+
@rmdir($ssdir_tmp);
|
92 |
+
@rmdir($ssdir);
|
|
|
|
|
93 |
}
|
94 |
}
|
95 |
}
|
101 |
delete_option('duplicator_ui_view_state');
|
102 |
delete_option('duplicator_package_active');
|
103 |
delete_option("duplicator_exe_safe_mode");
|
104 |
+
}
|
|
views/packages/controller.php
CHANGED
@@ -12,30 +12,24 @@ require_once(DUPLICATOR_PLUGIN_PATH . '/views/inc.header.php');
|
|
12 |
|
13 |
$current_view = (isset($_REQUEST['action']) && $_REQUEST['action'] == 'detail') ? 'detail' : 'main';
|
14 |
|
15 |
-
$
|
16 |
?>
|
17 |
<script>
|
18 |
jQuery(document).ready(function($) {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
var win = window.open(actionLocation, '_blank');
|
26 |
-
win.focus();
|
27 |
-
}
|
28 |
-
else {
|
29 |
-
location.href = actionLocation;
|
30 |
-
}
|
31 |
};
|
32 |
|
33 |
-
Duplicator.Pack.DownloadFile = function(
|
34 |
{
|
35 |
var link = document.createElement('a');
|
36 |
link.target = "_blank";
|
37 |
-
link.download =
|
38 |
-
link.href= url;
|
39 |
document.body.appendChild(link);
|
40 |
|
41 |
// click event fire
|
12 |
|
13 |
$current_view = (isset($_REQUEST['action']) && $_REQUEST['action'] == 'detail') ? 'detail' : 'main';
|
14 |
|
15 |
+
$download_installer_nonce = wp_create_nonce('duplicator_download_installer');
|
16 |
?>
|
17 |
<script>
|
18 |
jQuery(document).ready(function($) {
|
19 |
|
20 |
+
Duplicator.Pack.DownloadInstaller = function (json)
|
21 |
+
{
|
22 |
+
var actionLocation = ajaxurl + '?action=duplicator_download_installer&id=' + json.id + '&hash='+ json.hash +'&nonce=' + '<?php echo $download_installer_nonce; ?>';
|
23 |
+
location.href = actionLocation;
|
24 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
};
|
26 |
|
27 |
+
Duplicator.Pack.DownloadFile = function(json)
|
28 |
{
|
29 |
var link = document.createElement('a');
|
30 |
link.target = "_blank";
|
31 |
+
link.download = json.filename;
|
32 |
+
link.href= json.url;
|
33 |
document.body.appendChild(link);
|
34 |
|
35 |
// click event fire
|
views/packages/details/controller.php
CHANGED
@@ -9,7 +9,7 @@ $package_id = isset($_REQUEST["id"]) ? sanitize_text_field($_REQUEST["id"]) :
|
|
9 |
|
10 |
$package = DUP_Package::getByID($package_id);
|
11 |
$err_found = ($package == null || $package->Status < 100);
|
12 |
-
$link_log = "{$package->
|
13 |
$err_link_log = "<a target='_blank' href='".esc_url($link_log)."' >" . esc_html__('package log', 'duplicator') . '</a>';
|
14 |
$err_link_faq = '<a target="_blank" href="https://snapcreek.com/duplicator/docs/faqs-tech/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_campaign=problem_resolution&utm_content=pkg_details_faq">' . esc_html__('FAQ', 'duplicator') . '</a>';
|
15 |
$err_link_ticket = '<a target="_blank" href="https://snapcreek.com/duplicator/docs/faqs-tech/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_campaign=problem_resolution&utm_content=pkg_details_resources#faq-resource">' . esc_html__('resources page', 'duplicator') . '</a>';
|
9 |
|
10 |
$package = DUP_Package::getByID($package_id);
|
11 |
$err_found = ($package == null || $package->Status < 100);
|
12 |
+
$link_log = DUP_Settings::getSsdirUrl()."/{$package->NameHash}.log";
|
13 |
$err_link_log = "<a target='_blank' href='".esc_url($link_log)."' >" . esc_html__('package log', 'duplicator') . '</a>';
|
14 |
$err_link_faq = '<a target="_blank" href="https://snapcreek.com/duplicator/docs/faqs-tech/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_campaign=problem_resolution&utm_content=pkg_details_faq">' . esc_html__('FAQ', 'duplicator') . '</a>';
|
15 |
$err_link_ticket = '<a target="_blank" href="https://snapcreek.com/duplicator/docs/faqs-tech/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_campaign=problem_resolution&utm_content=pkg_details_resources#faq-resource">' . esc_html__('resources page', 'duplicator') . '</a>';
|
views/packages/details/detail.php
CHANGED
@@ -6,37 +6,21 @@ $ui_css_storage = (isset($view_state['dup-package-dtl-storage-panel']) && $view_
|
|
6 |
$ui_css_archive = (isset($view_state['dup-package-dtl-archive-panel']) && $view_state['dup-package-dtl-archive-panel']) ? 'display:block' : 'display:none';
|
7 |
$ui_css_install = (isset($view_state['dup-package-dtl-install-panel']) && $view_state['dup-package-dtl-install-panel']) ? 'display:block' : 'display:none';
|
8 |
|
9 |
-
$
|
10 |
-
$
|
11 |
-
$
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
$
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
'hash' => $package->Hash,
|
25 |
-
'file' => 'archive'
|
26 |
-
),
|
27 |
-
$base_url
|
28 |
-
);
|
29 |
-
$link_installer = add_query_arg(
|
30 |
-
array(
|
31 |
-
'action' => 'duplicator_download',
|
32 |
-
'id' => $package->ID,
|
33 |
-
'hash' => $package->Hash,
|
34 |
-
'file' => 'installer'
|
35 |
-
),
|
36 |
-
$base_url
|
37 |
-
);
|
38 |
-
$link_log = "{$package->StoreURL}{$package->NameHash}.log";
|
39 |
-
$link_scan = "{$package->StoreURL}{$package->NameHash}_scan.json";
|
40 |
|
41 |
$debug_on = DUP_Settings::Get('package_debug');
|
42 |
$mysqldump_on = DUP_Settings::Get('package_mysqldump') && DUP_DB::getMySqlDumpPath();
|
@@ -147,28 +131,28 @@ GENERAL -->
|
|
147 |
<div id="dup-downloads-area">
|
148 |
<?php if (!$err_found) :?>
|
149 |
|
150 |
-
<button class="button" onclick="Duplicator.Pack.
|
151 |
-
<button class="button" onclick="Duplicator.Pack.
|
152 |
-
<button class="button" onclick="Duplicator.Pack.
|
153 |
-
<button class="button" onclick="Duplicator.Pack.
|
154 |
-
<button class="button" onclick="Duplicator.Pack.ShowLinksDialog(
|
155 |
<?php else: ?>
|
156 |
-
<button class="button" onclick="Duplicator.Pack.
|
157 |
<?php endif; ?>
|
158 |
</div>
|
159 |
<?php if (!$err_found) :?>
|
160 |
<table class="dup-sub-list">
|
161 |
<tr>
|
162 |
<td><?php esc_html_e('Archive', 'duplicator') ?>: </td>
|
163 |
-
<td><a href="<?php echo esc_url($
|
164 |
</tr>
|
165 |
<tr>
|
166 |
<td><?php esc_html_e('Installer', 'duplicator') ?>: </td>
|
167 |
-
<td><a href="#" onclick="Duplicator.Pack.
|
168 |
</tr>
|
169 |
<tr>
|
170 |
<td><?php esc_html_e('Database', 'duplicator') ?>: </td>
|
171 |
-
<td><a href="<?php echo
|
172 |
</tr>
|
173 |
</table>
|
174 |
<?php endif; ?>
|
@@ -222,7 +206,7 @@ STORAGE -->
|
|
222 |
<tr class="package-row">
|
223 |
<td><i class="fa fa-server"></i> <?php esc_html_e('Default', 'duplicator');?></td>
|
224 |
<td><?php esc_html_e("Local", 'duplicator'); ?></td>
|
225 |
-
<td><?php echo esc_html(
|
226 |
</tr>
|
227 |
<tr>
|
228 |
<td colspan="4">
|
@@ -418,13 +402,13 @@ jQuery(document).ready(function($)
|
|
418 |
* @param db The path to the sql file
|
419 |
* @param install The path to the install file
|
420 |
* @param pack The path to the package file */
|
421 |
-
Duplicator.Pack.ShowLinksDialog = function(
|
422 |
{
|
423 |
var url = '#TB_inline?width=650&height=350&inlineId=dup-dlg-quick-path';
|
424 |
tb_show("<?php esc_html_e('Package File Links', 'duplicator') ?>", url);
|
425 |
|
426 |
|
427 |
-
var msg = <?php printf('"%s:\n" +
|
428 |
esc_html__("DATABASE", 'duplicator'),
|
429 |
esc_html__("ARCHIVE", 'duplicator'),
|
430 |
esc_html__("LOG", 'duplicator'));
|
6 |
$ui_css_archive = (isset($view_state['dup-package-dtl-archive-panel']) && $view_state['dup-package-dtl-archive-panel']) ? 'display:block' : 'display:none';
|
7 |
$ui_css_install = (isset($view_state['dup-package-dtl-install-panel']) && $view_state['dup-package-dtl-install-panel']) ? 'display:block' : 'display:none';
|
8 |
|
9 |
+
$sqlDownloadInfo = $package->getPackageFileDownloadInfo(DUP_PackageFileType::SQL);
|
10 |
+
$archiveDownloadInfo = $package->getPackageFileDownloadInfo(DUP_PackageFileType::Archive);
|
11 |
+
$logDownloadInfo = $package->getPackageFileDownloadInfo(DUP_PackageFileType::Log);
|
12 |
+
$scanDownloadInfo = $package->getPackageFileDownloadInfo(DUP_PackageFileType::Scan);
|
13 |
+
$installerDownloadInfo = $package->getInstallerDownloadInfo();
|
14 |
+
$sqlDownloadInfoJson = DupLiteSnapJsonU::json_encode_esc_attr($sqlDownloadInfo);
|
15 |
+
$archiveDownloadInfoJson = DupLiteSnapJsonU::json_encode_esc_attr($archiveDownloadInfo);
|
16 |
+
$logDownloadInfoJson = DupLiteSnapJsonU::json_encode_esc_attr($logDownloadInfo);
|
17 |
+
$scanDownloadInfoJson = DupLiteSnapJsonU::json_encode_esc_attr($scanDownloadInfo);
|
18 |
+
$installerDownloadInfoJson = DupLiteSnapJsonU::json_encode_esc_attr($installerDownloadInfo);
|
19 |
+
$showLinksDialogJson = DupLiteSnapJsonU::json_encode_esc_attr(array(
|
20 |
+
"sql" => $sqlDownloadInfo["url"],
|
21 |
+
"archive" => $archiveDownloadInfo["url"],
|
22 |
+
"log" => $logDownloadInfo["url"],
|
23 |
+
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
$debug_on = DUP_Settings::Get('package_debug');
|
26 |
$mysqldump_on = DUP_Settings::Get('package_mysqldump') && DUP_DB::getMySqlDumpPath();
|
131 |
<div id="dup-downloads-area">
|
132 |
<?php if (!$err_found) :?>
|
133 |
|
134 |
+
<button class="button" onclick="Duplicator.Pack.DownloadInstaller(<?php echo $installerDownloadInfoJson; ?>);return false;"><i class="fa fa-bolt fa-sm"></i> Installer</button>
|
135 |
+
<button class="button" onclick="Duplicator.Pack.DownloadFile(<?php echo $archiveDownloadInfoJson; ?>);return false;"><i class="far fa-file-archive"></i> Archive - <?php echo esc_html($package->ZipSize); ?></button>
|
136 |
+
<button class="button" onclick="Duplicator.Pack.DownloadFile(<?php echo $sqlDownloadInfoJson; ?>);return false;"><i class="fa fa-table fa-sm"></i> SQL - <?php echo esc_html(DUP_Util::byteSize($package->Database->Size)) ?></button>
|
137 |
+
<button class="button" onclick="Duplicator.Pack.DownloadFile(<?php echo $logDownloadInfoJson; ?>);return false;"><i class="fa fa-table fa-sm"></i> <?php esc_html_e('Log', 'duplicator'); ?> </button>
|
138 |
+
<button class="button" onclick="Duplicator.Pack.ShowLinksDialog(<?php echo $showLinksDialogJson;?>);" class="thickbox"><i class="fa fa-lock fa-xs"></i> <?php esc_html_e("Share", 'duplicator')?></button>
|
139 |
<?php else: ?>
|
140 |
+
<button class="button" onclick="Duplicator.Pack.DownloadFile(<?php echo $logDownloadInfoJson; ?>);return false;"><i class="fa fa-table fa-sm"></i> Log </button>
|
141 |
<?php endif; ?>
|
142 |
</div>
|
143 |
<?php if (!$err_found) :?>
|
144 |
<table class="dup-sub-list">
|
145 |
<tr>
|
146 |
<td><?php esc_html_e('Archive', 'duplicator') ?>: </td>
|
147 |
+
<td><a href="<?php echo esc_url($archiveDownloadInfo["url"]); ?>"><?php echo esc_html($package->Archive->File); ?></a></td>
|
148 |
</tr>
|
149 |
<tr>
|
150 |
<td><?php esc_html_e('Installer', 'duplicator') ?>: </td>
|
151 |
+
<td><a href="#" onclick="Duplicator.Pack.DownloadInstaller(<?php echo $installerDownloadInfoJson; ?>);return false;" ><?php echo esc_html($package->Installer->File) ?></a></td>
|
152 |
</tr>
|
153 |
<tr>
|
154 |
<td><?php esc_html_e('Database', 'duplicator') ?>: </td>
|
155 |
+
<td><a href="<?php echo $sqlDownloadInfo["url"]; ?>" target="_blank"><?php echo esc_html($package->Database->File); ?></a></td>
|
156 |
</tr>
|
157 |
</table>
|
158 |
<?php endif; ?>
|
206 |
<tr class="package-row">
|
207 |
<td><i class="fa fa-server"></i> <?php esc_html_e('Default', 'duplicator');?></td>
|
208 |
<td><?php esc_html_e("Local", 'duplicator'); ?></td>
|
209 |
+
<td><?php echo esc_html(DUP_Settings::getSsdirPath()); ?></td>
|
210 |
</tr>
|
211 |
<tr>
|
212 |
<td colspan="4">
|
402 |
* @param db The path to the sql file
|
403 |
* @param install The path to the install file
|
404 |
* @param pack The path to the package file */
|
405 |
+
Duplicator.Pack.ShowLinksDialog = function(json)
|
406 |
{
|
407 |
var url = '#TB_inline?width=650&height=350&inlineId=dup-dlg-quick-path';
|
408 |
tb_show("<?php esc_html_e('Package File Links', 'duplicator') ?>", url);
|
409 |
|
410 |
|
411 |
+
var msg = <?php printf('"%s:\n" + json.sql + "\n\n%s:\n" + json.archive + "\n\n%s:\n" + json.log;',
|
412 |
esc_html__("DATABASE", 'duplicator'),
|
413 |
esc_html__("ARCHIVE", 'duplicator'),
|
414 |
esc_html__("LOG", 'duplicator'));
|
views/packages/main/packages.php
CHANGED
@@ -153,14 +153,14 @@ if (DUP_Settings::Get('installer_name_mode') == DUP_Settings::INSTALLER_NAME_MOD
|
|
153 |
<th style="width: 70px;"><?php esc_html_e("Size", 'duplicator') ?></th>
|
154 |
<th><?php esc_html_e("Package Name", 'duplicator') ?></th>
|
155 |
<th class="inst-name">
|
156 |
-
<a href='admin.php?page=duplicator-settings&tab=packageadmin.php?page=duplicator-settings&tab=package#installer-
|
157 |
<?php
|
158 |
esc_html_e("Installer Name", 'duplicator');
|
159 |
?>
|
160 |
</a>
|
161 |
<i class="fas fa-question-circle fa-sm"
|
162 |
data-tooltip-title="<?php esc_html_e("Installer Name:", 'duplicator'); ?>"
|
163 |
-
data-tooltip="<?php
|
164 |
</i>
|
165 |
</th>
|
166 |
<th style="text-align:center; width: 200px;">
|
@@ -194,13 +194,12 @@ if (DUP_Settings::Get('installer_name_mode') == DUP_Settings::INSTALLER_NAME_MOD
|
|
194 |
$pack_name = $Package->Name;
|
195 |
$pack_archive_size = $Package->getArchiveSize();
|
196 |
$pack_perc = $Package->Status;
|
197 |
-
$pack_storeurl = $Package->StoreURL;
|
198 |
$pack_dbonly = $Package->Archive->ExportOnlyDB;
|
199 |
$pack_build_mode = ($Package->Archive->Format === 'ZIP') ? true : false;
|
200 |
|
201 |
//Links
|
202 |
$uniqueid = $Package->NameHash;
|
203 |
-
$packagepath =
|
204 |
|
205 |
$css_alt = ($packageTablerowCount % 2 != 0) ? '' : 'alternate';
|
206 |
|
@@ -244,10 +243,10 @@ if (DUP_Settings::Get('installer_name_mode') == DUP_Settings::INSTALLER_NAME_MOD
|
|
244 |
<span data-dup-copy-text="<?php echo $installerName; ?>" ><i class='far fa-copy' style='cursor: pointer'></i>
|
245 |
</td>
|
246 |
<td class="get-btns">
|
247 |
-
<button id="<?php echo esc_attr("{$uniqueid}_installer.php"); ?>" class="button no-select" onclick="Duplicator.Pack.
|
248 |
<i class="fa fa-bolt fa-sm"></i> <?php esc_html_e("Installer", 'duplicator') ?>
|
249 |
</button>
|
250 |
-
<button id="<?php echo esc_attr("{$uniqueid}_archive.zip"); ?>" class="button no-select" onclick="Duplicator.Pack.DownloadFile(
|
251 |
<i class="far fa-file-archive"></i> <?php esc_html_e("Archive", 'duplicator') ?>
|
252 |
</button>
|
253 |
<button type="button" class="button no-select" title="<?php esc_attr_e("Package Details", 'duplicator') ?>" onclick="Duplicator.Pack.OpenPackageDetails(<?php echo "{$Package->ID}"; ?>);">
|
153 |
<th style="width: 70px;"><?php esc_html_e("Size", 'duplicator') ?></th>
|
154 |
<th><?php esc_html_e("Package Name", 'duplicator') ?></th>
|
155 |
<th class="inst-name">
|
156 |
+
<a href='admin.php?page=duplicator-settings&tab=packageadmin.php?page=duplicator-settings&tab=package#duplicator-installer-settings'>
|
157 |
<?php
|
158 |
esc_html_e("Installer Name", 'duplicator');
|
159 |
?>
|
160 |
</a>
|
161 |
<i class="fas fa-question-circle fa-sm"
|
162 |
data-tooltip-title="<?php esc_html_e("Installer Name:", 'duplicator'); ?>"
|
163 |
+
data-tooltip="<?php echo esc_attr($packageExeNameModeMsg); ?>" >
|
164 |
</i>
|
165 |
</th>
|
166 |
<th style="text-align:center; width: 200px;">
|
194 |
$pack_name = $Package->Name;
|
195 |
$pack_archive_size = $Package->getArchiveSize();
|
196 |
$pack_perc = $Package->Status;
|
|
|
197 |
$pack_dbonly = $Package->Archive->ExportOnlyDB;
|
198 |
$pack_build_mode = ($Package->Archive->Format === 'ZIP') ? true : false;
|
199 |
|
200 |
//Links
|
201 |
$uniqueid = $Package->NameHash;
|
202 |
+
$packagepath = DUP_Settings::getSsdirUrl().'/'.$Package->Archive->File;
|
203 |
|
204 |
$css_alt = ($packageTablerowCount % 2 != 0) ? '' : 'alternate';
|
205 |
|
243 |
<span data-dup-copy-text="<?php echo $installerName; ?>" ><i class='far fa-copy' style='cursor: pointer'></i>
|
244 |
</td>
|
245 |
<td class="get-btns">
|
246 |
+
<button id="<?php echo esc_attr("{$uniqueid}_installer.php"); ?>" class="button no-select" onclick="Duplicator.Pack.DownloadInstaller(<?php echo DupLiteSnapJsonU::json_encode_esc_attr($Package->getInstallerDownloadInfo()); ?>); return false;">
|
247 |
<i class="fa fa-bolt fa-sm"></i> <?php esc_html_e("Installer", 'duplicator') ?>
|
248 |
</button>
|
249 |
+
<button id="<?php echo esc_attr("{$uniqueid}_archive.zip"); ?>" class="button no-select" onclick="Duplicator.Pack.DownloadFile(<?php echo DupLiteSnapJsonU::json_encode_esc_attr($Package->getPackageFileDownloadInfo(DUP_PackageFileType::Archive)); ?>); return false;">
|
250 |
<i class="far fa-file-archive"></i> <?php esc_html_e("Archive", 'duplicator') ?>
|
251 |
</button>
|
252 |
<button type="button" class="button no-select" title="<?php esc_attr_e("Package Details", 'duplicator') ?>" onclick="Duplicator.Pack.OpenPackageDetails(<?php echo "{$Package->ID}"; ?>);">
|
views/packages/main/s1.setup1.php
CHANGED
@@ -170,8 +170,8 @@ SYSTEM REQUIREMENTS -->
|
|
170 |
<?php
|
171 |
$abs_path = duplicator_get_abs_path();
|
172 |
|
173 |
-
printf("<b>%s</b> [%s] <br/>", $dup_tests['IO']['SSDIR'],
|
174 |
-
printf("<b>%s</b> [%s] <br/>", $dup_tests['IO']['SSTMP'],
|
175 |
printf("<b>%s</b> [%s] <br/>", $dup_tests['IO']['WPROOT'], $abs_path);
|
176 |
?>
|
177 |
<div style="font-size:11px; padding-top: 3px">
|
@@ -209,6 +209,16 @@ SYSTEM REQUIREMENTS -->
|
|
209 |
echo " <i><a href='http://php.net/manual/en/mysqli.installation.php' target='_blank'>[" . esc_html__('more info', 'duplicator') . "]</a></i>";
|
210 |
?>
|
211 |
</small>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
</div>
|
213 |
</div>
|
214 |
|
170 |
<?php
|
171 |
$abs_path = duplicator_get_abs_path();
|
172 |
|
173 |
+
printf("<b>%s</b> [%s] <br/>", $dup_tests['IO']['SSDIR'], DUP_Settings::getSsdirPath());
|
174 |
+
printf("<b>%s</b> [%s] <br/>", $dup_tests['IO']['SSTMP'], DUP_Settings::getSsdirTmpPath());
|
175 |
printf("<b>%s</b> [%s] <br/>", $dup_tests['IO']['WPROOT'], $abs_path);
|
176 |
?>
|
177 |
<div style="font-size:11px; padding-top: 3px">
|
209 |
echo " <i><a href='http://php.net/manual/en/mysqli.installation.php' target='_blank'>[" . esc_html__('more info', 'duplicator') . "]</a></i>";
|
210 |
?>
|
211 |
</small>
|
212 |
+
<hr>
|
213 |
+
<table class="dup-sys-info-results">
|
214 |
+
<tr>
|
215 |
+
<td><a href="https://www.php.net/manual/en/mysqli.real-escape-string.php" target="_blank">mysqli_real_escape_string</a></td>
|
216 |
+
<td><?php echo esc_html($dup_tests['SRV']['MYSQL_ESC']); ?></td>
|
217 |
+
</tr>
|
218 |
+
</table>
|
219 |
+
<small>
|
220 |
+
<?php esc_html_e("The function mysqli_real_escape_string is not working properly. Please consult host support and ask them to switch to a different PHP version or configuration."); ?>
|
221 |
+
</small>
|
222 |
</div>
|
223 |
</div>
|
224 |
|
views/packages/main/s1.setup2.php
CHANGED
@@ -62,8 +62,9 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
|
62 |
div.dup-install-prefill-tab-pnl {min-height:180px !important; }
|
63 |
</style>
|
64 |
<?php
|
65 |
-
$action_url
|
66 |
-
$action_nonce_url
|
|
|
67 |
?>
|
68 |
<form id="dup-form-opts" method="post" action="<?php echo $action_nonce_url; ?>" data-parsley-validate="" autocomplete="oldpassword">
|
69 |
<input type="hidden" id="dup-form-opts-action" name="action" value="">
|
@@ -93,42 +94,56 @@ STORAGE -->
|
|
93 |
<div class="dup-box-arrow"></div>
|
94 |
</div>
|
95 |
<div class="dup-box-panel" id="dup-pack-storage-panel" style="<?php echo esc_html($ui_css_storage); ?>">
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
</div>
|
133 |
</div><br/>
|
134 |
|
62 |
div.dup-install-prefill-tab-pnl {min-height:180px !important; }
|
63 |
</style>
|
64 |
<?php
|
65 |
+
$action_url = admin_url("admin.php?page=duplicator&tab=new2&retry={$retry_state}");
|
66 |
+
$action_nonce_url = wp_nonce_url($action_url, 'new2-package');
|
67 |
+
$storage_position = DUP_Settings::Get('storage_position');
|
68 |
?>
|
69 |
<form id="dup-form-opts" method="post" action="<?php echo $action_nonce_url; ?>" data-parsley-validate="" autocomplete="oldpassword">
|
70 |
<input type="hidden" id="dup-form-opts-action" name="action" value="">
|
94 |
<div class="dup-box-arrow"></div>
|
95 |
</div>
|
96 |
<div class="dup-box-panel" id="dup-pack-storage-panel" style="<?php echo esc_html($ui_css_storage); ?>">
|
97 |
+
<div style="text-align: right; padding:0 5px 3px 0">
|
98 |
+
<a href="admin.php?page=duplicator-settings&tab=storage"><?php esc_html_e("[Storage Options]", 'duplicator'); ?> </a>
|
99 |
+
</div>
|
100 |
+
<table class="widefat package-tbl" style="margin-bottom:15px" >
|
101 |
+
<thead>
|
102 |
+
<tr>
|
103 |
+
<th style='width:200px'><?php esc_html_e("Name", 'duplicator'); ?></th>
|
104 |
+
<th style='width:100px'><?php esc_html_e("Type", 'duplicator'); ?></th>
|
105 |
+
<th style="white-space:nowrap"><?php esc_html_e("Location", 'duplicator'); ?></th>
|
106 |
+
</tr>
|
107 |
+
</thead>
|
108 |
+
<tbody>
|
109 |
+
<tr class="package-row">
|
110 |
+
<td>
|
111 |
+
<i class="fa fa-server"></i> <?php esc_html_e('Default', 'duplicator');?>
|
112 |
+
<i>
|
113 |
+
<?php
|
114 |
+
if ($storage_position === DUP_Settings::STORAGE_POSITION_LECAGY) {
|
115 |
+
esc_html_e("(Legacy Path)", 'duplicator');
|
116 |
+
} else {
|
117 |
+
esc_html_e("(Contents Path)", 'duplicator');
|
118 |
+
}
|
119 |
+
?>
|
120 |
+
</i>
|
121 |
+
</td>
|
122 |
+
<td><?php esc_html_e("Local", 'duplicator'); ?></td>
|
123 |
+
<td><?php echo DUP_Settings::getSsdirPath(); ?></td>
|
124 |
+
</tr>
|
125 |
+
<tr>
|
126 |
+
<td colspan="4" style="padding:7px 0 7px 7px">
|
127 |
+
<div class="dup-store-pro">
|
128 |
+
<span class="dup-pro-text">
|
129 |
+
<img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/amazon-64.png"); ?>" />
|
130 |
+
<img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/dropbox-64.png"); ?>" />
|
131 |
+
<img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/google_drive_64px.png"); ?>" />
|
132 |
+
<img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/onedrive-48px.png"); ?>" />
|
133 |
+
<img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/ftp-64.png"); ?>" />
|
134 |
+
<?php echo sprintf(__('%1$s, %2$s, %3$s, %4$s, %5$s and other storage options available in', 'duplicator'), 'Amazon', 'Dropbox', 'Google Drive', 'OneDrive', 'FTP/SFTP'); ?>
|
135 |
+
<a href="https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=free_storage&utm_campaign=duplicator_pro" target="_blank"><?php esc_html_e('Duplicator Pro', 'duplicator');?></a>
|
136 |
+
<i class="far fa-lightbulb"
|
137 |
+
data-tooltip-title="<?php esc_attr_e("Additional Storage:", 'duplicator'); ?>"
|
138 |
+
data-tooltip="<?php esc_attr_e('Duplicator Pro allows you to create a package and then store it at a custom location on this server or to a cloud '
|
139 |
+
. 'based location such as Google Drive, Amazon, Dropbox or FTP.', 'duplicator'); ?>">
|
140 |
+
</i>
|
141 |
+
</span>
|
142 |
+
</div>
|
143 |
+
</td>
|
144 |
+
</tr>
|
145 |
+
</tbody>
|
146 |
+
</table>
|
147 |
</div>
|
148 |
</div><br/>
|
149 |
|
views/packages/main/s2.scan3.php
CHANGED
@@ -504,15 +504,15 @@ DATABASE -->
|
|
504 |
<div style="padding: 7px; background-color:#F3B2B7; font-weight: bold ">
|
505 |
<?php
|
506 |
printf(__('The build can\'t continue because the total size of files and the database exceeds the %s limit that can be processed when creating a DupArchive package. ', 'duplicator'), $duparchive_max_limit);
|
507 |
-
printf(__('<a href="javascript:void(0)" onclick="jQuery(\'#data-ll-status-recommendations\').toggle()">Click for recommendations.</a>', 'duplicator'));
|
508 |
?>
|
|
|
509 |
</div>
|
510 |
<div class="info" id="data-ll-status-recommendations">
|
511 |
<?php
|
512 |
echo '<b>';
|
513 |
$lnk = '<a href="admin.php?page=duplicator-settings&tab=package" target="_blank">' . esc_html__('Archive Engine', 'duplicator') . '</a>';
|
514 |
-
printf(
|
515 |
-
. " With DupArchive, Duplicator is restricted to processing sites up to %s. To process larger sites, consider these recommendations. ", 'duplicator'), $duparchive_max_limit, $duparchive_max_limit);
|
516 |
echo '</b>';
|
517 |
echo '<br/><hr size="1" />';
|
518 |
|
@@ -708,7 +708,7 @@ jQuery(document).ready(function($)
|
|
708 |
{
|
709 |
|
710 |
Handlebars.registerHelper('stripWPRoot', function(path) {
|
711 |
-
return path.replace('<?php echo duplicator_get_abs_path(); ?>');
|
712 |
});
|
713 |
|
714 |
//Uncheck file names if directory is checked
|
504 |
<div style="padding: 7px; background-color:#F3B2B7; font-weight: bold ">
|
505 |
<?php
|
506 |
printf(__('The build can\'t continue because the total size of files and the database exceeds the %s limit that can be processed when creating a DupArchive package. ', 'duplicator'), $duparchive_max_limit);
|
|
|
507 |
?>
|
508 |
+
<a href="javascript:void(0)" onclick="jQuery('#data-ll-status-recommendations').slideToggle('slow');"><?php esc_html_e('Click for recommendations.', 'duplicator'); ?></a>
|
509 |
</div>
|
510 |
<div class="info" id="data-ll-status-recommendations">
|
511 |
<?php
|
512 |
echo '<b>';
|
513 |
$lnk = '<a href="admin.php?page=duplicator-settings&tab=package" target="_blank">' . esc_html__('Archive Engine', 'duplicator') . '</a>';
|
514 |
+
printf(esc_html__("The %s is set to create packages in the 'DupArchive' format. This custom format is used to overcome budget host constraints."
|
515 |
+
. " With DupArchive, Duplicator is restricted to processing sites up to %s. To process larger sites, consider these recommendations. ", 'duplicator'), $lnk, $duparchive_max_limit, $duparchive_max_limit);
|
516 |
echo '</b>';
|
517 |
echo '<br/><hr size="1" />';
|
518 |
|
708 |
{
|
709 |
|
710 |
Handlebars.registerHelper('stripWPRoot', function(path) {
|
711 |
+
return path.replace('<?php echo duplicator_get_abs_path(); ?>', '');
|
712 |
});
|
713 |
|
714 |
//Uncheck file names if directory is checked
|
views/packages/main/s3.build.php
CHANGED
@@ -253,7 +253,7 @@ TOOL BAR: STEPS -->
|
|
253 |
<div style="color:#777; padding: 15px 5px 5px 5px">
|
254 |
<b> <?php esc_html_e('Notice', 'duplicator'); ?></b><br/>
|
255 |
<?php
|
256 |
-
printf('<b><i class="fa fa-folder-o"></i> %s %s</b> <br/> %s', esc_html__('Build Folder:'),
|
257 |
__("On some servers the build will continue to run in the background. To validate if a build is still running; open the 'tmp' folder above and see "
|
258 |
."if the archive file is growing in size or check the main packages screen to see if the package completed. If it is not then your server "
|
259 |
."has strict timeout constraints.", 'duplicator')
|
@@ -618,8 +618,14 @@ jQuery(document).ready(function ($)
|
|
618 |
Duplicator.Pack.WireDownloadLinks = function(data)
|
619 |
{
|
620 |
var pack = data.package;
|
621 |
-
var
|
622 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
623 |
|
624 |
$('#dup-progress-bar-area').hide();
|
625 |
$('#dup-progress-area, #dup-msg-success').show(300);
|
@@ -630,9 +636,13 @@ jQuery(document).ready(function ($)
|
|
630 |
$('#dup-create-new').removeClass('disabled');
|
631 |
|
632 |
//Wire Up Downloads
|
633 |
-
$('#dup-btn-installer').click(function() {
|
|
|
|
|
|
|
|
|
634 |
$('#dup-btn-archive').click(function() {
|
635 |
-
Duplicator.Pack.DownloadFile(
|
636 |
return false;
|
637 |
});
|
638 |
|
253 |
<div style="color:#777; padding: 15px 5px 5px 5px">
|
254 |
<b> <?php esc_html_e('Notice', 'duplicator'); ?></b><br/>
|
255 |
<?php
|
256 |
+
printf('<b><i class="fa fa-folder-o"></i> %s %s</b> <br/> %s', esc_html__('Build Folder:'), DUP_Settings::getSsdirTmpPath(),
|
257 |
__("On some servers the build will continue to run in the background. To validate if a build is still running; open the 'tmp' folder above and see "
|
258 |
."if the archive file is growing in size or check the main packages screen to see if the package completed. If it is not then your server "
|
259 |
."has strict timeout constraints.", 'duplicator')
|
618 |
Duplicator.Pack.WireDownloadLinks = function(data)
|
619 |
{
|
620 |
var pack = data.package;
|
621 |
+
var archive_json = {
|
622 |
+
filename: pack.Archive.File,
|
623 |
+
url: "<?php echo DUP_Settings::getSsdirUrl(); ?>" + "/" + pack.Archive.File
|
624 |
+
};
|
625 |
+
var installer_json = {
|
626 |
+
id: pack.ID,
|
627 |
+
hash: pack.Hash
|
628 |
+
};
|
629 |
|
630 |
$('#dup-progress-bar-area').hide();
|
631 |
$('#dup-progress-area, #dup-msg-success').show(300);
|
636 |
$('#dup-create-new').removeClass('disabled');
|
637 |
|
638 |
//Wire Up Downloads
|
639 |
+
$('#dup-btn-installer').click(function() {
|
640 |
+
Duplicator.Pack.DownloadInstaller(installer_json);
|
641 |
+
return false;
|
642 |
+
});
|
643 |
+
|
644 |
$('#dup-btn-archive').click(function() {
|
645 |
+
Duplicator.Pack.DownloadFile(archive_json);
|
646 |
return false;
|
647 |
});
|
648 |
|
views/settings/general.php
CHANGED
@@ -4,25 +4,24 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
|
4 |
global $wp_version;
|
5 |
global $wpdb;
|
6 |
|
7 |
-
$action_updated
|
8 |
$action_response = __("General Settings Saved", 'duplicator');
|
9 |
|
10 |
//SAVE RESULTS
|
11 |
if (isset($_POST['action']) && $_POST['action'] == 'save') {
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
DUP_Settings::Set('uninstall_tables', isset($_POST['uninstall_tables']) ? "1" : "0");
|
21 |
-
DUP_Settings::Set('storage_htaccess_off', isset($_POST['storage_htaccess_off']) ? "1" : "0");
|
22 |
|
23 |
-
DUP_Settings::Set('wpfront_integrate', isset($_POST['wpfront_integrate']) ? "1" : "0");
|
24 |
-
DUP_Settings::Set('package_debug', isset($_POST['package_debug']) ? "1" : "0");
|
25 |
-
|
26 |
$skip_archive_scan = filter_input(INPUT_POST, 'skip_archive_scan', FILTER_VALIDATE_BOOLEAN);
|
27 |
DUP_Settings::Set('skip_archive_scan', $skip_archive_scan);
|
28 |
|
@@ -32,7 +31,32 @@ if (isset($_POST['action']) && $_POST['action'] == 'save') {
|
|
32 |
$unhook_third_party_css = filter_input(INPUT_POST, 'unhook_third_party_css', FILTER_VALIDATE_BOOLEAN);
|
33 |
DUP_Settings::Set('unhook_third_party_css', $unhook_third_party_css);
|
34 |
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
dup_log::trace("#### trace log enabled");
|
38 |
// Trace on
|
@@ -42,7 +66,6 @@ if (isset($_POST['action']) && $_POST['action'] == 'save') {
|
|
42 |
}
|
43 |
|
44 |
DUP_Settings::Set('trace_log_enabled', 1);
|
45 |
-
|
46 |
} else {
|
47 |
dup_log::trace("#### trace log disabled");
|
48 |
|
@@ -51,19 +74,18 @@ if (isset($_POST['action']) && $_POST['action'] == 'save') {
|
|
51 |
}
|
52 |
|
53 |
DUP_Settings::Save();
|
54 |
-
|
55 |
-
|
56 |
}
|
57 |
|
58 |
-
$trace_log_enabled
|
59 |
-
$uninstall_settings
|
60 |
-
$uninstall_files
|
61 |
-
$uninstall_tables
|
62 |
-
$
|
63 |
-
$
|
64 |
-
$
|
65 |
-
$
|
66 |
-
$skip_archive_scan = DUP_Settings::Get('skip_archive_scan');
|
67 |
$unhook_third_party_js = DUP_Settings::Get('unhook_third_party_js');
|
68 |
$unhook_third_party_css = DUP_Settings::Get('unhook_third_party_css');
|
69 |
?>
|
@@ -92,71 +114,21 @@ $unhook_third_party_css = DUP_Settings::Get('unhook_third_party_css');
|
|
92 |
<tr valign="top">
|
93 |
<th scope="row"><label><?php esc_html_e("Version", 'duplicator'); ?></label></th>
|
94 |
<td>
|
95 |
-
|
96 |
-
|
97 |
-
</td>
|
98 |
-
</tr>
|
99 |
-
<tr valign="top">
|
100 |
-
<th scope="row"><label><?php esc_html_e("Uninstall", 'duplicator'); ?></label></th>
|
101 |
-
<td>
|
102 |
-
<input type="checkbox" name="uninstall_settings" id="uninstall_settings" <?php echo ($uninstall_settings) ? 'checked="checked"' : ''; ?> />
|
103 |
-
<label for="uninstall_settings"><?php esc_html_e("Delete Plugin Settings", 'duplicator') ?> </label><br/>
|
104 |
-
|
105 |
-
<input type="checkbox" name="uninstall_files" id="uninstall_files" <?php echo ($uninstall_files) ? 'checked="checked"' : ''; ?> />
|
106 |
-
<label for="uninstall_files"><?php esc_html_e("Delete Entire Storage Directory", 'duplicator') ?></label><br/>
|
107 |
-
|
108 |
</td>
|
109 |
</tr>
|
110 |
<tr valign="top">
|
111 |
-
<th scope="row"><label><?php esc_html_e("
|
112 |
<td>
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
</tr>
|
121 |
-
<tr>
|
122 |
-
<td><label><input type="radio" name="storage" /><?php esc_html_e('Contents Path:', 'duplicator'); ?></label></td>
|
123 |
-
<td><i>/public_html/mysite/wp-contents/backups-duplicator-lite</i></td>
|
124 |
-
</tr>
|
125 |
-
</table>
|
126 |
-
|
127 |
-
<p class="description" style="max-width:800px">
|
128 |
-
<?php esc_html_e("The storage location is where all the package files are stored. If your host has troubles writting content to the root directory then use the Contents Path.", 'duplicator'); ?>
|
129 |
-
</p>
|
130 |
-
<br/><br/>-->
|
131 |
-
|
132 |
-
<input type="checkbox" name="storage_htaccess_off" id="storage_htaccess_off" <?php echo ($storage_htaccess_off) ? 'checked="checked"' : ''; ?> />
|
133 |
-
<label for="storage_htaccess_off"><?php esc_html_e("Disable .htaccess File In Storage Directory", 'duplicator') ?> </label>
|
134 |
-
<p class="description">
|
135 |
-
<?php esc_html_e("Disable if issues occur when downloading installer/archive files.", 'duplicator'); ?>
|
136 |
</p>
|
137 |
-
</td>
|
138 |
-
</tr>
|
139 |
-
<tr>
|
140 |
-
<th scope="row"><label><?php esc_html_e("Custom Roles", 'duplicator'); ?></label></th>
|
141 |
-
<td>
|
142 |
-
<input type="checkbox" name="wpfront_integrate" id="wpfront_integrate" <?php echo ($wpfront_integrate) ? 'checked="checked"' : ''; ?> <?php echo $wpfront_ready ? '' : 'disabled'; ?> />
|
143 |
-
<label for="wpfront_integrate"><?php esc_html_e("Enable User Role Editor Plugin Integration", 'duplicator'); ?></label>
|
144 |
-
<p class="description" style="max-width: 800px">
|
145 |
-
<?php printf('%s <a href="https://wordpress.org/plugins/wpfront-user-role-editor/" target="_blank">%s</a> %s'
|
146 |
-
. ' <a href="https://wpfront.com/user-role-editor-pro/?ref=3" target="_blank">%s</a> %s '
|
147 |
-
. ' <a href="https://wpfront.com/integrations/duplicator-integration/?ref=3" target="_blank">%s</a>. %s'
|
148 |
-
. ' <a href="https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=user_role_plugin&utm_campaign=duplicator_pro" target="_blank">%s</a>.',
|
149 |
-
esc_html__('To enable custom roles with Duplicator please install the ', 'duplicator'),
|
150 |
-
esc_html__('User Role Editor Free', 'duplicator'),
|
151 |
-
esc_html__('OR', 'duplicator'),
|
152 |
-
esc_html__('User Role Editor Professional', 'duplicator'),
|
153 |
-
esc_html__('plugins. Please note the User Role Editor Plugin is a separate plugin and does not unlock any Duplicator features. For more information on User Role Editor plugin please see', 'duplicator'),
|
154 |
-
esc_html__('the documentation', 'duplicator'),
|
155 |
-
esc_html__('If you are interested in downloading Duplicator Pro then please use', 'duplicator'),
|
156 |
-
esc_html__('this link', 'duplicator')
|
157 |
-
);
|
158 |
-
?>
|
159 |
-
</p>
|
160 |
</td>
|
161 |
</tr>
|
162 |
</table>
|
@@ -179,13 +151,17 @@ $unhook_third_party_css = DUP_Settings::Get('unhook_third_party_css');
|
|
179 |
<label for="trace_log_enabled"><?php esc_html_e("Enabled", 'duplicator') ?> </label><br/>
|
180 |
<p class="description">
|
181 |
<?php
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
?>
|
186 |
</p><br/>
|
187 |
-
<button class="button" <?php
|
188 |
-
|
|
|
|
|
|
|
|
|
189 |
</button>
|
190 |
</td>
|
191 |
</tr>
|
@@ -203,22 +179,26 @@ $unhook_third_party_css = DUP_Settings::Get('unhook_third_party_css');
|
|
203 |
<i class="fas fa-redo fa-sm"></i> <?php esc_html_e('Reset Packages', 'duplicator'); ?>
|
204 |
</button>
|
205 |
<p class="description">
|
206 |
-
<?php
|
207 |
-
|
|
|
|
|
208 |
<i class="fas fa-question-circle fa-sm"
|
209 |
-
|
210 |
-
|
211 |
</p>
|
212 |
</td>
|
213 |
</tr>
|
214 |
<tr valign="top">
|
215 |
<th scope="row"><label><?php esc_html_e('Archive scan', 'duplicator'); ?></label></th>
|
216 |
<td>
|
217 |
-
<input type="checkbox" name="skip_archive_scan" id="_skip_archive_scan" <?php checked(
|
218 |
<label for="_skip_archive_scan"><?php esc_html_e("Skip", 'duplicator') ?> </label><br/>
|
219 |
<p class="description">
|
220 |
-
<?php
|
221 |
-
|
|
|
|
|
222 |
</p>
|
223 |
</td>
|
224 |
</tr>
|
@@ -254,12 +234,36 @@ $unhook_third_party_css = DUP_Settings::Get('unhook_third_party_css');
|
|
254 |
</p>
|
255 |
</td>
|
256 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
</table>
|
258 |
|
259 |
<p class="submit" style="margin: 20px 0px 0xp 5px;">
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
|
264 |
</form>
|
265 |
|
@@ -271,19 +275,19 @@ $reset_confirm->title = __('Reset Packages ?', 'duplicator');
|
|
271 |
$reset_confirm->message = __('This will clear and reset all of the current temporary packages. Would you like to continue?', 'duplicator');
|
272 |
$reset_confirm->progressText = __('Resetting settings, Please Wait...', 'duplicator');
|
273 |
$reset_confirm->jscallback = 'Duplicator.Pack.ResetAll()';
|
274 |
-
$reset_confirm->progressOn
|
275 |
$reset_confirm->okText = __('Yes', 'duplicator');
|
276 |
$reset_confirm->cancelText = __('No', 'duplicator');
|
277 |
$reset_confirm->closeOnConfirm = true;
|
278 |
$reset_confirm->initConfirm();
|
279 |
|
280 |
-
$msg_ajax_error
|
281 |
-
$msg_ajax_error->hide_on_init
|
282 |
$msg_ajax_error->is_dismissible = true;
|
283 |
$msg_ajax_error->initMessage();
|
284 |
|
285 |
-
$msg_response_error
|
286 |
-
$msg_response_error->hide_on_init
|
287 |
$msg_response_error->is_dismissible = true;
|
288 |
$msg_response_error->initMessage();
|
289 |
|
@@ -293,65 +297,65 @@ $msg_response_success->is_dismissible = true;
|
|
293 |
$msg_response_success->initMessage();
|
294 |
?>
|
295 |
<script>
|
296 |
-
jQuery(document).ready(function($)
|
297 |
-
{
|
298 |
-
var msgDebug = <?php echo DUP_Util::isWpDebug() ? 'true' : 'false'; ?>;
|
299 |
-
|
300 |
-
// which: 0=installer, 1=archive, 2=sql file, 3=log
|
301 |
-
Duplicator.Pack.DownloadTraceLog = function ()
|
302 |
{
|
303 |
-
var
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
var message = '<?php _e('Packages successfully reset', 'duplicator'); ?>';
|
329 |
if (msgDebug) {
|
330 |
-
|
331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
}
|
333 |
-
|
334 |
-
|
335 |
-
$msg_response_success->showMessage();
|
336 |
-
?>
|
337 |
-
} else {
|
338 |
-
var message = '<?php _e('RESPONSE ERROR!', 'duplicator'); ?>'+ '<br><br>' + result.data.message;
|
339 |
if (msgDebug) {
|
340 |
-
|
341 |
}
|
342 |
-
|
343 |
-
$msg_response_error->updateMessage('message');
|
344 |
-
$msg_response_error->showMessage();
|
345 |
-
?>
|
346 |
-
}
|
347 |
-
},
|
348 |
-
error: function (result) {
|
349 |
-
if (msgDebug) {
|
350 |
-
console.log(result);
|
351 |
}
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
};
|
356 |
-
});
|
357 |
</script>
|
4 |
global $wp_version;
|
5 |
global $wpdb;
|
6 |
|
7 |
+
$action_updated = null;
|
8 |
$action_response = __("General Settings Saved", 'duplicator');
|
9 |
|
10 |
//SAVE RESULTS
|
11 |
if (isset($_POST['action']) && $_POST['action'] == 'save') {
|
12 |
|
13 |
+
//Nonce Check
|
14 |
+
if (!isset($_POST['dup_settings_save_nonce_field']) || !wp_verify_nonce($_POST['dup_settings_save_nonce_field'], 'dup_settings_save')) {
|
15 |
+
die('Invalid token permissions to perform this request.');
|
16 |
+
}
|
17 |
+
|
18 |
+
DUP_Settings::Set('uninstall_settings', isset($_POST['uninstall_settings']) ? "1" : "0");
|
19 |
+
DUP_Settings::Set('uninstall_files', isset($_POST['uninstall_files']) ? "1" : "0");
|
20 |
+
DUP_Settings::Set('uninstall_tables', isset($_POST['uninstall_tables']) ? "1" : "0");
|
21 |
|
22 |
+
DUP_Settings::Set('wpfront_integrate', isset($_POST['wpfront_integrate']) ? "1" : "0");
|
23 |
+
DUP_Settings::Set('package_debug', isset($_POST['package_debug']) ? "1" : "0");
|
|
|
|
|
24 |
|
|
|
|
|
|
|
25 |
$skip_archive_scan = filter_input(INPUT_POST, 'skip_archive_scan', FILTER_VALIDATE_BOOLEAN);
|
26 |
DUP_Settings::Set('skip_archive_scan', $skip_archive_scan);
|
27 |
|
31 |
$unhook_third_party_css = filter_input(INPUT_POST, 'unhook_third_party_css', FILTER_VALIDATE_BOOLEAN);
|
32 |
DUP_Settings::Set('unhook_third_party_css', $unhook_third_party_css);
|
33 |
|
34 |
+
switch (filter_input(INPUT_POST, 'storage_position', FILTER_DEFAULT)) {
|
35 |
+
case DUP_Settings::STORAGE_POSITION_LECAGY:
|
36 |
+
$setPostion = DUP_Settings::STORAGE_POSITION_LECAGY;
|
37 |
+
break;
|
38 |
+
case DUP_Settings::STORAGE_POSITION_WP_CONTENT:
|
39 |
+
default:
|
40 |
+
$setPostion = DUP_Settings::STORAGE_POSITION_WP_CONTENT;
|
41 |
+
break;
|
42 |
+
}
|
43 |
+
|
44 |
+
if (DUP_Settings::setStoragePosition($setPostion) != true) {
|
45 |
+
$targetFolder = ($setPostion === DUP_Settings::STORAGE_POSITION_WP_CONTENT) ? DUP_Settings::getSsdirPathWpCont() : DUP_Settings::getSsdirPathLegacy();
|
46 |
+
?>
|
47 |
+
<div id="message" class="notice notice-error is-dismissible">
|
48 |
+
<p>
|
49 |
+
<b><?php esc_html_e('Storage folder move problem'); ?></b>
|
50 |
+
</p>
|
51 |
+
<p>
|
52 |
+
<?php echo sprintf(__('Duplicator can\'t change the storage folder to <i>%s</i>', 'duplicator'), esc_html($targetFolder)); ?><br>
|
53 |
+
<?php echo sprintf(__('Check the parent folder permissions. ( <i>%s</i> )', 'duplicator'), esc_html(dirname($targetFolder))); ?>
|
54 |
+
</p>
|
55 |
+
</div>
|
56 |
+
<?php
|
57 |
+
}
|
58 |
+
|
59 |
+
if (isset($_REQUEST['trace_log_enabled'])) {
|
60 |
|
61 |
dup_log::trace("#### trace log enabled");
|
62 |
// Trace on
|
66 |
}
|
67 |
|
68 |
DUP_Settings::Set('trace_log_enabled', 1);
|
|
|
69 |
} else {
|
70 |
dup_log::trace("#### trace log disabled");
|
71 |
|
74 |
}
|
75 |
|
76 |
DUP_Settings::Save();
|
77 |
+
$action_updated = true;
|
78 |
+
DUP_Util::initSnapshotDirectory();
|
79 |
}
|
80 |
|
81 |
+
$trace_log_enabled = DUP_Settings::Get('trace_log_enabled');
|
82 |
+
$uninstall_settings = DUP_Settings::Get('uninstall_settings');
|
83 |
+
$uninstall_files = DUP_Settings::Get('uninstall_files');
|
84 |
+
$uninstall_tables = DUP_Settings::Get('uninstall_tables');
|
85 |
+
$wpfront_integrate = DUP_Settings::Get('wpfront_integrate');
|
86 |
+
$wpfront_ready = apply_filters('wpfront_user_role_editor_duplicator_integration_ready', false);
|
87 |
+
$package_debug = DUP_Settings::Get('package_debug');
|
88 |
+
$skip_archive_scan = DUP_Settings::Get('skip_archive_scan');
|
|
|
89 |
$unhook_third_party_js = DUP_Settings::Get('unhook_third_party_js');
|
90 |
$unhook_third_party_css = DUP_Settings::Get('unhook_third_party_css');
|
91 |
?>
|
114 |
<tr valign="top">
|
115 |
<th scope="row"><label><?php esc_html_e("Version", 'duplicator'); ?></label></th>
|
116 |
<td>
|
117 |
+
<?php echo DUPLICATOR_VERSION ?>
|
118 |
+
<i><small>(<?php echo DUPLICATOR_VERSION_BUILD ?>)</small></i>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
</td>
|
120 |
</tr>
|
121 |
<tr valign="top">
|
122 |
+
<th scope="row"><label><?php esc_html_e("Uninstall", 'duplicator'); ?></label></th>
|
123 |
<td>
|
124 |
+
<p>
|
125 |
+
<input type="checkbox" name="uninstall_settings" id="uninstall_settings" <?php echo ($uninstall_settings) ? 'checked="checked"' : ''; ?> />
|
126 |
+
<label for="uninstall_settings"><?php esc_html_e("Delete Plugin Settings", 'duplicator') ?> </label>
|
127 |
+
</p>
|
128 |
+
<p>
|
129 |
+
<input type="checkbox" name="uninstall_files" id="uninstall_files" <?php echo ($uninstall_files) ? 'checked="checked"' : ''; ?> />
|
130 |
+
<label for="uninstall_files"><?php esc_html_e("Delete Entire Storage Directory", 'duplicator') ?></label><br/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
</td>
|
133 |
</tr>
|
134 |
</table>
|
151 |
<label for="trace_log_enabled"><?php esc_html_e("Enabled", 'duplicator') ?> </label><br/>
|
152 |
<p class="description">
|
153 |
<?php
|
154 |
+
esc_html_e('Turns on detailed operation logging. Logging will occur in both PHP error and local trace logs.');
|
155 |
+
echo ('<br/>');
|
156 |
+
esc_html_e('WARNING: Only turn on this setting when asked to by support as tracing will impact performance.', 'duplicator');
|
157 |
?>
|
158 |
</p><br/>
|
159 |
+
<button class="button" <?php
|
160 |
+
if (!DUP_Log::TraceFileExists()) {
|
161 |
+
echo 'disabled';
|
162 |
+
}
|
163 |
+
?> onclick="Duplicator.Pack.DownloadTraceLog(); return false">
|
164 |
+
<i class="fa fa-download"></i> <?php echo esc_html__('Download Trace Log', 'duplicator').' ('.DUP_LOG::GetTraceStatus().')'; ?>
|
165 |
</button>
|
166 |
</td>
|
167 |
</tr>
|
179 |
<i class="fas fa-redo fa-sm"></i> <?php esc_html_e('Reset Packages', 'duplicator'); ?>
|
180 |
</button>
|
181 |
<p class="description">
|
182 |
+
<?php
|
183 |
+
esc_html_e("This process will reset all packages by deleting those without a completed status, reset the active package id and perform a "
|
184 |
+
."cleanup of the build tmp file.", 'duplicator');
|
185 |
+
?>
|
186 |
<i class="fas fa-question-circle fa-sm"
|
187 |
+
data-tooltip-title="<?php esc_attr_e("Reset Settings", 'duplicator'); ?>"
|
188 |
+
data-tooltip="<?php esc_attr_e('This action should only be used if the packages screen is having issues or a build is stuck.', 'duplicator'); ?>"></i>
|
189 |
</p>
|
190 |
</td>
|
191 |
</tr>
|
192 |
<tr valign="top">
|
193 |
<th scope="row"><label><?php esc_html_e('Archive scan', 'duplicator'); ?></label></th>
|
194 |
<td>
|
195 |
+
<input type="checkbox" name="skip_archive_scan" id="_skip_archive_scan" <?php checked($skip_archive_scan, true); ?> value="1" />
|
196 |
<label for="_skip_archive_scan"><?php esc_html_e("Skip", 'duplicator') ?> </label><br/>
|
197 |
<p class="description">
|
198 |
+
<?php
|
199 |
+
esc_html_e('If enabled all files check on scan will be skipped before package creation. '
|
200 |
+
.'In some cases, this option can be beneficial if the scan process is having issues running or returning errors.', 'duplicator');
|
201 |
+
?>
|
202 |
</p>
|
203 |
</td>
|
204 |
</tr>
|
234 |
</p>
|
235 |
</td>
|
236 |
</tr>
|
237 |
+
<tr>
|
238 |
+
<th scope="row"><label><?php esc_html_e("Custom Roles", 'duplicator'); ?></label></th>
|
239 |
+
<td>
|
240 |
+
<input type="checkbox" name="wpfront_integrate" id="wpfront_integrate" <?php echo ($wpfront_integrate) ? 'checked="checked"' : ''; ?> <?php echo $wpfront_ready ? '' : 'disabled'; ?> />
|
241 |
+
<label for="wpfront_integrate"><?php esc_html_e("Enable User Role Editor Plugin Integration", 'duplicator'); ?></label>
|
242 |
+
<p class="description" style="max-width: 800px">
|
243 |
+
<?php
|
244 |
+
printf('%s <a href="https://wordpress.org/plugins/wpfront-user-role-editor/" target="_blank">%s</a> %s'
|
245 |
+
.' <a href="https://wpfront.com/user-role-editor-pro/?ref=3" target="_blank">%s</a> %s '
|
246 |
+
.' <a href="https://wpfront.com/integrations/duplicator-integration/?ref=3" target="_blank">%s</a>. %s'
|
247 |
+
.' <a href="https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=user_role_plugin&utm_campaign=duplicator_pro" target="_blank">%s</a>.',
|
248 |
+
esc_html__('To enable custom roles with Duplicator please install the ', 'duplicator'),
|
249 |
+
esc_html__('User Role Editor Free', 'duplicator'),
|
250 |
+
esc_html__('OR', 'duplicator'),
|
251 |
+
esc_html__('User Role Editor Professional', 'duplicator'),
|
252 |
+
esc_html__('plugins. Please note the User Role Editor Plugin is a separate plugin and does not unlock any Duplicator features. For more information on User Role Editor plugin please see', 'duplicator'),
|
253 |
+
esc_html__('the documentation', 'duplicator'),
|
254 |
+
esc_html__('If you are interested in downloading Duplicator Pro then please use', 'duplicator'),
|
255 |
+
esc_html__('this link', 'duplicator')
|
256 |
+
);
|
257 |
+
?>
|
258 |
+
</p>
|
259 |
+
</td>
|
260 |
+
</tr>
|
261 |
</table>
|
262 |
|
263 |
<p class="submit" style="margin: 20px 0px 0xp 5px;">
|
264 |
+
<br/>
|
265 |
+
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e("Save General Settings", 'duplicator') ?>" style="display: inline-block;" />
|
266 |
+
</p>
|
267 |
|
268 |
</form>
|
269 |
|
275 |
$reset_confirm->message = __('This will clear and reset all of the current temporary packages. Would you like to continue?', 'duplicator');
|
276 |
$reset_confirm->progressText = __('Resetting settings, Please Wait...', 'duplicator');
|
277 |
$reset_confirm->jscallback = 'Duplicator.Pack.ResetAll()';
|
278 |
+
$reset_confirm->progressOn = false;
|
279 |
$reset_confirm->okText = __('Yes', 'duplicator');
|
280 |
$reset_confirm->cancelText = __('No', 'duplicator');
|
281 |
$reset_confirm->closeOnConfirm = true;
|
282 |
$reset_confirm->initConfirm();
|
283 |
|
284 |
+
$msg_ajax_error = new DUP_UI_Messages(__('AJAX ERROR!', 'duplicator').'<br>'.__('Ajax request error', 'duplicator'), DUP_UI_Messages::ERROR);
|
285 |
+
$msg_ajax_error->hide_on_init = true;
|
286 |
$msg_ajax_error->is_dismissible = true;
|
287 |
$msg_ajax_error->initMessage();
|
288 |
|
289 |
+
$msg_response_error = new DUP_UI_Messages(__('RESPONSE ERROR!', 'duplicator'), DUP_UI_Messages::ERROR);
|
290 |
+
$msg_response_error->hide_on_init = true;
|
291 |
$msg_response_error->is_dismissible = true;
|
292 |
$msg_response_error->initMessage();
|
293 |
|
297 |
$msg_response_success->initMessage();
|
298 |
?>
|
299 |
<script>
|
300 |
+
jQuery(document).ready(function ($)
|
|
|
|
|
|
|
|
|
|
|
301 |
{
|
302 |
+
var msgDebug = <?php echo DUP_Util::isWpDebug() ? 'true' : 'false'; ?>;
|
303 |
+
|
304 |
+
// which: 0=installer, 1=archive, 2=sql file, 3=log
|
305 |
+
Duplicator.Pack.DownloadTraceLog = function ()
|
306 |
+
{
|
307 |
+
var actionLocation = ajaxurl + '?action=DUP_CTRL_Tools_getTraceLog&nonce=' + '<?php echo wp_create_nonce('DUP_CTRL_Tools_getTraceLog'); ?>';
|
308 |
+
location.href = actionLocation;
|
309 |
+
};
|
310 |
+
|
311 |
+
Duplicator.Pack.ConfirmResetAll = function ()
|
312 |
+
{
|
313 |
+
<?php $reset_confirm->showConfirm(); ?>
|
314 |
+
};
|
315 |
+
|
316 |
+
Duplicator.Pack.ResetAll = function ()
|
317 |
+
{
|
318 |
+
$.ajax({
|
319 |
+
type: "POST",
|
320 |
+
url: ajaxurl,
|
321 |
+
dataType: "json",
|
322 |
+
data: {
|
323 |
+
action: 'duplicator_reset_all_settings',
|
324 |
+
nonce: '<?php echo wp_create_nonce('duplicator_reset_all_settings'); ?>'
|
325 |
+
},
|
326 |
+
success: function (result) {
|
|
|
327 |
if (msgDebug) {
|
328 |
+
console.log(result);
|
329 |
+
}
|
330 |
+
|
331 |
+
if (result.success) {
|
332 |
+
var message = '<?php _e('Packages successfully reset', 'duplicator'); ?>';
|
333 |
+
if (msgDebug) {
|
334 |
+
console.log(result.data.message);
|
335 |
+
console.log(result.data.html);
|
336 |
+
}
|
337 |
+
<?php
|
338 |
+
$msg_response_success->updateMessage('message');
|
339 |
+
$msg_response_success->showMessage();
|
340 |
+
?>
|
341 |
+
} else {
|
342 |
+
var message = '<?php _e('RESPONSE ERROR!', 'duplicator'); ?>' + '<br><br>' + result.data.message;
|
343 |
+
if (msgDebug) {
|
344 |
+
message += '<br><br>' + result.data.html;
|
345 |
+
}
|
346 |
+
<?php
|
347 |
+
$msg_response_error->updateMessage('message');
|
348 |
+
$msg_response_error->showMessage();
|
349 |
+
?>
|
350 |
}
|
351 |
+
},
|
352 |
+
error: function (result) {
|
|
|
|
|
|
|
|
|
353 |
if (msgDebug) {
|
354 |
+
console.log(result);
|
355 |
}
|
356 |
+
<?php $msg_ajax_error->showMessage(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
}
|
358 |
+
});
|
359 |
+
};
|
360 |
+
});
|
|
|
|
|
361 |
</script>
|
views/settings/packages.php
CHANGED
@@ -278,7 +278,7 @@ $installerNameMode = DUP_Settings::Get('installer_name_mode');
|
|
278 |
</tr>
|
279 |
</table><br/>
|
280 |
|
281 |
-
<h3 class="title"><?php esc_html_e("Installer", 'duplicator') ?> </h3>
|
282 |
<hr size="1" />
|
283 |
<table class="form-table">
|
284 |
<tr>
|
278 |
</tr>
|
279 |
</table><br/>
|
280 |
|
281 |
+
<h3 class="title" id="duplicator-installer-settings"><?php esc_html_e("Installer", 'duplicator') ?> </h3>
|
282 |
<hr size="1" />
|
283 |
<table class="form-table">
|
284 |
<tr>
|
views/settings/storage.php
CHANGED
@@ -2,36 +2,173 @@
|
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
3 |
?>
|
4 |
<style>
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
</style>
|
9 |
|
10 |
<div class="panel">
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
3 |
?>
|
4 |
<style>
|
5 |
+
div.panel {padding: 20px 5px 10px 10px;}
|
6 |
+
div.area {font-size:16px; text-align: center; line-height: 30px; width:500px; margin:auto}
|
7 |
+
ul.li {padding:2px}
|
8 |
</style>
|
9 |
|
10 |
<div class="panel">
|
11 |
+
<?php
|
12 |
+
$action_updated = null;
|
13 |
+
$action_response = esc_html__("Storage Settings Saved", 'duplicator');
|
14 |
+
|
15 |
+
//SAVE RESULTS
|
16 |
+
if (filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING) === 'save') {
|
17 |
+
//Nonce Check
|
18 |
+
if (!wp_verify_nonce(filter_input(INPUT_POST, 'dup_storage_settings_save_nonce_field', FILTER_SANITIZE_STRING), 'dup_settings_save')) {
|
19 |
+
die('Invalid token permissions to perform this request.');
|
20 |
+
}
|
21 |
+
|
22 |
+
DUP_Settings::Set('storage_htaccess_off', filter_input(INPUT_POST, 'storage_htaccess_off', FILTER_VALIDATE_BOOLEAN));
|
23 |
+
|
24 |
+
switch (filter_input(INPUT_POST, 'storage_position', FILTER_DEFAULT)) {
|
25 |
+
case DUP_Settings::STORAGE_POSITION_LECAGY:
|
26 |
+
$setPostion = DUP_Settings::STORAGE_POSITION_LECAGY;
|
27 |
+
break;
|
28 |
+
case DUP_Settings::STORAGE_POSITION_WP_CONTENT:
|
29 |
+
default:
|
30 |
+
$setPostion = DUP_Settings::STORAGE_POSITION_WP_CONTENT;
|
31 |
+
break;
|
32 |
+
}
|
33 |
+
|
34 |
+
if (DUP_Settings::setStoragePosition($setPostion) != true) {
|
35 |
+
$targetFolder = ($setPostion === DUP_Settings::STORAGE_POSITION_WP_CONTENT) ? DUP_Settings::getSsdirPathWpCont() : DUP_Settings::getSsdirPathLegacy();
|
36 |
+
?>
|
37 |
+
<div id="message" class="notice notice-error is-dismissible">
|
38 |
+
<p>
|
39 |
+
<b><?php esc_html_e('Storage folder move problem'); ?></b>
|
40 |
+
</p>
|
41 |
+
<p>
|
42 |
+
<?php echo sprintf(__('Duplicator can\'t change the storage folder to <i>%s</i>', 'duplicator'), esc_html($targetFolder)); ?><br>
|
43 |
+
<?php echo sprintf(__('Check the parent folder permissions. ( <i>%s</i> )', 'duplicator'), esc_html(dirname($targetFolder))); ?>
|
44 |
+
</p>
|
45 |
+
</div>
|
46 |
+
<?php
|
47 |
+
}
|
48 |
+
DUP_Settings::Save();
|
49 |
+
$action_updated = true;
|
50 |
+
}
|
51 |
+
?>
|
52 |
+
|
53 |
+
<?php
|
54 |
+
$storage_position = DUP_Settings::Get('storage_position');
|
55 |
+
$storage_htaccess_off = DUP_Settings::Get('storage_htaccess_off');
|
56 |
+
?>
|
57 |
+
<form id="dup-settings-form" action="<?php echo admin_url('admin.php?page=duplicator-settings&tab=storage'); ?>" method="post">
|
58 |
+
<?php wp_nonce_field('dup_settings_save', 'dup_storage_settings_save_nonce_field', false); ?>
|
59 |
+
<input type="hidden" name="action" value="save">
|
60 |
+
<input type="hidden" name="page" value="duplicator-settings">
|
61 |
+
|
62 |
+
<?php if ($action_updated) : ?>
|
63 |
+
<div id="message" class="notice notice-success is-dismissible dup-wpnotice-box"><p><?php echo esc_html($action_response); ?></p></div>
|
64 |
+
<?php endif; ?>
|
65 |
+
|
66 |
+
<table class="form-table">
|
67 |
+
<tr valign="top">
|
68 |
+
<th scope="row"><label><?php esc_html_e("Location", 'duplicator'); ?></label></th>
|
69 |
+
<td>
|
70 |
+
<p>
|
71 |
+
<label>
|
72 |
+
<input type="radio" name="storage_position"
|
73 |
+
value="<?php echo DUP_Settings::STORAGE_POSITION_LECAGY; ?>"
|
74 |
+
<?php checked($storage_position === DUP_Settings::STORAGE_POSITION_LECAGY); ?> >
|
75 |
+
<span class="storage_pos_fixed_label"><?php esc_html_e('Legacy Path:', 'duplicator'); ?></span>
|
76 |
+
<i><?php echo DUP_Settings::getSsdirPathLegacy(); ?></i>
|
77 |
+
</label>
|
78 |
+
</p>
|
79 |
+
<p>
|
80 |
+
<label>
|
81 |
+
<input type="radio" name="storage_position"
|
82 |
+
value="<?php echo DUP_Settings::STORAGE_POSITION_WP_CONTENT; ?>"
|
83 |
+
<?php checked($storage_position === DUP_Settings::STORAGE_POSITION_WP_CONTENT); ?> >
|
84 |
+
<span class="storage_pos_fixed_label" ><?php esc_html_e('Contents Path:', 'duplicator'); ?></span>
|
85 |
+
<i><?php echo DUP_Settings::getSsdirPathWpCont(); ?></i>
|
86 |
+
</label>
|
87 |
+
</p>
|
88 |
+
<p class="description" style="max-width:800px">
|
89 |
+
<?php
|
90 |
+
esc_html_e("The storage location is where all package files are stored to disk. If your host has troubles writing content to the 'Legacy Path' then use "
|
91 |
+
. "the 'Contents Path'. Upon clicking the save button all files are moved to the new location and the previous path is removed.", 'duplicator');
|
92 |
+
?><br/>
|
93 |
+
|
94 |
+
|
95 |
+
<i class="fas fa-database fa-sm"></i> <span id="duplicator_advanced_storage_text" class="link-style">[<?php esc_html_e("More Advanced Storage Options...", 'duplicator'); ?>]</span>
|
96 |
+
</p>
|
97 |
+
</td>
|
98 |
+
</tr>
|
99 |
+
<tr valign="top">
|
100 |
+
<th scope="row"><label><?php esc_html_e("Apache .htaccess", 'duplicator'); ?></label></th>
|
101 |
+
<td>
|
102 |
+
<input type="checkbox" name="storage_htaccess_off" id="storage_htaccess_off" <?php echo ($storage_htaccess_off) ? 'checked="checked"' : ''; ?> />
|
103 |
+
<label for="storage_htaccess_off"><?php esc_html_e("Disable .htaccess file in storage directory", 'duplicator') ?> </label>
|
104 |
+
<p class="description">
|
105 |
+
<?php
|
106 |
+
esc_html_e("When checked this setting will prevent Duplicator from laying down an .htaccess file in the storage location above.", 'duplicator');
|
107 |
+
echo '<br/>';
|
108 |
+
esc_html_e("Only disable this option if issues occur when downloading either the installer/archive files.", 'duplicator');
|
109 |
+
?>
|
110 |
+
</p>
|
111 |
+
</td>
|
112 |
+
</tr>
|
113 |
+
</table>
|
114 |
+
<p class="submit" style="margin: 20px 0px 0xp 5px;">
|
115 |
+
<br/>
|
116 |
+
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e("Save Storage Settings", 'duplicator') ?>" style="display: inline-block;" />
|
117 |
+
</p>
|
118 |
+
</form>
|
119 |
+
<br/>
|
120 |
</div>
|
121 |
+
<!-- ==========================================
|
122 |
+
THICK-BOX DIALOGS: -->
|
123 |
+
<?php
|
124 |
+
|
125 |
+
function dup_lite_storage_advanced_pro_content()
|
126 |
+
{
|
127 |
+
ob_start();
|
128 |
+
?>
|
129 |
+
<div style="text-align: center">
|
130 |
+
<img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/logo-dpro-300x50.png"); ?>" style="height:50px; width:250px" /><br/>
|
131 |
+
<?php
|
132 |
+
esc_html_e('Store & Automate to Multiple Endpoints', 'duplicator');
|
133 |
+
echo '<br/>';
|
134 |
+
esc_html_e('with Duplicator Pro', 'duplicator');
|
135 |
+
?>
|
136 |
+
|
137 |
+
<div style="text-align: left; margin:auto; width:175px">
|
138 |
+
<ul>
|
139 |
+
<li><i class="fab fa-amazon"></i> <?php esc_html_e('Amazon S3', 'duplicator'); ?></li>
|
140 |
+
<li><i class="fab fa-dropbox"></i> <?php esc_html_e(' Dropbox', 'duplicator'); ?></li>
|
141 |
+
<li><i class="fab fa-google-drive"></i> <?php esc_html_e('Google Drive', 'duplicator'); ?></li>
|
142 |
+
<li><i class="fa fa-cloud fa-sm"></i> <?php esc_html_e('One Drive', 'duplicator'); ?></li>
|
143 |
+
<li><i class="fa fa-upload"></i> <?php esc_html_e('FTP & SFTP', 'duplicator'); ?></li>
|
144 |
+
<li><i class="far fa-folder-open"></i> <?php esc_html_e('Custom Directory', 'duplicator'); ?></li>
|
145 |
+
</ul>
|
146 |
+
</div>
|
147 |
+
<i>
|
148 |
+
<?php esc_html_e('Set up one-time storage locations and automatically', 'duplicator'); ?><br>
|
149 |
+
<?php esc_html_e('push the package to your destination.', 'duplicator'); ?>
|
150 |
+
</i>
|
151 |
+
</div>
|
152 |
+
<p style="text-align: center">
|
153 |
+
<a href="https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=free_settings_storage_popup&utm_campaign=duplicator_pro" target="_blank" class="button button-primary button-large dup-check-it-btn" >
|
154 |
+
<?php esc_html_e('Learn More', 'duplicator'); ?>
|
155 |
+
</a>
|
156 |
+
</p>
|
157 |
+
<?php
|
158 |
+
return ob_get_clean();
|
159 |
+
}
|
160 |
+
$storageAlert = new DUP_UI_Dialog();
|
161 |
+
$storageAlert->title = __('Advanced Storage', 'duplicator');
|
162 |
+
$storageAlert->height = 525;
|
163 |
+
$storageAlert->width = 400;
|
164 |
+
$storageAlert->okText = esc_html__('Close', 'duplicator');
|
165 |
+
$storageAlert->message = dup_lite_storage_advanced_pro_content();
|
166 |
+
$storageAlert->initAlert();
|
167 |
+
?>
|
168 |
+
<script>
|
169 |
+
jQuery(document).ready(function ($) {
|
170 |
+
$("#duplicator_advanced_storage_text").click(function () {
|
171 |
+
<?php $storageAlert->showAlert(); ?>
|
172 |
+
});
|
173 |
+
});
|
174 |
+
</script>
|
views/tools/diagnostics/inc.data.php
CHANGED
@@ -45,7 +45,7 @@ OPTIONS DATA -->
|
|
45 |
<?php esc_html_e("Clear Build Cache", 'duplicator'); ?>
|
46 |
</button>
|
47 |
</td>
|
48 |
-
<td><?php esc_html_e("Removes all build data from:", 'duplicator'); ?> [<?php echo
|
49 |
</tr>
|
50 |
</table>
|
51 |
</div>
|
45 |
<?php esc_html_e("Clear Build Cache", 'duplicator'); ?>
|
46 |
</button>
|
47 |
</td>
|
48 |
+
<td><?php esc_html_e("Removes all build data from:", 'duplicator'); ?> [<?php echo DUP_Settings::getSsdirTmpPath() ?>].</td>
|
49 |
</tr>
|
50 |
</table>
|
51 |
</div>
|
views/tools/diagnostics/information.php
CHANGED
@@ -64,7 +64,7 @@ if ($section == "info" || $section == '') {
|
|
64 |
if (!empty($glob_files)) {
|
65 |
foreach ($glob_files as $glob_file) {
|
66 |
$installer_log_file_path = $glob_file;
|
67 |
-
DUP_IO::copyFile($installer_log_file_path,
|
68 |
}
|
69 |
}
|
70 |
|
64 |
if (!empty($glob_files)) {
|
65 |
foreach ($glob_files as $glob_file) {
|
66 |
$installer_log_file_path = $glob_file;
|
67 |
+
DUP_IO::copyFile($installer_log_file_path, DUP_Settings::getSsdirInstallerPath());
|
68 |
}
|
69 |
}
|
70 |
|
views/tools/diagnostics/logging.php
CHANGED
@@ -7,7 +7,7 @@ function _duplicatorSortFiles($a,$b) {
|
|
7 |
return filemtime($b) - filemtime($a);
|
8 |
}
|
9 |
|
10 |
-
$logs = glob(
|
11 |
if ($logs != false && count($logs)) {
|
12 |
usort($logs, '_duplicatorSortFiles');
|
13 |
@chmod(DUP_Util::safePath($logs[0]), 0644);
|
@@ -31,8 +31,8 @@ if (!isset($logname) || !$logname) {
|
|
31 |
$logname = (count($logs) > 0) ? basename($logs[0]) : "";
|
32 |
}
|
33 |
|
34 |
-
$logurl
|
35 |
-
$logfound = (strlen($logname) > 0) ? true :false;
|
36 |
?>
|
37 |
|
38 |
<style>
|
7 |
return filemtime($b) - filemtime($a);
|
8 |
}
|
9 |
|
10 |
+
$logs = glob(DUP_Settings::getSsdirPath() . '/*.log') ;
|
11 |
if ($logs != false && count($logs)) {
|
12 |
usort($logs, '_duplicatorSortFiles');
|
13 |
@chmod(DUP_Util::safePath($logs[0]), 0644);
|
31 |
$logname = (count($logs) > 0) ? basename($logs[0]) : "";
|
32 |
}
|
33 |
|
34 |
+
$logurl = DUP_Settings::getSsdirUrl().'/'.$logname;
|
35 |
+
$logfound = (strlen($logname) > 0) ? true : false;
|
36 |
?>
|
37 |
|
38 |
<style>
|