Version Description
Download this release
Release Info
Developer | cory@lamle.org |
Plugin | Duplicator – WordPress Migration Plugin |
Version | 1.3.20 |
Comparing to | |
See all releases |
Code changes from version 1.3.18 to 1.3.20
- classes/class.db.php +1 -2
- classes/class.logging.php +18 -11
- classes/class.settings.php +3 -4
- classes/package/class.pack.database.php +31 -11
- classes/package/class.pack.installer.php +2 -2
- classes/package/class.pack.php +45 -50
- classes/package/duparchive/class.pack.archive.duparchive.php +1 -0
- classes/package/duparchive/class.pack.archive.duparchive.state.create.php +2 -4
- classes/package/duparchive/class.pack.archive.duparchive.state.expand.php +3 -3
- classes/ui/class.ui.notice.php +37 -0
- classes/utilities/class.u.json.php +2 -2
- classes/utilities/class.u.php +25 -6
- classes/utilities/class.u.zip.php +28 -24
- ctrls/ctrl.base.php +2 -2
- ctrls/ctrl.package.php +31 -21
- deactivation.php +1 -1
- define.php +3 -2
- duplicator.php +65 -6
- installer/dup-installer/assets/inc.css.php +0 -1
- installer/dup-installer/classes/class.csrf.php +55 -7
- installer/dup-installer/classes/class.installer.state.php +1 -1
- installer/dup-installer/classes/class.s3.func.php +111 -17
- installer/dup-installer/classes/utilities/class.u.notices.manager.php +1 -1
- installer/dup-installer/classes/utilities/class.u.php +59 -40
- installer/dup-installer/ctrls/ctrl.s1.php +1 -1
- installer/dup-installer/ctrls/ctrl.s2.base.php +1 -1
- installer/dup-installer/ctrls/ctrl.s2.dbinstall.php +2 -2
- installer/dup-installer/ctrls/ctrl.s2.dbtest.php +1 -1
- installer/dup-installer/ctrls/ctrl.s3.php +1 -1
- installer/dup-installer/main.installer.php +1 -1
- installer/dup-installer/views/view.s2.dbtest.php +1 -1
- installer/dup-installer/views/view.s3.php +6 -12
- installer/installer.tpl +55 -5
- lib/config/class.wp.config.tranformer.php +6 -6
- lib/dup_archive/classes/util/class.duparchive.u.json.php +2 -2
- lib/dup_archive/daws/class.daws.state.expand.php +2 -2
- lib/dup_archive/daws/daws.php +1 -1
- lib/fileops/class.fileops.state.php +12 -12
- lib/fileops/class.fileops.u.move.php +8 -8
- lib/fileops/fileops.php +31 -31
- lib/snaplib/class.snaplib.exceptions.php +1 -1
- lib/snaplib/class.snaplib.jsonSerializable.abstract.php +169 -0
- lib/snaplib/class.snaplib.logger.php +1 -0
- lib/snaplib/class.snaplib.u.io.php +28 -12
- lib/snaplib/class.snaplib.u.json.php +286 -0
- lib/snaplib/class.snaplib.u.os.php +1 -0
- lib/snaplib/class.snaplib.u.util.php +24 -263
- lib/snaplib/class.snaplib.u.wp.php +1 -0
- lib/snaplib/snaplib.all.php +2 -0
- readme.txt +1 -1
- views/packages/main/s1.setup2.php +24 -23
- views/packages/main/s2.scan3.php +1 -1
- views/packages/main/s3.build.php +7 -7
- views/settings/general.php +52 -12
- views/settings/packages.php +1 -1
- views/tools/diagnostics/inc.settings.php +10 -1
- views/tools/diagnostics/logging.php +26 -16
classes/class.db.php
CHANGED
@@ -241,5 +241,4 @@ class DUP_DB extends wpdb
|
|
241 |
return @esc_sql($sql);
|
242 |
}
|
243 |
}
|
244 |
-
}
|
245 |
-
DUP_DB::init();
|
241 |
return @esc_sql($sql);
|
242 |
}
|
243 |
}
|
244 |
+
}
|
|
classes/class.logging.php
CHANGED
@@ -68,20 +68,24 @@ class DUP_Log
|
|
68 |
*/
|
69 |
public static function Close()
|
70 |
{
|
|
|
|
|
71 |
if (!is_null(self::$logFileHandle)) {
|
72 |
$result = @fclose(self::$logFileHandle);
|
73 |
self::$logFileHandle = null;
|
|
|
|
|
74 |
}
|
75 |
return $result;
|
76 |
}
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
*
|
86 |
* @param string $msg The message to log
|
87 |
*
|
@@ -89,7 +93,9 @@ class DUP_Log
|
|
89 |
*/
|
90 |
public static function Info($msg)
|
91 |
{
|
92 |
-
self
|
|
|
|
|
93 |
if (!is_null(self::$logFileHandle)) {
|
94 |
@fwrite(self::$logFileHandle, $msg."\n");
|
95 |
}
|
@@ -263,7 +269,7 @@ class DUP_Log
|
|
263 |
@fwrite(self::$logFileHandle, "{$err_msg}");
|
264 |
|
265 |
switch ($behavior) {
|
266 |
-
|
267 |
case Dup_ErrorBehavior::ThrowException:
|
268 |
DUP_LOG::trace("throwing exception");
|
269 |
throw new Exception("DUPLICATOR ERROR: Please see the 'Package Log' file link below.");
|
@@ -446,6 +452,9 @@ class DUP_Handler
|
|
446 |
|
447 |
if (self::$codeReference) {
|
448 |
$result .= ' [CODE:'.$errno.'|FILE:'.$errfile.'|LINE:'.$errline.']';
|
|
|
|
|
|
|
449 |
}
|
450 |
|
451 |
return $result;
|
@@ -520,5 +529,3 @@ class DUP_Handler
|
|
520 |
}
|
521 |
}
|
522 |
}
|
523 |
-
|
524 |
-
DUP_Log::Init();
|
68 |
*/
|
69 |
public static function Close()
|
70 |
{
|
71 |
+
$result = true;
|
72 |
+
|
73 |
if (!is_null(self::$logFileHandle)) {
|
74 |
$result = @fclose(self::$logFileHandle);
|
75 |
self::$logFileHandle = null;
|
76 |
+
} else {
|
77 |
+
$result = true;
|
78 |
}
|
79 |
return $result;
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* General information send to the package log if opened
|
84 |
+
* @param string $msg The message to log
|
85 |
+
*
|
86 |
+
* REPLACE TO DEBUG: Memory consumption as script runs
|
87 |
+
* $results = DUP_Util::byteSize(memory_get_peak_usage(true)) . "\t" . $msg;
|
88 |
+
* @fwrite(self::$logFileHandle, "{$results} \n");
|
89 |
*
|
90 |
* @param string $msg The message to log
|
91 |
*
|
93 |
*/
|
94 |
public static function Info($msg)
|
95 |
{
|
96 |
+
if (self::$traceEnabled) {
|
97 |
+
self::Trace($msg);
|
98 |
+
}
|
99 |
if (!is_null(self::$logFileHandle)) {
|
100 |
@fwrite(self::$logFileHandle, $msg."\n");
|
101 |
}
|
269 |
@fwrite(self::$logFileHandle, "{$err_msg}");
|
270 |
|
271 |
switch ($behavior) {
|
272 |
+
|
273 |
case Dup_ErrorBehavior::ThrowException:
|
274 |
DUP_LOG::trace("throwing exception");
|
275 |
throw new Exception("DUPLICATOR ERROR: Please see the 'Package Log' file link below.");
|
452 |
|
453 |
if (self::$codeReference) {
|
454 |
$result .= ' [CODE:'.$errno.'|FILE:'.$errfile.'|LINE:'.$errline.']';
|
455 |
+
ob_start();
|
456 |
+
debug_print_backtrace();
|
457 |
+
$result .= "\n".ob_get_clean();
|
458 |
}
|
459 |
|
460 |
return $result;
|
529 |
}
|
530 |
}
|
531 |
}
|
|
|
|
classes/class.settings.php
CHANGED
@@ -25,7 +25,7 @@ class DUP_Settings
|
|
25 |
{
|
26 |
self::$Data = get_option(self::OPT_SETTINGS);
|
27 |
//when the plugin updated, this will be true
|
28 |
-
if (empty(self::$Data) || self::$Version > self::$Data['version']) {
|
29 |
self::SetDefaults();
|
30 |
}
|
31 |
}
|
@@ -141,6 +141,8 @@ class DUP_Settings
|
|
141 |
|
142 |
//Skip scan archive
|
143 |
$default['skip_archive_scan'] = isset(self::$Data['skip_archive_scan']) ? self::$Data['skip_archive_scan'] : false;
|
|
|
|
|
144 |
|
145 |
$default['active_package_id'] = -1;
|
146 |
|
@@ -156,6 +158,3 @@ class DUP_Settings
|
|
156 |
return $ui_create_frmt;
|
157 |
}
|
158 |
}
|
159 |
-
//Init Class
|
160 |
-
DUP_Settings::init();
|
161 |
-
?>
|
25 |
{
|
26 |
self::$Data = get_option(self::OPT_SETTINGS);
|
27 |
//when the plugin updated, this will be true
|
28 |
+
if (empty(self::$Data) || empty(self::$Data['version']) || self::$Version > self::$Data['version']) {
|
29 |
self::SetDefaults();
|
30 |
}
|
31 |
}
|
141 |
|
142 |
//Skip scan archive
|
143 |
$default['skip_archive_scan'] = isset(self::$Data['skip_archive_scan']) ? self::$Data['skip_archive_scan'] : false;
|
144 |
+
$default['unhook_third_party_js'] = isset(self::$Data['unhook_third_party_js']) ? self::$Data['unhook_third_party_js'] : false;
|
145 |
+
$default['unhook_third_party_css'] = isset(self::$Data['unhook_third_party_css']) ? self::$Data['unhook_third_party_css'] : false;
|
146 |
|
147 |
$default['active_package_id'] = -1;
|
148 |
|
158 |
return $ui_create_frmt;
|
159 |
}
|
160 |
}
|
|
|
|
|
|
classes/package/class.pack.database.php
CHANGED
@@ -345,6 +345,21 @@ class DUP_Database
|
|
345 |
$this->info->collationList = DUP_DB::getTableCollationList($filterTables);
|
346 |
}
|
347 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
/**
|
349 |
* Build the database script using mysqldump
|
350 |
*
|
@@ -384,13 +399,23 @@ class DUP_Database
|
|
384 |
$tables = array();
|
385 |
$baseTables = array();
|
386 |
foreach ($res as $row) {
|
387 |
-
|
388 |
-
|
389 |
-
|
|
|
|
|
390 |
}
|
391 |
}
|
392 |
$filterTables = isset($this->FilterTables) ? explode(',', $this->FilterTables) : null;
|
393 |
$tblAllCount = count($tables);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
//$tblFilterOn = ($this->FilterOn) ? 'ON' : 'OFF';
|
395 |
|
396 |
if (is_array($filterTables) && $this->FilterOn) {
|
@@ -514,13 +539,6 @@ class DUP_Database
|
|
514 |
$sql_footer = "\n\n/* Duplicator WordPress Timestamp: ".date("Y-m-d H:i:s")."*/\n";
|
515 |
$sql_footer .= "/* ".DUPLICATOR_DB_EOF_MARKER." */\n";
|
516 |
file_put_contents($this->dbStorePath, $sql_footer, FILE_APPEND);
|
517 |
-
foreach ($tables as $table) {
|
518 |
-
if (in_array($table, $baseTables)) {
|
519 |
-
$row_count = $GLOBALS['wpdb']->get_var("SELECT Count(*) FROM `{$table}`");
|
520 |
-
$rewrite_table_as = $this->rewriteTableNameAs($table);
|
521 |
-
$this->Package->Database->info->tableWiseRowCounts[$rewrite_table_as] = $row_count;
|
522 |
-
}
|
523 |
-
}
|
524 |
return ($output) ? false : true;
|
525 |
}
|
526 |
|
@@ -534,7 +552,9 @@ class DUP_Database
|
|
534 |
global $wpdb;
|
535 |
|
536 |
$wpdb->query("SET session wait_timeout = ".DUPLICATOR_DB_MAX_TIME);
|
537 |
-
$handle = fopen($this->dbStorePath, 'w+')
|
|
|
|
|
538 |
$tables = $wpdb->get_col("SHOW FULL TABLES WHERE Table_Type != 'VIEW'");
|
539 |
|
540 |
$filterTables = isset($this->FilterTables) ? explode(',', $this->FilterTables) : null;
|
345 |
$this->info->collationList = DUP_DB::getTableCollationList($filterTables);
|
346 |
}
|
347 |
|
348 |
+
/**
|
349 |
+
* Unset tableWiseRowCounts table key for which row count is unstable
|
350 |
+
*
|
351 |
+
* @param object $package The reference to the current package being built *
|
352 |
+
* @return void
|
353 |
+
*/
|
354 |
+
public function validateTableWiseRowCounts() {
|
355 |
+
foreach ($this->Package->Database->info->tableWiseRowCounts as $rewriteTableAs => $rowCount) {
|
356 |
+
$newRowCount = $GLOBALS['wpdb']->get_var("SELECT Count(*) FROM `{$rewriteTableAs}`");
|
357 |
+
if ($rowCount != $newRowCount) {
|
358 |
+
unset($this->Package->Database->info->tableWiseRowCounts[$rewriteTableAs]);
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
/**
|
364 |
* Build the database script using mysqldump
|
365 |
*
|
399 |
$tables = array();
|
400 |
$baseTables = array();
|
401 |
foreach ($res as $row) {
|
402 |
+
if (DUP_Util::isTableExists($row[0])) {
|
403 |
+
$tables[] = $row[0];
|
404 |
+
if ('BASE TABLE' == $row[1]) {
|
405 |
+
$baseTables[] = $row[0];
|
406 |
+
}
|
407 |
}
|
408 |
}
|
409 |
$filterTables = isset($this->FilterTables) ? explode(',', $this->FilterTables) : null;
|
410 |
$tblAllCount = count($tables);
|
411 |
+
|
412 |
+
foreach ($tables as $table) {
|
413 |
+
if (in_array($table, $baseTables)) {
|
414 |
+
$row_count = $GLOBALS['wpdb']->get_var("SELECT Count(*) FROM `{$table}`");
|
415 |
+
$rewrite_table_as = $this->rewriteTableNameAs($table);
|
416 |
+
$this->Package->Database->info->tableWiseRowCounts[$rewrite_table_as] = $row_count;
|
417 |
+
}
|
418 |
+
}
|
419 |
//$tblFilterOn = ($this->FilterOn) ? 'ON' : 'OFF';
|
420 |
|
421 |
if (is_array($filterTables) && $this->FilterOn) {
|
539 |
$sql_footer = "\n\n/* Duplicator WordPress Timestamp: ".date("Y-m-d H:i:s")."*/\n";
|
540 |
$sql_footer .= "/* ".DUPLICATOR_DB_EOF_MARKER." */\n";
|
541 |
file_put_contents($this->dbStorePath, $sql_footer, FILE_APPEND);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
return ($output) ? false : true;
|
543 |
}
|
544 |
|
552 |
global $wpdb;
|
553 |
|
554 |
$wpdb->query("SET session wait_timeout = ".DUPLICATOR_DB_MAX_TIME);
|
555 |
+
if (($handle = fopen($this->dbStorePath, 'w+')) == false) {
|
556 |
+
DUP_Log::error('[PHP DUMP] ERROR Can\'t open sbStorePath "'.$this->dbStorePath.'"', Dup_ErrorBehavior::Quit);
|
557 |
+
}
|
558 |
$tables = $wpdb->get_col("SHOW FULL TABLES WHERE Table_Type != 'VIEW'");
|
559 |
|
560 |
$filterTables = isset($this->FilterTables) ? explode(',', $this->FilterTables) : null;
|
classes/package/class.pack.installer.php
CHANGED
@@ -144,7 +144,7 @@ class DUP_Installer
|
|
144 |
$ac->package_hash = $this->Package->getPackageHash();
|
145 |
$ac->package_notes = $this->Package->Notes;
|
146 |
$ac->url_old = get_option('siteurl');
|
147 |
-
$ac->opts_delete =
|
148 |
$ac->blogname = esc_html(get_option('blogname'));
|
149 |
$ac->wproot = DUPLICATOR_WPROOTPATH;
|
150 |
$ac->relative_content_dir = str_replace(ABSPATH, '', WP_CONTENT_DIR);
|
@@ -166,7 +166,7 @@ class DUP_Installer
|
|
166 |
$ac->is_outer_root_wp_config_file = (!file_exists(DUPLICATOR_WPROOTPATH.'wp-config.php')) ? true : false;
|
167 |
$ac->is_outer_root_wp_content_dir = $this->Package->Archive->isOuterWPContentDir();
|
168 |
|
169 |
-
$json =
|
170 |
DUP_Log::TraceObject('json', $json);
|
171 |
|
172 |
if (file_put_contents($archive_config_filepath, $json) === false) {
|
144 |
$ac->package_hash = $this->Package->getPackageHash();
|
145 |
$ac->package_notes = $this->Package->Notes;
|
146 |
$ac->url_old = get_option('siteurl');
|
147 |
+
$ac->opts_delete = DupLiteSnapJsonU::wp_json_encode_pprint($GLOBALS['DUPLICATOR_OPTS_DELETE']);
|
148 |
$ac->blogname = esc_html(get_option('blogname'));
|
149 |
$ac->wproot = DUPLICATOR_WPROOTPATH;
|
150 |
$ac->relative_content_dir = str_replace(ABSPATH, '', WP_CONTENT_DIR);
|
166 |
$ac->is_outer_root_wp_config_file = (!file_exists(DUPLICATOR_WPROOTPATH.'wp-config.php')) ? true : false;
|
167 |
$ac->is_outer_root_wp_content_dir = $this->Package->Archive->isOuterWPContentDir();
|
168 |
|
169 |
+
$json = DupLiteSnapJsonU::wp_json_encode_pprint($ac);
|
170 |
DUP_Log::TraceObject('json', $json);
|
171 |
|
172 |
if (file_put_contents($archive_config_filepath, $json) === false) {
|
classes/package/class.pack.php
CHANGED
@@ -289,7 +289,7 @@ class DUP_Package
|
|
289 |
$report['RPT']['ScanTime'] = DUP_Util::elapsedTime(DUP_Util::getMicrotime(), $timerStart);
|
290 |
$fp = fopen(DUPLICATOR_SSDIR_PATH_TMP."/{$this->ScanFile}", 'w');
|
291 |
|
292 |
-
fwrite($fp,
|
293 |
fclose($fp);
|
294 |
|
295 |
return $report;
|
@@ -482,7 +482,7 @@ class DUP_Package
|
|
482 |
public function getArchiveSize() {
|
483 |
$size = 0;
|
484 |
|
485 |
-
if ($this->Status >=
|
486 |
$size = $this->Archive->Size;
|
487 |
} else {
|
488 |
$tmpSearch = glob(DUPLICATOR_SSDIR_PATH_TMP . "/{$this->NameHash}_*");
|
@@ -735,7 +735,7 @@ class DUP_Package
|
|
735 |
}
|
736 |
// We was not storing Status in Lite 1.2.52, so it is for backward compatibility
|
737 |
if (!isset($Package->Status)) {
|
738 |
-
$Package->Status = $
|
739 |
}
|
740 |
call_user_func($callback, $Package);
|
741 |
unset($Package);
|
@@ -783,23 +783,20 @@ class DUP_Package
|
|
783 |
$sql_temp_size = @filesize($sql_temp_path);
|
784 |
$sql_easy_size = DUP_Util::byteSize($sql_temp_size);
|
785 |
$sql_done_txt = DUP_Util::tailFile($sql_temp_path, 3);
|
786 |
-
DUP_Log::Trace('
|
787 |
|
788 |
// Note: Had to add extra size check of 800 since observed bad sql when filter was on
|
789 |
if (!strstr($sql_done_txt, 'DUPLICATOR_MYSQLDUMP_EOF') || (!$this->Database->FilterOn && $sql_temp_size < 5120) || ($this->Database->FilterOn && $this->Database->info->tablesFinalCount > 0 && $sql_temp_size < 800)) {
|
790 |
-
DUP_Log::Trace('
|
791 |
|
792 |
$error_text = "ERROR: SQL file not complete. The file {$sql_temp_path} looks too small ($sql_temp_size bytes) or the end of file marker was not found.";
|
793 |
$this->BuildProgress->set_failed($error_text);
|
794 |
-
$this->
|
795 |
-
$this->update();
|
796 |
-
//$this->setStatus(DUP_PackageStatus::ERROR);
|
797 |
DUP_Log::Error("$error_text", '', Dup_ErrorBehavior::LogOnly);
|
798 |
-
|
799 |
return;
|
800 |
}
|
801 |
|
802 |
-
DUP_Log::Trace('
|
803 |
DUP_Log::Info("SQL FILE: {$sql_easy_size}");
|
804 |
|
805 |
//------------------------
|
@@ -833,9 +830,7 @@ class DUP_Package
|
|
833 |
$error_message = "ERROR: The archive file contains no size.";
|
834 |
|
835 |
$this->BuildProgress->set_failed($error_message);
|
836 |
-
$this->
|
837 |
-
$this->update();
|
838 |
-
//$this->setStatus(DUP_PackageStatus::ERROR);
|
839 |
DUP_Log::error($error_message, "Archive Size: {$zip_easy_size}", Dup_ErrorBehavior::LogOnly);
|
840 |
return;
|
841 |
}
|
@@ -852,8 +847,7 @@ class DUP_Package
|
|
852 |
//$this->BuildProgress->failed = true;
|
853 |
//$this->setStatus(DUP_PackageStatus::ERROR);
|
854 |
$this->BuildProgress->set_failed($error_message);
|
855 |
-
$this->
|
856 |
-
$this->update();
|
857 |
|
858 |
DUP_Log::Error($error_message, '', Dup_ErrorBehavior::LogOnly);
|
859 |
return;
|
@@ -1136,7 +1130,7 @@ class DUP_Package
|
|
1136 |
}
|
1137 |
|
1138 |
if ($this->BuildProgress->initialized == false) {
|
1139 |
-
DUP_Log::Trace('
|
1140 |
$this->BuildProgress->initialized = true;
|
1141 |
$this->TimerStart = Dup_Util::getMicrotime();
|
1142 |
$this->update();
|
@@ -1144,29 +1138,28 @@ class DUP_Package
|
|
1144 |
|
1145 |
//START BUILD
|
1146 |
if (!$this->BuildProgress->database_script_built) {
|
1147 |
-
|
1148 |
-
|
1149 |
$this->Database->build($this, Dup_ErrorBehavior::ThrowException);
|
|
|
|
|
1150 |
$this->BuildProgress->database_script_built = true;
|
1151 |
$this->update();
|
1152 |
-
|
1153 |
} else if (!$this->BuildProgress->archive_built) {
|
1154 |
-
|
1155 |
-
|
1156 |
$this->Archive->build($this);
|
1157 |
$this->update();
|
|
|
1158 |
} else if (!$this->BuildProgress->installer_built) {
|
1159 |
-
|
1160 |
-
|
1161 |
-
// Installer being built is stuffed into the archive build phase
|
1162 |
}
|
1163 |
|
1164 |
if ($this->BuildProgress->has_completed()) {
|
1165 |
-
|
1166 |
-
DUP_Log::Trace('c');
|
1167 |
|
1168 |
if (!$this->BuildProgress->failed) {
|
1169 |
-
DUP_LOG::
|
1170 |
// Only makees sense to perform build integrity check on completed archives
|
1171 |
$this->runDupArchiveBuildIntegrityCheck();
|
1172 |
} else {
|
@@ -1188,17 +1181,17 @@ class DUP_Package
|
|
1188 |
DUP_LOG::trace("Done package building");
|
1189 |
|
1190 |
if (!$this->BuildProgress->failed) {
|
1191 |
-
|
1192 |
$this->setStatus(DUP_PackageStatus::COMPLETE);
|
1193 |
DUP_LOG::Trace("Cleaning up duparchive temp files");
|
1194 |
//File Cleanup
|
1195 |
$this->buildCleanup();
|
1196 |
do_action('duplicator_lite_build_completed' , $this);
|
|
|
|
|
1197 |
}
|
1198 |
}
|
1199 |
-
|
1200 |
DUP_Log::Close();
|
1201 |
-
|
1202 |
return $this->BuildProgress->has_completed();
|
1203 |
}
|
1204 |
|
@@ -1216,6 +1209,7 @@ class DUP_Package
|
|
1216 |
//PHPs serialze method will return the object, but the ID above is not passed
|
1217 |
//for one reason or another so passing the object back in seems to do the trick
|
1218 |
$this->Database->build($this);
|
|
|
1219 |
$this->Archive->build($this);
|
1220 |
$this->Installer->build($this);
|
1221 |
|
@@ -1392,10 +1386,7 @@ class DUP_Package
|
|
1392 |
$sql .= "package = '" . esc_sql($packageObj) . "'";
|
1393 |
$sql .= "WHERE ID = {$this->ID}";
|
1394 |
|
1395 |
-
DUP_Log::Trace(
|
1396 |
-
DUP_Log::Trace("status = {$this->Status}");
|
1397 |
-
DUP_Log::Trace("ID = {$this->ID}");
|
1398 |
-
DUP_Log::Trace('-------------------------');
|
1399 |
|
1400 |
//DUP_Log::Trace('####Executing SQL' . $sql . '-----------');
|
1401 |
$wpdb->query($sql);
|
@@ -1420,8 +1411,9 @@ class DUP_Package
|
|
1420 |
|
1421 |
/**
|
1422 |
* Sets the status to log the state of the build
|
|
|
1423 |
*
|
1424 |
-
* @param $status
|
1425 |
*
|
1426 |
* @return void
|
1427 |
*/
|
@@ -1430,18 +1422,17 @@ class DUP_Package
|
|
1430 |
if (!isset($status)) {
|
1431 |
DUP_Log::Error("Package SetStatus did not receive a proper code.");
|
1432 |
}
|
1433 |
-
|
1434 |
$this->Status = $status;
|
1435 |
-
|
1436 |
$this->update();
|
1437 |
}
|
1438 |
|
1439 |
/**
|
1440 |
* Does a hash already exists
|
|
|
1441 |
*
|
1442 |
* @param string $hash An existing hash value
|
1443 |
*
|
1444 |
-
* @return int
|
1445 |
*/
|
1446 |
public function getHashKey($hash)
|
1447 |
{
|
@@ -1460,7 +1451,7 @@ class DUP_Package
|
|
1460 |
/**
|
1461 |
* Makes the hashkey for the package files
|
1462 |
*
|
1463 |
-
* @return string A unique hashkey
|
1464 |
*/
|
1465 |
public function makeHash()
|
1466 |
{
|
@@ -1481,7 +1472,7 @@ class DUP_Package
|
|
1481 |
*
|
1482 |
* @see DUP_Package::saveActive
|
1483 |
*
|
1484 |
-
* @return
|
1485 |
*/
|
1486 |
public static function getActive()
|
1487 |
{
|
@@ -1503,18 +1494,21 @@ class DUP_Package
|
|
1503 |
*
|
1504 |
* @param int $id A valid package id form the duplicator_packages table
|
1505 |
*
|
1506 |
-
* @return DUP_Package A copy of the DUP_Package object
|
1507 |
*/
|
1508 |
public static function getByID($id)
|
1509 |
{
|
1510 |
global $wpdb;
|
1511 |
-
$obj
|
1512 |
$tablePrefix = DUP_Util::getTablePrefix();
|
1513 |
-
$sql
|
1514 |
-
$row
|
1515 |
if (is_object($row)) {
|
1516 |
-
$obj
|
1517 |
-
//
|
|
|
|
|
|
|
1518 |
}
|
1519 |
//Incase unserilaize fails
|
1520 |
$obj = (is_object($obj)) ? $obj : null;
|
@@ -1524,7 +1518,7 @@ class DUP_Package
|
|
1524 |
/**
|
1525 |
* Gets a default name for the package
|
1526 |
*
|
1527 |
-
* @return string A default package name such as 20170218_blogname
|
1528 |
*/
|
1529 |
public static function getDefaultName($preDate = true)
|
1530 |
{
|
@@ -1568,13 +1562,14 @@ class DUP_Package
|
|
1568 |
/**
|
1569 |
* Provides various date formats
|
1570 |
*
|
1571 |
-
* @param $
|
1572 |
* @param $format Various date formats to apply
|
1573 |
*
|
1574 |
-
* @return a formated date based on the $format
|
1575 |
*/
|
1576 |
-
public static function getCreatedDateFormat($
|
1577 |
{
|
|
|
1578 |
$date = new DateTime($date);
|
1579 |
switch ($format) {
|
1580 |
//YEAR
|
289 |
$report['RPT']['ScanTime'] = DUP_Util::elapsedTime(DUP_Util::getMicrotime(), $timerStart);
|
290 |
$fp = fopen(DUPLICATOR_SSDIR_PATH_TMP."/{$this->ScanFile}", 'w');
|
291 |
|
292 |
+
fwrite($fp, DupLiteSnapJsonU::wp_json_encode_pprint($report));
|
293 |
fclose($fp);
|
294 |
|
295 |
return $report;
|
482 |
public function getArchiveSize() {
|
483 |
$size = 0;
|
484 |
|
485 |
+
if ($this->Status >= DUP_PackageStatus::COMPLETE) {
|
486 |
$size = $this->Archive->Size;
|
487 |
} else {
|
488 |
$tmpSearch = glob(DUPLICATOR_SSDIR_PATH_TMP . "/{$this->NameHash}_*");
|
735 |
}
|
736 |
// We was not storing Status in Lite 1.2.52, so it is for backward compatibility
|
737 |
if (!isset($Package->Status)) {
|
738 |
+
$Package->Status = $rows[0]->status;
|
739 |
}
|
740 |
call_user_func($callback, $Package);
|
741 |
unset($Package);
|
783 |
$sql_temp_size = @filesize($sql_temp_path);
|
784 |
$sql_easy_size = DUP_Util::byteSize($sql_temp_size);
|
785 |
$sql_done_txt = DUP_Util::tailFile($sql_temp_path, 3);
|
786 |
+
DUP_Log::Trace('[DUP ARCHIVE] '.__FUNCTION__.' '.__LINE__);
|
787 |
|
788 |
// Note: Had to add extra size check of 800 since observed bad sql when filter was on
|
789 |
if (!strstr($sql_done_txt, 'DUPLICATOR_MYSQLDUMP_EOF') || (!$this->Database->FilterOn && $sql_temp_size < 5120) || ($this->Database->FilterOn && $this->Database->info->tablesFinalCount > 0 && $sql_temp_size < 800)) {
|
790 |
+
DUP_Log::Trace('[DUP ARCHIVE] '.__FUNCTION__.' '.__LINE__);
|
791 |
|
792 |
$error_text = "ERROR: SQL file not complete. The file {$sql_temp_path} looks too small ($sql_temp_size bytes) or the end of file marker was not found.";
|
793 |
$this->BuildProgress->set_failed($error_text);
|
794 |
+
$this->setStatus(DUP_PackageStatus::ERROR);
|
|
|
|
|
795 |
DUP_Log::Error("$error_text", '', Dup_ErrorBehavior::LogOnly);
|
|
|
796 |
return;
|
797 |
}
|
798 |
|
799 |
+
DUP_Log::Trace('[DUP ARCHIVE] '.__FUNCTION__.' '.__LINE__);
|
800 |
DUP_Log::Info("SQL FILE: {$sql_easy_size}");
|
801 |
|
802 |
//------------------------
|
830 |
$error_message = "ERROR: The archive file contains no size.";
|
831 |
|
832 |
$this->BuildProgress->set_failed($error_message);
|
833 |
+
$this->setStatus(DUP_PackageStatus::ERROR);
|
|
|
|
|
834 |
DUP_Log::error($error_message, "Archive Size: {$zip_easy_size}", Dup_ErrorBehavior::LogOnly);
|
835 |
return;
|
836 |
}
|
847 |
//$this->BuildProgress->failed = true;
|
848 |
//$this->setStatus(DUP_PackageStatus::ERROR);
|
849 |
$this->BuildProgress->set_failed($error_message);
|
850 |
+
$this->setStatus(DUP_PackageStatus::ERROR);
|
|
|
851 |
|
852 |
DUP_Log::Error($error_message, '', Dup_ErrorBehavior::LogOnly);
|
853 |
return;
|
1130 |
}
|
1131 |
|
1132 |
if ($this->BuildProgress->initialized == false) {
|
1133 |
+
DUP_Log::Trace('[DUP ARCHIVE] INIZIALIZE');
|
1134 |
$this->BuildProgress->initialized = true;
|
1135 |
$this->TimerStart = Dup_Util::getMicrotime();
|
1136 |
$this->update();
|
1138 |
|
1139 |
//START BUILD
|
1140 |
if (!$this->BuildProgress->database_script_built) {
|
1141 |
+
DUP_Log::Info('[DUP ARCHIVE] BUILDING DATABASE');
|
|
|
1142 |
$this->Database->build($this, Dup_ErrorBehavior::ThrowException);
|
1143 |
+
DUP_Log::Info('[DUP ARCHIVE] VALIDATING DATABASE');
|
1144 |
+
$this->Database->validateTableWiseRowCounts();
|
1145 |
$this->BuildProgress->database_script_built = true;
|
1146 |
$this->update();
|
1147 |
+
DUP_Log::Info('[DUP ARCHIVE] DONE DATABASE');
|
1148 |
} else if (!$this->BuildProgress->archive_built) {
|
1149 |
+
DUP_Log::Info('[DUP ARCHIVE] BUILDING ARCHIVE');
|
|
|
1150 |
$this->Archive->build($this);
|
1151 |
$this->update();
|
1152 |
+
DUP_Log::Info('[DUP ARCHIVE] DONE ARCHIVE');
|
1153 |
} else if (!$this->BuildProgress->installer_built) {
|
1154 |
+
DUP_Log::Info('[DUP ARCHIVE] BUILDING INSTALLER');
|
1155 |
+
// Installer being built is stuffed into the archive build phase
|
|
|
1156 |
}
|
1157 |
|
1158 |
if ($this->BuildProgress->has_completed()) {
|
1159 |
+
DUP_Log::Info('[DUP ARCHIVE] HAS COMPLETED CLOSING');
|
|
|
1160 |
|
1161 |
if (!$this->BuildProgress->failed) {
|
1162 |
+
DUP_LOG::Info("[DUP ARCHIVE] DUP ARCHIVE INTEGRITY CHECK");
|
1163 |
// Only makees sense to perform build integrity check on completed archives
|
1164 |
$this->runDupArchiveBuildIntegrityCheck();
|
1165 |
} else {
|
1181 |
DUP_LOG::trace("Done package building");
|
1182 |
|
1183 |
if (!$this->BuildProgress->failed) {
|
1184 |
+
DUP_Log::Trace('[DUP ARCHIVE] HAS COMPLETED DONE');
|
1185 |
$this->setStatus(DUP_PackageStatus::COMPLETE);
|
1186 |
DUP_LOG::Trace("Cleaning up duparchive temp files");
|
1187 |
//File Cleanup
|
1188 |
$this->buildCleanup();
|
1189 |
do_action('duplicator_lite_build_completed' , $this);
|
1190 |
+
} else {
|
1191 |
+
DUP_Log::Trace('[DUP ARCHIVE] HAS COMPLETED ERROR');
|
1192 |
}
|
1193 |
}
|
|
|
1194 |
DUP_Log::Close();
|
|
|
1195 |
return $this->BuildProgress->has_completed();
|
1196 |
}
|
1197 |
|
1209 |
//PHPs serialze method will return the object, but the ID above is not passed
|
1210 |
//for one reason or another so passing the object back in seems to do the trick
|
1211 |
$this->Database->build($this);
|
1212 |
+
$this->Database->validateTableWiseRowCounts();
|
1213 |
$this->Archive->build($this);
|
1214 |
$this->Installer->build($this);
|
1215 |
|
1386 |
$sql .= "package = '" . esc_sql($packageObj) . "'";
|
1387 |
$sql .= "WHERE ID = {$this->ID}";
|
1388 |
|
1389 |
+
DUP_Log::Trace("UPDATE PACKAGE ID = {$this->ID} STATUS = {$this->Status}");
|
|
|
|
|
|
|
1390 |
|
1391 |
//DUP_Log::Trace('####Executing SQL' . $sql . '-----------');
|
1392 |
$wpdb->query($sql);
|
1411 |
|
1412 |
/**
|
1413 |
* Sets the status to log the state of the build
|
1414 |
+
* The status level for where the package is
|
1415 |
*
|
1416 |
+
* @param int $status
|
1417 |
*
|
1418 |
* @return void
|
1419 |
*/
|
1422 |
if (!isset($status)) {
|
1423 |
DUP_Log::Error("Package SetStatus did not receive a proper code.");
|
1424 |
}
|
|
|
1425 |
$this->Status = $status;
|
|
|
1426 |
$this->update();
|
1427 |
}
|
1428 |
|
1429 |
/**
|
1430 |
* Does a hash already exists
|
1431 |
+
* Returns 0 if no hash is found, if found returns the table ID
|
1432 |
*
|
1433 |
* @param string $hash An existing hash value
|
1434 |
*
|
1435 |
+
* @return int
|
1436 |
*/
|
1437 |
public function getHashKey($hash)
|
1438 |
{
|
1451 |
/**
|
1452 |
* Makes the hashkey for the package files
|
1453 |
*
|
1454 |
+
* @return string // A unique hashkey
|
1455 |
*/
|
1456 |
public function makeHash()
|
1457 |
{
|
1472 |
*
|
1473 |
* @see DUP_Package::saveActive
|
1474 |
*
|
1475 |
+
* @return DUP_Package // A copy of the DUP_Package object
|
1476 |
*/
|
1477 |
public static function getActive()
|
1478 |
{
|
1494 |
*
|
1495 |
* @param int $id A valid package id form the duplicator_packages table
|
1496 |
*
|
1497 |
+
* @return DUP_Package // A copy of the DUP_Package object
|
1498 |
*/
|
1499 |
public static function getByID($id)
|
1500 |
{
|
1501 |
global $wpdb;
|
1502 |
+
$obj = new DUP_Package();
|
1503 |
$tablePrefix = DUP_Util::getTablePrefix();
|
1504 |
+
$sql = $wpdb->prepare("SELECT * FROM `{$tablePrefix}duplicator_packages` WHERE ID = %d", $id);
|
1505 |
+
$row = $wpdb->get_row($sql);
|
1506 |
if (is_object($row)) {
|
1507 |
+
$obj = @unserialize($row->package);
|
1508 |
+
// We was not storing Status in Lite 1.2.52, so it is for backward compatibility
|
1509 |
+
if (!isset($obj->Status)) {
|
1510 |
+
$obj->Status = $row->status;
|
1511 |
+
}
|
1512 |
}
|
1513 |
//Incase unserilaize fails
|
1514 |
$obj = (is_object($obj)) ? $obj : null;
|
1518 |
/**
|
1519 |
* Gets a default name for the package
|
1520 |
*
|
1521 |
+
* @return string // A default package name such as 20170218_blogname
|
1522 |
*/
|
1523 |
public static function getDefaultName($preDate = true)
|
1524 |
{
|
1562 |
/**
|
1563 |
* Provides various date formats
|
1564 |
*
|
1565 |
+
* @param $utcDate created date in the GMT timezone
|
1566 |
* @param $format Various date formats to apply
|
1567 |
*
|
1568 |
+
* @return string // a formated date based on the $format
|
1569 |
*/
|
1570 |
+
public static function getCreatedDateFormat($utcDate, $format = 1)
|
1571 |
{
|
1572 |
+
$date = get_date_from_gmt($utcDate);
|
1573 |
$date = new DateTime($date);
|
1574 |
switch ($format) {
|
1575 |
//YEAR
|
classes/package/duparchive/class.pack.archive.duparchive.php
CHANGED
@@ -10,6 +10,7 @@ require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/class.duparchive.l
|
|
10 |
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/class.duparchive.engine.php');
|
11 |
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/states/class.duparchive.state.create.php');
|
12 |
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/states/class.duparchive.state.expand.php');
|
|
|
13 |
|
14 |
class DUP_DupArchive_Logger extends DupArchiveLoggerBase
|
15 |
{
|
10 |
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/class.duparchive.engine.php');
|
11 |
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/states/class.duparchive.state.create.php');
|
12 |
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/states/class.duparchive.state.expand.php');
|
13 |
+
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/class.duparchive.processing.failure.php');
|
14 |
|
15 |
class DUP_DupArchive_Logger extends DupArchiveLoggerBase
|
16 |
{
|
classes/package/duparchive/class.pack.archive.duparchive.state.create.php
CHANGED
@@ -7,6 +7,7 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
|
7 |
*/
|
8 |
|
9 |
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/states/class.duparchive.state.create.php');
|
|
|
10 |
|
11 |
class DUP_DupArchive_Create_State extends DupArchiveCreateState
|
12 |
{
|
@@ -40,9 +41,6 @@ class DUP_DupArchive_Create_State extends DupArchiveCreateState
|
|
40 |
{
|
41 |
$instance = new DUP_DupArchive_Create_State();
|
42 |
|
43 |
-
/* @var $buildProgress DUP_Build_Progress */
|
44 |
-
$buildProgress = &$package->BuildProgress;
|
45 |
-
|
46 |
if ($setArchiveOffsetToEndOfArchive) {
|
47 |
$instance->archiveOffset = filesize($archivePath);
|
48 |
} else {
|
@@ -69,7 +67,7 @@ class DUP_DupArchive_Create_State extends DupArchiveCreateState
|
|
69 |
|
70 |
public function addFailure($type, $subject, $description, $isCritical = false)
|
71 |
{
|
72 |
-
|
73 |
}
|
74 |
|
75 |
public function save()
|
7 |
*/
|
8 |
|
9 |
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/states/class.duparchive.state.create.php');
|
10 |
+
require_once (DUPLICATOR_PLUGIN_PATH.'lib/dup_archive/classes/class.duparchive.processing.failure.php');
|
11 |
|
12 |
class DUP_DupArchive_Create_State extends DupArchiveCreateState
|
13 |
{
|
41 |
{
|
42 |
$instance = new DUP_DupArchive_Create_State();
|
43 |
|
|
|
|
|
|
|
44 |
if ($setArchiveOffsetToEndOfArchive) {
|
45 |
$instance->archiveOffset = filesize($archivePath);
|
46 |
} else {
|
67 |
|
68 |
public function addFailure($type, $subject, $description, $isCritical = false)
|
69 |
{
|
70 |
+
parent::addFailure($type, $subject, $description, $isCritical);
|
71 |
}
|
72 |
|
73 |
public function save()
|
classes/package/duparchive/class.pack.archive.duparchive.state.expand.php
CHANGED
@@ -76,18 +76,18 @@ class DUP_DupArchive_Expand_State extends DupArchiveExpandState
|
|
76 |
$data = new stdClass();
|
77 |
|
78 |
if($this->currentFileHeader != null) {
|
79 |
-
$data->currentFileHeaderString =
|
80 |
} else {
|
81 |
$data->currentFileHeaderString = null;
|
82 |
}
|
83 |
|
84 |
if($this->archiveHeader != null) {
|
85 |
-
$data->archiveHeaderString =
|
86 |
} else {
|
87 |
$data->archiveHeaderString = null;
|
88 |
}
|
89 |
|
90 |
-
$data->failuresString =
|
91 |
|
92 |
// Object members auto skipped
|
93 |
DUP_Util::objectCopy($this, $data);
|
76 |
$data = new stdClass();
|
77 |
|
78 |
if($this->currentFileHeader != null) {
|
79 |
+
$data->currentFileHeaderString = DupLiteSnapJsonU::wp_json_encode($this->currentFileHeader);
|
80 |
} else {
|
81 |
$data->currentFileHeaderString = null;
|
82 |
}
|
83 |
|
84 |
if($this->archiveHeader != null) {
|
85 |
+
$data->archiveHeaderString = DupLiteSnapJsonU::wp_json_encode($this->archiveHeader);
|
86 |
} else {
|
87 |
$data->archiveHeaderString = null;
|
88 |
}
|
89 |
|
90 |
+
$data->failuresString = DupLiteSnapJsonU::wp_json_encode($this->failures, JSON_FORCE_OBJECT);
|
91 |
|
92 |
// Object members auto skipped
|
93 |
DUP_Util::objectCopy($this, $data);
|
classes/ui/class.ui.notice.php
CHANGED
@@ -92,5 +92,42 @@ class DUP_UI_Notice
|
|
92 |
echo '</div>';
|
93 |
echo "<script>window.location = '{$location}';</script>";
|
94 |
die(esc_html__('Invalid token permissions to perform this request.', 'duplicator'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
}
|
92 |
echo '</div>';
|
93 |
echo "<script>window.location = '{$location}';</script>";
|
94 |
die(esc_html__('Invalid token permissions to perform this request.', 'duplicator'));
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Shows install deactivated function
|
100 |
+
*/
|
101 |
+
public static function installAutoDeactivatePlugins() {
|
102 |
+
$reactivatePluginsAfterInstallation = get_option('duplicator_reactivate_plugins_after_installation', false);
|
103 |
+
if (is_array($reactivatePluginsAfterInstallation)) {
|
104 |
+
$shouldBeActivated = array();
|
105 |
+
foreach ($reactivatePluginsAfterInstallation as $pluginSlug => $pluginTitle) {
|
106 |
+
if (!is_plugin_active($pluginSlug)) {
|
107 |
+
$shouldBeActivated[$pluginSlug] = $pluginTitle;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
if (empty($shouldBeActivated)) {
|
112 |
+
delete_option('duplicator_reactivate_plugins_after_installation', false);
|
113 |
+
} else {
|
114 |
+
$activatePluginsAnchors = array();
|
115 |
+
foreach ($shouldBeActivated as $slug => $title) {
|
116 |
+
$activateURL = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$slug), 'activate-plugin_'.$slug);
|
117 |
+
$anchorTitle = sprintf(esc_html__('Activate %s', 'duplicator'), $title);
|
118 |
+
$activatePluginsAnchors[] = '<a href="'.$activateURL.'"
|
119 |
+
title="'.esc_attr($anchorTitle).'">'.
|
120 |
+
$title.'</a>';
|
121 |
+
}
|
122 |
+
|
123 |
+
echo "<div class='update-nag dpro-admin-notice'>
|
124 |
+
<p>".
|
125 |
+
"<b>Warning!</b> Migration Almost Complete! <br/>".
|
126 |
+
"Plugin(s) listed here was deactivated during installation, Please activate them: <br/>".
|
127 |
+
implode(' ,', $activatePluginsAnchors).
|
128 |
+
"</p>".
|
129 |
+
"</div>";
|
130 |
+
}
|
131 |
+
}
|
132 |
}
|
133 |
}
|
classes/utilities/class.u.json.php
CHANGED
@@ -35,7 +35,7 @@ class DUP_JSON
|
|
35 |
public static function customEncode($value, $iteration = 1)
|
36 |
{
|
37 |
if (DUP_Util::$on_php_53_plus) {
|
38 |
-
$encoded =
|
39 |
|
40 |
switch (json_last_error()) {
|
41 |
case JSON_ERROR_NONE:
|
@@ -66,7 +66,7 @@ class DUP_JSON
|
|
66 |
public static function safeEncode($data, $options = 0, $depth = 512)
|
67 |
{
|
68 |
try {
|
69 |
-
$jsonString =
|
70 |
} catch (Exception $e) {
|
71 |
$jsonString = false;
|
72 |
}
|
35 |
public static function customEncode($value, $iteration = 1)
|
36 |
{
|
37 |
if (DUP_Util::$on_php_53_plus) {
|
38 |
+
$encoded = DupLiteSnapJsonU::wp_json_encode_pprint($value);
|
39 |
|
40 |
switch (json_last_error()) {
|
41 |
case JSON_ERROR_NONE:
|
66 |
public static function safeEncode($data, $options = 0, $depth = 512)
|
67 |
{
|
68 |
try {
|
69 |
+
$jsonString = DupLiteSnapJsonU::wp_json_encode($data, $options, $depth);
|
70 |
} catch (Exception $e) {
|
71 |
$jsonString = false;
|
72 |
}
|
classes/utilities/class.u.php
CHANGED
@@ -330,8 +330,13 @@ class DUP_Util
|
|
330 |
{
|
331 |
try {
|
332 |
$files = array();
|
333 |
-
|
334 |
-
|
|
|
|
|
|
|
|
|
|
|
335 |
}
|
336 |
return $files;
|
337 |
} catch (Exception $exc) {
|
@@ -530,7 +535,7 @@ class DUP_Util
|
|
530 |
$user = '';
|
531 |
try {
|
532 |
if (function_exists('exec')) {
|
533 |
-
$user = exec('whoami');
|
534 |
}
|
535 |
|
536 |
if (!strlen($user) && function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
|
@@ -730,8 +735,23 @@ class DUP_Util
|
|
730 |
} else {
|
731 |
return 0;
|
732 |
}
|
733 |
-
|
734 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
735 |
|
736 |
/**
|
737 |
* Finds if its a valid executable or not
|
@@ -816,5 +836,4 @@ class DUP_Util
|
|
816 |
{
|
817 |
return function_exists($function_name) && !in_array($function_name, self::getIniDisableFuncs());
|
818 |
}
|
819 |
-
}
|
820 |
-
DUP_Util::init();
|
330 |
{
|
331 |
try {
|
332 |
$files = array();
|
333 |
+
if ($dh = opendir($path)) {
|
334 |
+
while (($file = readdir($dh)) !== false) {
|
335 |
+
if ($file == '.' || $file == '..') continue;
|
336 |
+
$full_file_path = trailingslashit($path).$file;
|
337 |
+
$files[] = str_replace("\\", '/', $full_file_path);
|
338 |
+
}
|
339 |
+
@closedir($dh);
|
340 |
}
|
341 |
return $files;
|
342 |
} catch (Exception $exc) {
|
535 |
$user = '';
|
536 |
try {
|
537 |
if (function_exists('exec')) {
|
538 |
+
$user = @exec('whoami');
|
539 |
}
|
540 |
|
541 |
if (!strlen($user) && function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
|
735 |
} else {
|
736 |
return 0;
|
737 |
}
|
738 |
+
}
|
739 |
|
740 |
+
/**
|
741 |
+
* Check given table is exist in real
|
742 |
+
*
|
743 |
+
* @param $table string Table name
|
744 |
+
* @return booleam
|
745 |
+
*/
|
746 |
+
public static function isTableExists($table)
|
747 |
+
{
|
748 |
+
// It will clear the $GLOBALS['wpdb']->last_error var
|
749 |
+
$GLOBALS['wpdb']->flush();
|
750 |
+
$sql = "SELECT 1 FROM ".esc_sql($table)." LIMIT 1;";
|
751 |
+
$ret = $GLOBALS['wpdb']->get_var($sql);
|
752 |
+
if (empty($GLOBALS['wpdb']->last_error)) return true;
|
753 |
+
return false;
|
754 |
+
}
|
755 |
|
756 |
/**
|
757 |
* Finds if its a valid executable or not
|
836 |
{
|
837 |
return function_exists($function_name) && !in_array($function_name, self::getIniDisableFuncs());
|
838 |
}
|
839 |
+
}
|
|
classes/utilities/class.u.zip.php
CHANGED
@@ -25,40 +25,44 @@ class DUP_Zip_U
|
|
25 |
*
|
26 |
* @return bool Returns true if the directory was added to the object
|
27 |
*/
|
28 |
-
|
29 |
{
|
30 |
-
$success =
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
if ($retainDirectory) {
|
39 |
-
$
|
40 |
}
|
|
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
} else {
|
48 |
-
$added = false;
|
49 |
-
}
|
50 |
} else {
|
51 |
-
$added =
|
52 |
}
|
53 |
|
54 |
if (!$added) {
|
55 |
-
DUP_Log::error("Couldn't add file $
|
56 |
-
$success =
|
57 |
break;
|
58 |
}
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
}
|
63 |
|
64 |
|
25 |
*
|
26 |
* @return bool Returns true if the directory was added to the object
|
27 |
*/
|
28 |
+
public static function addDirWithZipArchive(&$zipArchive, $directoryPath, $retainDirectory, $localPrefix, $isCompressed)
|
29 |
{
|
30 |
+
$success = TRUE;
|
31 |
+
$directoryPath = rtrim($directoryPath, '/\\').'/';
|
32 |
+
if (!$fp = @opendir($directoryPath)) {
|
33 |
+
return FALSE;
|
34 |
+
}
|
35 |
+
while (FALSE !== ($file = readdir($fp))) {
|
36 |
+
if ($file === '.' || $file === '..') continue;
|
37 |
+
$objectPath = $directoryPath . $file;
|
38 |
+
// Not used DUP_U::safePath(), because I would like to decrease max_nest_level
|
39 |
+
// Otherwise we will get the error:
|
40 |
+
// PHP Fatal error: Uncaught Error: Maximum function nesting level of '512' reached, aborting! in ...
|
41 |
+
// $objectPath = DUP_U::safePath($objectPath);
|
42 |
+
$objectPath = str_replace("\\", '/', $objectPath);
|
43 |
+
$localName = ltrim(str_replace($directoryPath, '', $objectPath), '/');
|
44 |
if ($retainDirectory) {
|
45 |
+
$localName = basename($directoryPath)."/$localName";
|
46 |
}
|
47 |
+
$localName = $localPrefix . $localName;
|
48 |
|
49 |
+
if (is_dir($objectPath)) {
|
50 |
+
$localPrefixArg = substr($localName, 0, strrpos($localName, '/')).'/';
|
51 |
+
$added = self::addDirWithZipArchive($zipArchive, $objectPath, $retainDirectory, $localPrefixArg, $isCompressed);
|
52 |
+
} else if (is_readable($objectPath)) {
|
53 |
+
$added = DUP_Zip_U::addFileToZipArchive($zipArchive, $objectPath, $localName, $isCompressed);
|
|
|
|
|
|
|
54 |
} else {
|
55 |
+
$added = FALSE;
|
56 |
}
|
57 |
|
58 |
if (!$added) {
|
59 |
+
DUP_Log::error("Couldn't add file $objectPath to archive", '', false);
|
60 |
+
$success = FALSE;
|
61 |
break;
|
62 |
}
|
63 |
+
}
|
64 |
+
@closedir($fp);
|
65 |
+
return $success;
|
66 |
}
|
67 |
|
68 |
|
ctrls/ctrl.base.php
CHANGED
@@ -122,7 +122,7 @@ class DUP_CTRL_Result
|
|
122 |
|
123 |
switch ($this->CTRL->returnType) {
|
124 |
case 'JSON' :
|
125 |
-
return
|
126 |
break;
|
127 |
case 'PHP' :
|
128 |
return $this;
|
@@ -148,7 +148,7 @@ class DUP_CTRL_Result
|
|
148 |
$payload['Line'] = $exception->getLine();
|
149 |
$payload['Trace'] = $exception->getTraceAsString();
|
150 |
$this->process($payload, DUP_CTRL_Status::ERROR);
|
151 |
-
die(
|
152 |
}
|
153 |
|
154 |
private function getProcessTime()
|
122 |
|
123 |
switch ($this->CTRL->returnType) {
|
124 |
case 'JSON' :
|
125 |
+
return DupLiteSnapJsonU::wp_json_encode($this);
|
126 |
break;
|
127 |
case 'PHP' :
|
128 |
return $this;
|
148 |
$payload['Line'] = $exception->getLine();
|
149 |
$payload['Trace'] = $exception->getTraceAsString();
|
150 |
$this->process($payload, DUP_CTRL_Status::ERROR);
|
151 |
+
die(DupLiteSnapJsonU::wp_json_encode($this));
|
152 |
}
|
153 |
|
154 |
private function getProcessTime()
|
ctrls/ctrl.package.php
CHANGED
@@ -7,7 +7,9 @@ require_once(DUPLICATOR_PLUGIN_PATH.'/ctrls/ctrl.base.php');
|
|
7 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/utilities/class.u.scancheck.php');
|
8 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/utilities/class.u.json.php');
|
9 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/package/class.pack.php');
|
|
|
10 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/package/duparchive/class.pack.archive.duparchive.state.create.php');
|
|
|
11 |
/* @var $package DUP_Package */
|
12 |
|
13 |
/**
|
@@ -83,7 +85,7 @@ function duplicator_package_build()
|
|
83 |
$json['runtime'] = $Package->Runtime;
|
84 |
$json['exeSize'] = $Package->ExeSize;
|
85 |
$json['archiveSize'] = $Package->ZipSize;
|
86 |
-
$json_response =
|
87 |
|
88 |
//Simulate a Host Build Interrupt
|
89 |
//die(0);
|
@@ -100,9 +102,8 @@ function duplicator_package_build()
|
|
100 |
function duplicator_duparchive_package_build()
|
101 |
{
|
102 |
DUP_Handler::init_error_handler();
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
check_ajax_referer('duplicator_duparchive_package_build', 'nonce');
|
107 |
DUP_Util::hasCapability('export');
|
108 |
header('Content-Type: application/json');
|
@@ -114,36 +115,45 @@ function duplicator_duparchive_package_build()
|
|
114 |
// The DupArchive build process always works on a saved package so the first time through save the active package to the package table.
|
115 |
// After that, just retrieve it.
|
116 |
$active_package_id = DUP_Settings::Get('active_package_id');
|
|
|
117 |
|
118 |
if ($active_package_id == -1) {
|
119 |
$package = DUP_Package::getActive();
|
120 |
$package->save('daf');
|
121 |
-
DUP_Log::
|
|
|
122 |
DUP_Settings::Set('active_package_id', $package->ID);
|
123 |
DUP_Settings::Save();
|
124 |
} else {
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
127 |
}
|
128 |
|
129 |
if (!is_readable(DUPLICATOR_SSDIR_PATH_TMP."/{$package->ScanFile}")) {
|
|
|
130 |
die("The scan result file was not found. Please run the scan step before building the package.");
|
131 |
}
|
132 |
|
133 |
if ($package === null) {
|
|
|
134 |
die("There is no active package.");
|
135 |
}
|
136 |
|
137 |
if($package->Status == DUP_PackageStatus::ERROR) {
|
|
|
138 |
$hasCompleted = true;
|
139 |
} else {
|
140 |
try {
|
141 |
$hasCompleted = $package->runDupArchiveBuild();
|
142 |
}
|
143 |
catch(Exception $ex) {
|
144 |
-
|
145 |
-
Dup_Log::Error('Caught exception', $ex->getMessage(), Dup_ErrorBehavior::LogOnly);
|
146 |
-
|
147 |
$package->setStatus(DUP_PackageStatus::ERROR);
|
148 |
$hasCompleted = true;
|
149 |
}
|
@@ -151,17 +161,17 @@ function duplicator_duparchive_package_build()
|
|
151 |
|
152 |
$json = array();
|
153 |
$json['failures'] = array_merge($package->BuildProgress->build_failures, $package->BuildProgress->validation_failures);
|
154 |
-
|
|
|
|
|
155 |
|
156 |
//JSON:Debug Response
|
157 |
//Pass = 1, Warn = 2, 3 = Failure, 4 = Not Done
|
158 |
if ($hasCompleted) {
|
159 |
-
|
160 |
-
Dup_Log::Trace('#### completed');
|
161 |
|
162 |
if($package->Status == DUP_PackageStatus::ERROR) {
|
163 |
-
|
164 |
-
Dup_Log::Trace('#### error');
|
165 |
$error_message = __('Error building DupArchive package') . '<br/>';
|
166 |
|
167 |
foreach($json['failures'] as $failure) {
|
@@ -169,7 +179,7 @@ function duplicator_duparchive_package_build()
|
|
169 |
}
|
170 |
|
171 |
Dup_Log::Error("Build failed so sending back error", esc_html($error_message), Dup_ErrorBehavior::LogOnly);
|
172 |
-
|
173 |
|
174 |
$json['status'] = 3;
|
175 |
} else {
|
@@ -182,12 +192,13 @@ function duplicator_duparchive_package_build()
|
|
182 |
$json['runtime'] = $package->Runtime;
|
183 |
$json['exeSize'] = $package->ExeSize;
|
184 |
$json['archiveSize'] = $package->ZipSize;
|
|
|
185 |
} else {
|
186 |
-
|
187 |
$json['status'] = 4;
|
188 |
}
|
189 |
|
190 |
-
$json_response =
|
191 |
|
192 |
Dup_Log::TraceObject('json response', $json_response);
|
193 |
error_reporting($errLevel);
|
@@ -265,12 +276,12 @@ function duplicator_package_delete()
|
|
265 |
}
|
266 |
} catch (Exception $e) {
|
267 |
$json['error'] = "{$e}";
|
268 |
-
die(
|
269 |
}
|
270 |
|
271 |
$json['ids'] = "{$postIDs}";
|
272 |
$json['removed'] = $delCount;
|
273 |
-
echo
|
274 |
die();
|
275 |
}
|
276 |
|
@@ -529,7 +540,6 @@ class DUP_CTRL_Package extends DUP_CTRL_Base
|
|
529 |
|
530 |
if($package != null) {
|
531 |
$test = DUP_CTRL_Status::SUCCESS;
|
532 |
-
|
533 |
$payload['status'] = $package->Status;
|
534 |
} else {
|
535 |
$test = DUP_CTRL_Status::FAILED;
|
7 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/utilities/class.u.scancheck.php');
|
8 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/utilities/class.u.json.php');
|
9 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/package/class.pack.php');
|
10 |
+
|
11 |
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/package/duparchive/class.pack.archive.duparchive.state.create.php');
|
12 |
+
require_once(DUPLICATOR_PLUGIN_PATH.'/classes/package/duparchive/class.pack.archive.duparchive.php');
|
13 |
/* @var $package DUP_Package */
|
14 |
|
15 |
/**
|
85 |
$json['runtime'] = $Package->Runtime;
|
86 |
$json['exeSize'] = $Package->ExeSize;
|
87 |
$json['archiveSize'] = $Package->ZipSize;
|
88 |
+
$json_response = DupLiteSnapJsonU::wp_json_encode($json);
|
89 |
|
90 |
//Simulate a Host Build Interrupt
|
91 |
//die(0);
|
102 |
function duplicator_duparchive_package_build()
|
103 |
{
|
104 |
DUP_Handler::init_error_handler();
|
105 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] CALL TO '.__FUNCTION__);
|
106 |
+
|
|
|
107 |
check_ajax_referer('duplicator_duparchive_package_build', 'nonce');
|
108 |
DUP_Util::hasCapability('export');
|
109 |
header('Content-Type: application/json');
|
115 |
// The DupArchive build process always works on a saved package so the first time through save the active package to the package table.
|
116 |
// After that, just retrieve it.
|
117 |
$active_package_id = DUP_Settings::Get('active_package_id');
|
118 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] CURRENT PACKAGE ACTIVE '.$active_package_id);
|
119 |
|
120 |
if ($active_package_id == -1) {
|
121 |
$package = DUP_Package::getActive();
|
122 |
$package->save('daf');
|
123 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] PACKAGE AS NEW ID '.$package->ID.' SAVED | STATUS:'.$package->Status);
|
124 |
+
//DUP_Log::TraceObject("[CTRL DUP ARCIVE] PACKAGE SAVED:", $package);
|
125 |
DUP_Settings::Set('active_package_id', $package->ID);
|
126 |
DUP_Settings::Save();
|
127 |
} else {
|
128 |
+
if (($package = DUP_Package::getByID($active_package_id)) == null) {
|
129 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] ERROR: Get package by id '.$active_package_id.' FAILED');
|
130 |
+
die('Get package by id '.$active_package_id.' FAILED');
|
131 |
+
}
|
132 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] PACKAGE GET BY ID '.$active_package_id.' | STATUS:'.$package->Status);
|
133 |
+
// DUP_Log::TraceObject("getting active package by id {$active_package_id}", $package);
|
134 |
}
|
135 |
|
136 |
if (!is_readable(DUPLICATOR_SSDIR_PATH_TMP."/{$package->ScanFile}")) {
|
137 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] ERROR: The scan result file was not found. Please run the scan step before building the package.');
|
138 |
die("The scan result file was not found. Please run the scan step before building the package.");
|
139 |
}
|
140 |
|
141 |
if ($package === null) {
|
142 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] There is no active package.');
|
143 |
die("There is no active package.");
|
144 |
}
|
145 |
|
146 |
if($package->Status == DUP_PackageStatus::ERROR) {
|
147 |
+
$package->setStatus(DUP_PackageStatus::ERROR);
|
148 |
$hasCompleted = true;
|
149 |
} else {
|
150 |
try {
|
151 |
$hasCompleted = $package->runDupArchiveBuild();
|
152 |
}
|
153 |
catch(Exception $ex) {
|
154 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] ERROR: caught exception');
|
155 |
+
Dup_Log::Error('[CTRL DUP ARCIVE] Caught exception', $ex->getMessage(), Dup_ErrorBehavior::LogOnly);
|
156 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] ERROR: after log');
|
157 |
$package->setStatus(DUP_PackageStatus::ERROR);
|
158 |
$hasCompleted = true;
|
159 |
}
|
161 |
|
162 |
$json = array();
|
163 |
$json['failures'] = array_merge($package->BuildProgress->build_failures, $package->BuildProgress->validation_failures);
|
164 |
+
if (!empty($json['failures'])) {
|
165 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] FAILURES', $json['failures']);
|
166 |
+
}
|
167 |
|
168 |
//JSON:Debug Response
|
169 |
//Pass = 1, Warn = 2, 3 = Failure, 4 = Not Done
|
170 |
if ($hasCompleted) {
|
171 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] COMPLETED PACKAGE STATUS: '.$package->Status);
|
|
|
172 |
|
173 |
if($package->Status == DUP_PackageStatus::ERROR) {
|
174 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] ERROR');
|
|
|
175 |
$error_message = __('Error building DupArchive package') . '<br/>';
|
176 |
|
177 |
foreach($json['failures'] as $failure) {
|
179 |
}
|
180 |
|
181 |
Dup_Log::Error("Build failed so sending back error", esc_html($error_message), Dup_ErrorBehavior::LogOnly);
|
182 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] ERROR AFTER LOG 2');
|
183 |
|
184 |
$json['status'] = 3;
|
185 |
} else {
|
192 |
$json['runtime'] = $package->Runtime;
|
193 |
$json['exeSize'] = $package->ExeSize;
|
194 |
$json['archiveSize'] = $package->ZipSize;
|
195 |
+
DUP_Log::Trace('[CTRL DUP ARCIVE] JSON PACKAGE');
|
196 |
} else {
|
197 |
+
DUP_Log::Info('[CTRL DUP ARCIVE] sending back continue status PACKAGE STATUS: '.$package->Status);
|
198 |
$json['status'] = 4;
|
199 |
}
|
200 |
|
201 |
+
$json_response = DupLiteSnapJsonU::wp_json_encode($json);
|
202 |
|
203 |
Dup_Log::TraceObject('json response', $json_response);
|
204 |
error_reporting($errLevel);
|
276 |
}
|
277 |
} catch (Exception $e) {
|
278 |
$json['error'] = "{$e}";
|
279 |
+
die(DupLiteSnapJsonU::wp_json_encode($json));
|
280 |
}
|
281 |
|
282 |
$json['ids'] = "{$postIDs}";
|
283 |
$json['removed'] = $delCount;
|
284 |
+
echo DupLiteSnapJsonU::wp_json_encode($json);
|
285 |
die();
|
286 |
}
|
287 |
|
540 |
|
541 |
if($package != null) {
|
542 |
$test = DUP_CTRL_Status::SUCCESS;
|
|
|
543 |
$payload['status'] = $package->Status;
|
544 |
} else {
|
545 |
$test = DUP_CTRL_Status::FAILED;
|
deactivation.php
CHANGED
@@ -127,7 +127,7 @@ if (!function_exists('duplicator_add_deactivation_feedback_dialog_box')) {
|
|
127 |
+ ' <div class="duplicator-modal-body">'
|
128 |
+ ' <h2><?php _e('Quick Feedback', 'duplicator'); ?></h2>'
|
129 |
+ ' <div class="duplicator-modal-panel active"><p><?php _e('If you have a moment, please let us know why you are deactivating', 'duplicator'); ?>:</p>'
|
130 |
-
+ '<ul>' + <?php echo
|
131 |
+ ' </div>'
|
132 |
+ ' </div>'
|
133 |
+ ' <div class="duplicator-modal-footer">'
|
127 |
+ ' <div class="duplicator-modal-body">'
|
128 |
+ ' <h2><?php _e('Quick Feedback', 'duplicator'); ?></h2>'
|
129 |
+ ' <div class="duplicator-modal-panel active"><p><?php _e('If you have a moment, please let us know why you are deactivating', 'duplicator'); ?>:</p>'
|
130 |
+
+ '<ul>' + <?php echo DupLiteSnapJsonU::wp_json_encode($reasons_list_items_html); ?> + '</ul>'
|
131 |
+ ' </div>'
|
132 |
+ ' </div>'
|
133 |
+ ' <div class="duplicator-modal-footer">'
|
define.php
CHANGED
@@ -4,8 +4,8 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
|
4 |
//Prevent directly browsing to the file
|
5 |
if (function_exists('plugin_dir_url'))
|
6 |
{
|
7 |
-
define('DUPLICATOR_VERSION', '1.3.
|
8 |
-
define('DUPLICATOR_VERSION_BUILD', '2019-
|
9 |
define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
|
10 |
define('DUPLICATOR_SITE_URL', get_site_url());
|
11 |
|
@@ -57,6 +57,7 @@ if (function_exists('plugin_dir_url'))
|
|
57 |
define("DUPLICATOR_INSTALLER_DIRECTORY", DUPLICATOR_WPROOTPATH . 'dup-installer');
|
58 |
define('DUPLICATOR_MAX_LOG_SIZE', 400000); // The higher this is the more overhead
|
59 |
define('DUPLICATOR_ZIP_ARCHIVE_ADD_FROM_STR', false);
|
|
|
60 |
|
61 |
$GLOBALS['DUPLICATOR_SERVER_LIST'] = array('Apache','LiteSpeed', 'Nginx', 'Lighttpd', 'IIS', 'WebServerX', 'uWSGI');
|
62 |
$GLOBALS['DUPLICATOR_OPTS_DELETE'] = array('duplicator_ui_view_state', 'duplicator_package_active', 'duplicator_settings');
|
4 |
//Prevent directly browsing to the file
|
5 |
if (function_exists('plugin_dir_url'))
|
6 |
{
|
7 |
+
define('DUPLICATOR_VERSION', '1.3.20');
|
8 |
+
define('DUPLICATOR_VERSION_BUILD', '2019-08-30_16:20');
|
9 |
define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
|
10 |
define('DUPLICATOR_SITE_URL', get_site_url());
|
11 |
|
57 |
define("DUPLICATOR_INSTALLER_DIRECTORY", DUPLICATOR_WPROOTPATH . 'dup-installer');
|
58 |
define('DUPLICATOR_MAX_LOG_SIZE', 400000); // The higher this is the more overhead
|
59 |
define('DUPLICATOR_ZIP_ARCHIVE_ADD_FROM_STR', false);
|
60 |
+
define('DUPLICATOR_DEACTIVATION_FEEDBACK', false);
|
61 |
|
62 |
$GLOBALS['DUPLICATOR_SERVER_LIST'] = array('Apache','LiteSpeed', 'Nginx', 'Lighttpd', 'IIS', 'WebServerX', 'uWSGI');
|
63 |
$GLOBALS['DUPLICATOR_OPTS_DELETE'] = array('duplicator_ui_view_state', 'duplicator_package_active', 'duplicator_settings');
|
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
|
@@ -155,7 +155,9 @@ if (!function_exists('wp_normalize_path')) {
|
|
155 |
|
156 |
if (is_admin() == true)
|
157 |
{
|
158 |
-
|
|
|
|
|
159 |
require_once 'lib/snaplib/snaplib.all.php';
|
160 |
require_once 'classes/class.constants.php';
|
161 |
$isWPEngineHost = apply_filters('duplicator_wp_engine_host_check', file_exists(WPMU_PLUGIN_DIR.'/wpengine-common/mu-plugin.php'));
|
@@ -185,12 +187,18 @@ if (is_admin() == true)
|
|
185 |
require_once 'classes/ui/class.ui.notice.php';
|
186 |
require_once 'classes/package/class.pack.php';
|
187 |
require_once 'views/packages/screen.php';
|
188 |
-
|
189 |
//Controllers
|
190 |
require_once 'ctrls/ctrl.package.php';
|
191 |
require_once 'ctrls/ctrl.tools.php';
|
192 |
require_once 'ctrls/ctrl.ui.php';
|
193 |
require_once 'ctrls/class.web.services.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
/** ========================================================
|
196 |
* ACTIVATE/DEACTIVE/UPDATE HOOKS
|
@@ -278,7 +286,8 @@ if (is_admin() == true)
|
|
278 |
add_action('admin_init', 'duplicator_init');
|
279 |
add_action('admin_menu', 'duplicator_menu');
|
280 |
add_action('admin_enqueue_scripts', 'duplicator_admin_enqueue_scripts' );
|
281 |
-
|
|
|
282 |
|
283 |
//CTRL ACTIONS
|
284 |
DUP_Web_Services::init();
|
@@ -329,6 +338,12 @@ if (is_admin() == true)
|
|
329 |
|
330 |
// Clean tmp folder
|
331 |
DUP_Package::not_active_files_tmp_cleanup();
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
}
|
333 |
|
334 |
/**
|
@@ -503,5 +518,49 @@ if (is_admin() == true)
|
|
503 |
exit;
|
504 |
}
|
505 |
|
506 |
-
|
507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.20
|
7 |
Author: Snap Creek
|
8 |
Author URI: http://www.snapcreek.com/duplicator/
|
9 |
Text Domain: duplicator
|
155 |
|
156 |
if (is_admin() == true)
|
157 |
{
|
158 |
+
if (defined('DUPLICATOR_DEACTIVATION_FEEDBACK') && DUPLICATOR_DEACTIVATION_FEEDBACK) {
|
159 |
+
require_once 'deactivation.php';
|
160 |
+
}
|
161 |
require_once 'lib/snaplib/snaplib.all.php';
|
162 |
require_once 'classes/class.constants.php';
|
163 |
$isWPEngineHost = apply_filters('duplicator_wp_engine_host_check', file_exists(WPMU_PLUGIN_DIR.'/wpengine-common/mu-plugin.php'));
|
187 |
require_once 'classes/ui/class.ui.notice.php';
|
188 |
require_once 'classes/package/class.pack.php';
|
189 |
require_once 'views/packages/screen.php';
|
190 |
+
|
191 |
//Controllers
|
192 |
require_once 'ctrls/ctrl.package.php';
|
193 |
require_once 'ctrls/ctrl.tools.php';
|
194 |
require_once 'ctrls/ctrl.ui.php';
|
195 |
require_once 'ctrls/class.web.services.php';
|
196 |
+
|
197 |
+
//Init Class
|
198 |
+
DUP_Settings::init();
|
199 |
+
DUP_Log::Init();
|
200 |
+
DUP_Util::init();
|
201 |
+
DUP_DB::init();
|
202 |
|
203 |
/** ========================================================
|
204 |
* ACTIVATE/DEACTIVE/UPDATE HOOKS
|
286 |
add_action('admin_init', 'duplicator_init');
|
287 |
add_action('admin_menu', 'duplicator_menu');
|
288 |
add_action('admin_enqueue_scripts', 'duplicator_admin_enqueue_scripts' );
|
289 |
+
add_action('admin_notices', array('DUP_UI_Notice', 'showReservedFilesNotice'));
|
290 |
+
add_action('admin_notices', array('DUP_UI_Notice', 'installAutoDeactivatePlugins'));
|
291 |
|
292 |
//CTRL ACTIONS
|
293 |
DUP_Web_Services::init();
|
338 |
|
339 |
// Clean tmp folder
|
340 |
DUP_Package::not_active_files_tmp_cleanup();
|
341 |
+
|
342 |
+
$unhook_third_party_js = DUP_Settings::Get('unhook_third_party_js');
|
343 |
+
$unhook_third_party_css = DUP_Settings::Get('unhook_third_party_css');
|
344 |
+
if ($unhook_third_party_js || $unhook_third_party_css) {
|
345 |
+
add_action('admin_enqueue_scripts', 'duplicator_unhook_third_party_assets', 99999, 1);
|
346 |
+
}
|
347 |
}
|
348 |
|
349 |
/**
|
518 |
exit;
|
519 |
}
|
520 |
|
521 |
+
if (!function_exists('duplicator_unhook_third_party_assets')) {
|
522 |
+
/**
|
523 |
+
* Remove all external styles and scripts coming from other plugins
|
524 |
+
* which may cause compatibility issue, especially with React
|
525 |
+
*
|
526 |
+
* @return void
|
527 |
+
*/
|
528 |
+
function duplicator_unhook_third_party_assets($hook)
|
529 |
+
{
|
530 |
+
/*
|
531 |
+
$hook values in duplicator admin pages:
|
532 |
+
toplevel_page_duplicator
|
533 |
+
duplicator_page_duplicator-tools
|
534 |
+
duplicator_page_duplicator-settings
|
535 |
+
duplicator_page_duplicator-gopro
|
536 |
+
*/
|
537 |
+
if (strpos($hook, 'duplicator') !== false && strpos($hook, 'duplicator-pro') === false) {
|
538 |
+
$unhook_third_party_js = DUP_Settings::Get('unhook_third_party_js');
|
539 |
+
$unhook_third_party_css = DUP_Settings::Get('unhook_third_party_css');
|
540 |
+
$assets = array();
|
541 |
+
if ($unhook_third_party_css) $assets['styles'] = wp_styles();
|
542 |
+
if ($unhook_third_party_js) $assets['scripts'] = wp_scripts();
|
543 |
+
foreach ($assets as $type => $asset) {
|
544 |
+
foreach ($asset->registered as $handle => $dep) {
|
545 |
+
$src = $dep->src;
|
546 |
+
// test if the src is coming from /wp-admin/ or /wp-includes/ or /wp-fsqm-pro/.
|
547 |
+
if (
|
548 |
+
is_string($src) && // For some built-ins, $src is true|false
|
549 |
+
strpos($src, 'wp-admin') === false &&
|
550 |
+
strpos($src, 'wp-include') === false &&
|
551 |
+
// things below are specific to your plugin, so change them
|
552 |
+
strpos($src, 'duplicator') === false &&
|
553 |
+
strpos($src, 'woocommerce') === false &&
|
554 |
+
strpos($src, 'jetpack') === false &&
|
555 |
+
strpos($src, 'debug-bar') === false
|
556 |
+
) {
|
557 |
+
'scripts' === $type
|
558 |
+
? wp_dequeue_script($handle)
|
559 |
+
: wp_dequeue_style($handle);
|
560 |
+
}
|
561 |
+
}
|
562 |
+
}
|
563 |
+
}
|
564 |
+
}
|
565 |
+
}
|
566 |
+
}
|
installer/dup-installer/assets/inc.css.php
CHANGED
@@ -35,7 +35,6 @@
|
|
35 |
}
|
36 |
|
37 |
select , option {
|
38 |
-
background-color: lightgray;
|
39 |
color: black;
|
40 |
}
|
41 |
select {
|
35 |
}
|
36 |
|
37 |
select , option {
|
|
|
38 |
color: black;
|
39 |
}
|
40 |
select {
|
installer/dup-installer/classes/class.csrf.php
CHANGED
@@ -3,12 +3,26 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
|
3 |
|
4 |
class DUPX_CSRF {
|
5 |
|
6 |
-
/**
|
|
|
7 |
* @var string
|
8 |
*/
|
9 |
public static $prefix = '_DUPX_CSRF';
|
|
|
|
|
|
|
|
|
|
|
10 |
private static $CSRFVars;
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
public static function setKeyVal($key, $val) {
|
13 |
$CSRFVars = self::getCSRFVars();
|
14 |
$CSRFVars[$key] = $val;
|
@@ -16,6 +30,13 @@ class DUPX_CSRF {
|
|
16 |
self::$CSRFVars = false;
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
public static function getVal($key) {
|
20 |
$CSRFVars = self::getCSRFVars();
|
21 |
if (isset($CSRFVars[$key])) {
|
@@ -23,10 +44,10 @@ class DUPX_CSRF {
|
|
23 |
} else {
|
24 |
return false;
|
25 |
}
|
26 |
-
|
27 |
}
|
28 |
|
29 |
/** Generate DUPX_CSRF value for form
|
|
|
30 |
* @param string $form - Form name as session key
|
31 |
* @return string - token
|
32 |
*/
|
@@ -44,7 +65,9 @@ class DUPX_CSRF {
|
|
44 |
return $token;
|
45 |
}
|
46 |
|
47 |
-
/**
|
|
|
|
|
48 |
* @param string $token - Token
|
49 |
* @param string $form - Form name as session key
|
50 |
* @return boolean
|
@@ -76,10 +99,21 @@ class DUPX_CSRF {
|
|
76 |
return strtoupper(md5(implode('|', array($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']))));
|
77 |
}
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
private static function getKeyName($form) {
|
80 |
return DUPX_CSRF::$prefix . '_' . $form;
|
81 |
}
|
82 |
|
|
|
|
|
|
|
|
|
|
|
83 |
private static function getPackageHash() {
|
84 |
if (class_exists('DUPX_Bootstrap')) {
|
85 |
return DUPX_Bootstrap::PACKAGE_HASH;
|
@@ -88,6 +122,11 @@ class DUPX_CSRF {
|
|
88 |
}
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
91 |
private static function getFilePath() {
|
92 |
if (class_exists('DUPX_Bootstrap')) {
|
93 |
$dupInstallerfolderPath = dirname(__FILE__).'/dup-installer/';
|
@@ -100,6 +139,11 @@ class DUPX_CSRF {
|
|
100 |
return $filePath;
|
101 |
}
|
102 |
|
|
|
|
|
|
|
|
|
|
|
103 |
private static function getCSRFVars() {
|
104 |
if (!isset(self::$CSRFVars) || false === self::$CSRFVars) {
|
105 |
$filePath = self::getFilePath();
|
@@ -120,11 +164,15 @@ class DUPX_CSRF {
|
|
120 |
return self::$CSRFVars;
|
121 |
}
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
private static function saveCSRFVars($CSRFVars) {
|
124 |
-
$contents =
|
125 |
$filePath = self::getFilePath();
|
126 |
file_put_contents($filePath, $contents);
|
127 |
}
|
128 |
-
}
|
129 |
-
|
130 |
-
?>
|
3 |
|
4 |
class DUPX_CSRF {
|
5 |
|
6 |
+
/**
|
7 |
+
* Session var name prefix
|
8 |
* @var string
|
9 |
*/
|
10 |
public static $prefix = '_DUPX_CSRF';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Stores all CSRF values: Key as CSRF name and Val as CRF value
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
private static $CSRFVars;
|
17 |
|
18 |
+
/**
|
19 |
+
* Set new CSRF
|
20 |
+
*
|
21 |
+
* @param $key string CSRF Key
|
22 |
+
* @param $key string CSRF Val
|
23 |
+
*
|
24 |
+
* @return Void
|
25 |
+
*/
|
26 |
public static function setKeyVal($key, $val) {
|
27 |
$CSRFVars = self::getCSRFVars();
|
28 |
$CSRFVars[$key] = $val;
|
30 |
self::$CSRFVars = false;
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* Get CSRF value by passing CSRF key
|
35 |
+
*
|
36 |
+
* @param $key string CSRF key
|
37 |
+
*
|
38 |
+
* @return string|boolean If CSRF value set for give n Key, It returns CRF value otherise returns false
|
39 |
+
*/
|
40 |
public static function getVal($key) {
|
41 |
$CSRFVars = self::getCSRFVars();
|
42 |
if (isset($CSRFVars[$key])) {
|
44 |
} else {
|
45 |
return false;
|
46 |
}
|
|
|
47 |
}
|
48 |
|
49 |
/** Generate DUPX_CSRF value for form
|
50 |
+
*
|
51 |
* @param string $form - Form name as session key
|
52 |
* @return string - token
|
53 |
*/
|
65 |
return $token;
|
66 |
}
|
67 |
|
68 |
+
/**
|
69 |
+
* Check DUPX_CSRF value of form
|
70 |
+
*
|
71 |
* @param string $token - Token
|
72 |
* @param string $form - Form name as session key
|
73 |
* @return boolean
|
99 |
return strtoupper(md5(implode('|', array($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']))));
|
100 |
}
|
101 |
|
102 |
+
/**
|
103 |
+
* Generate CSRF Key name
|
104 |
+
*
|
105 |
+
* @param string the form name for which CSRF key need to generate
|
106 |
+
* @return string CSRF key
|
107 |
+
*/
|
108 |
private static function getKeyName($form) {
|
109 |
return DUPX_CSRF::$prefix . '_' . $form;
|
110 |
}
|
111 |
|
112 |
+
/**
|
113 |
+
* Get Package hash
|
114 |
+
*
|
115 |
+
* @return string Package hash
|
116 |
+
*/
|
117 |
private static function getPackageHash() {
|
118 |
if (class_exists('DUPX_Bootstrap')) {
|
119 |
return DUPX_Bootstrap::PACKAGE_HASH;
|
122 |
}
|
123 |
}
|
124 |
|
125 |
+
/**
|
126 |
+
* Get file path where CSRF tokens are stored in JSON encoded format
|
127 |
+
*
|
128 |
+
* @return string file path where CSRF token stored
|
129 |
+
*/
|
130 |
private static function getFilePath() {
|
131 |
if (class_exists('DUPX_Bootstrap')) {
|
132 |
$dupInstallerfolderPath = dirname(__FILE__).'/dup-installer/';
|
139 |
return $filePath;
|
140 |
}
|
141 |
|
142 |
+
/**
|
143 |
+
* Get all CSRF vars in array format
|
144 |
+
*
|
145 |
+
* @return array Key as CSRF name and value as CSRF value
|
146 |
+
*/
|
147 |
private static function getCSRFVars() {
|
148 |
if (!isset(self::$CSRFVars) || false === self::$CSRFVars) {
|
149 |
$filePath = self::getFilePath();
|
164 |
return self::$CSRFVars;
|
165 |
}
|
166 |
|
167 |
+
/**
|
168 |
+
* Stores all CSRF vars
|
169 |
+
*
|
170 |
+
* @param $CSRFVars array holds all CSRF key val
|
171 |
+
* @return void
|
172 |
+
*/
|
173 |
private static function saveCSRFVars($CSRFVars) {
|
174 |
+
$contents = DupLiteSnapJsonU::wp_json_encode($CSRFVars);
|
175 |
$filePath = self::getFilePath();
|
176 |
file_put_contents($filePath, $contents);
|
177 |
}
|
178 |
+
}
|
|
|
|
installer/dup-installer/classes/class.installer.state.php
CHANGED
@@ -81,7 +81,7 @@ class DUPX_InstallerState
|
|
81 |
|
82 |
public function save()
|
83 |
{
|
84 |
-
$data =
|
85 |
|
86 |
DupLiteSnapLibIOU::filePutContents(self::$state_filepath, $data);
|
87 |
}
|
81 |
|
82 |
public function save()
|
83 |
{
|
84 |
+
$data = DupLiteSnapJsonU::wp_json_encode($this);
|
85 |
|
86 |
DupLiteSnapLibIOU::filePutContents(self::$state_filepath, $data);
|
87 |
}
|
installer/dup-installer/classes/class.s3.func.php
CHANGED
@@ -376,14 +376,17 @@ final class DUPX_S3_Funcs
|
|
376 |
|
377 |
if (is_null($configTransformer)) {
|
378 |
//@todo: integrate all logic into DUPX_WPConfig::updateVars
|
379 |
-
if (is_writable(DUPX_Package::getWpconfigArkPath())) {
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
|
|
|
|
386 |
}
|
|
|
387 |
}
|
388 |
|
389 |
return $configTransformer;
|
@@ -983,21 +986,13 @@ LONGMSG;
|
|
983 |
self::logSectionHeader('GENERAL UPDATES & CLEANUP', __FUNCTION__, __LINE__);
|
984 |
// make sure dbConnection is inizialized
|
985 |
$this->dbConnection();
|
986 |
-
|
987 |
$blog_name = mysqli_real_escape_string($this->dbh, $this->post['blogname']);
|
988 |
-
|
989 |
-
|
990 |
-
if (!in_array('duplicator/duplicator.php', $plugin_list)) {
|
991 |
-
$plugin_list[] = 'duplicator/duplicator.php';
|
992 |
-
}
|
993 |
-
$serial_plugin_list = @serialize($plugin_list);
|
994 |
-
|
995 |
/** FINAL UPDATES: Must happen after the global replace to prevent double pathing
|
996 |
http://xyz.com/abc01 will become http://xyz.com/abc0101 with trailing data */
|
997 |
mysqli_query($this->dbh,
|
998 |
"UPDATE `".mysqli_real_escape_string($this->dbh, $GLOBALS['DUPX_AC']->wp_tableprefix)."options` SET option_value = '".mysqli_real_escape_string($this->dbh, $blog_name)."' WHERE option_name = 'blogname' ");
|
999 |
-
mysqli_query($this->dbh,
|
1000 |
-
"UPDATE `".mysqli_real_escape_string($this->dbh, $GLOBALS['DUPX_AC']->wp_tableprefix)."options` SET option_value = '".mysqli_real_escape_string($this->dbh, $serial_plugin_list)."' WHERE option_name = 'active_plugins' ");
|
1001 |
mysqli_query($this->dbh,
|
1002 |
"UPDATE `".mysqli_real_escape_string($this->dbh, $GLOBALS['DUPX_AC']->wp_tableprefix)."options` SET option_value = '".mysqli_real_escape_string($this->dbh, $this->post['url_new'])."' WHERE option_name = 'home' ");
|
1003 |
mysqli_query($this->dbh,
|
@@ -1015,6 +1010,105 @@ LONGMSG;
|
|
1015 |
}
|
1016 |
}
|
1017 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1018 |
public function noticeTest()
|
1019 |
{
|
1020 |
self::logSectionHeader('NOTICES TEST', __FUNCTION__, __LINE__);
|
376 |
|
377 |
if (is_null($configTransformer)) {
|
378 |
//@todo: integrate all logic into DUPX_WPConfig::updateVars
|
379 |
+
if (!is_writable(DUPX_Package::getWpconfigArkPath())) {
|
380 |
+
if (DupLiteSnapLibIOU::chmod(DUPX_Package::getWpconfigArkPath(), 0644)) {
|
381 |
+
DUPX_Log::info("File Permission Update: dup-wp-config-arc__[HASH].txt set to 0644");
|
382 |
+
} else {
|
383 |
+
$err_log = "\nWARNING: Unable to update file permissions and write to dup-wp-config-arc__[HASH].txt. ";
|
384 |
+
$err_log .= "Check that the wp-config.php is in the archive.zip and check with your host or administrator to enable PHP to write to the wp-config.php file. ";
|
385 |
+
$err_log .= "If performing a 'Manual Extraction' please be sure to select the 'Manual Archive Extraction' option on step 1 under options.";
|
386 |
+
DUPX_Log::error($err_log);
|
387 |
+
}
|
388 |
}
|
389 |
+
$configTransformer = new WPConfigTransformer(DUPX_Package::getWpconfigArkPath());
|
390 |
}
|
391 |
|
392 |
return $configTransformer;
|
986 |
self::logSectionHeader('GENERAL UPDATES & CLEANUP', __FUNCTION__, __LINE__);
|
987 |
// make sure dbConnection is inizialized
|
988 |
$this->dbConnection();
|
989 |
+
$this->deactivateIncompatiblePlugins();
|
990 |
$blog_name = mysqli_real_escape_string($this->dbh, $this->post['blogname']);
|
991 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
992 |
/** FINAL UPDATES: Must happen after the global replace to prevent double pathing
|
993 |
http://xyz.com/abc01 will become http://xyz.com/abc0101 with trailing data */
|
994 |
mysqli_query($this->dbh,
|
995 |
"UPDATE `".mysqli_real_escape_string($this->dbh, $GLOBALS['DUPX_AC']->wp_tableprefix)."options` SET option_value = '".mysqli_real_escape_string($this->dbh, $blog_name)."' WHERE option_name = 'blogname' ");
|
|
|
|
|
996 |
mysqli_query($this->dbh,
|
997 |
"UPDATE `".mysqli_real_escape_string($this->dbh, $GLOBALS['DUPX_AC']->wp_tableprefix)."options` SET option_value = '".mysqli_real_escape_string($this->dbh, $this->post['url_new'])."' WHERE option_name = 'home' ");
|
998 |
mysqli_query($this->dbh,
|
1010 |
}
|
1011 |
}
|
1012 |
|
1013 |
+
/**
|
1014 |
+
* Deactivate incompatible plugins
|
1015 |
+
*
|
1016 |
+
* @return void
|
1017 |
+
*/
|
1018 |
+
private function deactivateIncompatiblePlugins() {
|
1019 |
+
self::logSectionHeader("DEACTIVATE PLUGINS CHECK", __FUNCTION__, __LINE__);
|
1020 |
+
// make sure post data is inizialized
|
1021 |
+
$this->getPost();
|
1022 |
+
$nManager = DUPX_NOTICE_MANAGER::getInstance();
|
1023 |
+
$plugin_list = array();
|
1024 |
+
$auto_deactivate_plugins = $this->getAutoDeactivatePlugins();
|
1025 |
+
$deactivated_plugins = array();
|
1026 |
+
$reactivate_plugins_after_installation = array();
|
1027 |
+
foreach ($this->post['plugins'] as $plugin_slug) {
|
1028 |
+
if (isset($auto_deactivate_plugins[$plugin_slug])) {
|
1029 |
+
DUPX_Log::info("deactivate ".$plugin_slug);
|
1030 |
+
$deactivated_plugins[] = $plugin_slug;
|
1031 |
+
$nManager->addFinalReportNotice(array(
|
1032 |
+
'shortMsg' => $auto_deactivate_plugins[$plugin_slug]['shortMsg'],
|
1033 |
+
'level' => DUPX_NOTICE_ITEM::SOFT_WARNING,
|
1034 |
+
'longMsg' => $auto_deactivate_plugins[$plugin_slug]['longMsg'],
|
1035 |
+
'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_HTML,
|
1036 |
+
'sections' => 'general'
|
1037 |
+
));
|
1038 |
+
if ($auto_deactivate_plugins[$plugin_slug]['reactivate']) {
|
1039 |
+
$reactivate_plugins_after_installation[$plugin_slug] = $auto_deactivate_plugins[$plugin_slug]['title'];
|
1040 |
+
}
|
1041 |
+
} else {
|
1042 |
+
$plugin_list[] = $plugin_slug;
|
1043 |
+
}
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
if (!empty($deactivated_plugins)) {
|
1047 |
+
DUPX_Log::info('Plugin(s) listed here are deactivated: '. implode(', ', $deactivated_plugins));
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
if (!empty($reactivate_plugins_after_installation)) {
|
1051 |
+
DUPX_Log::info('Plugin(s) reactivated after installation: '. implode(', ', $deactivated_plugins));
|
1052 |
+
$reactivate_plugins_after_installation_str = serialize($reactivate_plugins_after_installation);
|
1053 |
+
mysqli_query($this->dbh, "INSERT INTO `".mysqli_real_escape_string($this->dbh, $GLOBALS['DUPX_AC']->wp_tableprefix)."options` (option_value, option_name) VALUES('".mysqli_real_escape_string($this->dbh,
|
1054 |
+
$reactivate_plugins_after_installation_str)."','duplicator_reactivate_plugins_after_installation')");
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
// Start
|
1058 |
+
// Force Duplicator active so we the security cleanup will be available
|
1059 |
+
if (!in_array('duplicator/duplicator.php', $plugin_list)) {
|
1060 |
+
$plugin_list[] = 'duplicator/duplicator.php';
|
1061 |
+
}
|
1062 |
+
$serial_plugin_list = @serialize($plugin_list);
|
1063 |
+
// End
|
1064 |
+
|
1065 |
+
mysqli_query($this->dbh,
|
1066 |
+
"UPDATE `".mysqli_real_escape_string($this->dbh, $GLOBALS['DUPX_AC']->wp_tableprefix)."options` SET option_value = '".mysqli_real_escape_string($this->dbh, $serial_plugin_list)."' WHERE option_name = 'active_plugins' ");
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
/**
|
1070 |
+
* Get Automatic deactivation plugins lists
|
1071 |
+
*
|
1072 |
+
* @return array key as plugin slug and val as plugin title
|
1073 |
+
*/
|
1074 |
+
private function getAutoDeactivatePlugins() {
|
1075 |
+
$excludePlugins = array();
|
1076 |
+
|
1077 |
+
if (!DUPX_U::is_ssl()) {
|
1078 |
+
DUPX_Log::info('Really Simple SSL [as Non-SSL installation] will be Deactivated, If It is activated', DUPX_Log::LV_HARD_DEBUG);
|
1079 |
+
$excludePlugins['really-simple-ssl/rlrsssl-really-simple-ssl.php'] = array(
|
1080 |
+
'title' => "Really Simple SSL",
|
1081 |
+
'shortMsg' => "Deactivated Plugin: Really Simple SSL",
|
1082 |
+
'longMsg' => "It is deactivated because You are migrating from SSL (HTTPS) to Non-SSL (HTTP).<br>
|
1083 |
+
If It was not deactivated, You will not able to login.",
|
1084 |
+
'reactivate' => false
|
1085 |
+
|
1086 |
+
);
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
if ($GLOBALS['DUPX_AC']->url_old != $this->post['siteurl']) {
|
1090 |
+
DUPX_Log::info('Simple Google reCAPTCHA [as Package creation site URL and Installation site URL are different] will be Deactivated, If It is activated', DUPX_Log::LV_HARD_DEBUG);
|
1091 |
+
$excludePlugins['simple-google-recaptcha/simple-google-recaptcha.php'] = array(
|
1092 |
+
'title' => "Simple Google reCAPTCHA",
|
1093 |
+
'shortMsg' => "Deactivated Plugin: Simple Google reCAPTCHA",
|
1094 |
+
'longMsg' => "It is deactivated because the Google Recaptcha required reCaptcha site key which is bound to the site's address. Your package site's address and installed site's address doesn't match. You can reactivate it from the installed site login panel after completion of the installation.<br>
|
1095 |
+
<strong>Please do not forget to change the reCaptcha site key after activating it.</strong>",
|
1096 |
+
'reactivate' => false
|
1097 |
+
);
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
DUPX_Log::info('WPBakery Page Builder will be Deactivated, If It is activated', DUPX_Log::LV_HARD_DEBUG);
|
1101 |
+
$excludePlugins['js_composer/js_composer.php'] = array(
|
1102 |
+
'title' => 'WPBakery Page Builder',
|
1103 |
+
'shortMsg' => "Deactivated Plugin: WPBakery Page Builder",
|
1104 |
+
'longMsg' => "It is deactivated automatically. <strong>You must reactivate from the WordPress admin panel after completing the installation.</strong> After activating it, Your site's frontend will be look good.",
|
1105 |
+
'reactivate' => true
|
1106 |
+
);
|
1107 |
+
|
1108 |
+
DUPX_Log::info('Activated plugins (If they are activated) listed here will be deactivated: '.DUPX_Log::varToString(array_keys($excludePlugins)));
|
1109 |
+
return $excludePlugins;
|
1110 |
+
}
|
1111 |
+
|
1112 |
public function noticeTest()
|
1113 |
{
|
1114 |
self::logSectionHeader('NOTICES TEST', __FUNCTION__, __LINE__);
|
installer/dup-installer/classes/utilities/class.u.notices.manager.php
CHANGED
@@ -88,7 +88,7 @@ final class DUPX_NOTICE_MANAGER
|
|
88 |
$notices['finalReport'][$uniqueId] = $notice->toArray();
|
89 |
}
|
90 |
|
91 |
-
file_put_contents($this->persistanceFile,
|
92 |
}
|
93 |
|
94 |
/**
|
88 |
$notices['finalReport'][$uniqueId] = $notice->toArray();
|
89 |
}
|
90 |
|
91 |
+
file_put_contents($this->persistanceFile, DupLiteSnapJsonU::wp_json_encode_pprint($notices));
|
92 |
}
|
93 |
|
94 |
/**
|
installer/dup-installer/classes/utilities/class.u.php
CHANGED
@@ -46,8 +46,8 @@ class DUPX_U
|
|
46 |
{
|
47 |
array_push($GLOBALS['REPLACE_LIST'], array('search' => $search, 'replace' => $replace));
|
48 |
|
49 |
-
$search_json = str_replace('"', "",
|
50 |
-
$replace_json = str_replace('"', "",
|
51 |
|
52 |
if ($search != $search_json) {
|
53 |
array_push($GLOBALS['REPLACE_LIST'], array('search' => $search_json, 'replace' => $replace_json));
|
@@ -652,6 +652,23 @@ class DUPX_U
|
|
652 |
return (version_compare(PHP_VERSION, $version) >= 0);
|
653 |
}
|
654 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
655 |
|
656 |
/**
|
657 |
* @param $url string The URL whichs domain you want to get
|
@@ -687,7 +704,7 @@ class DUPX_U
|
|
687 |
* @return string
|
688 |
*/
|
689 |
public static function esc_html( $text ) {
|
690 |
-
$safe_text =
|
691 |
$safe_text = self::_wp_specialchars( $safe_text, ENT_QUOTES );
|
692 |
/**
|
693 |
* Filters a string cleaned and escaped for output in HTML.
|
@@ -713,7 +730,7 @@ class DUPX_U
|
|
713 |
* @return string Escaped text.
|
714 |
*/
|
715 |
public static function esc_js( $text ) {
|
716 |
-
$safe_text =
|
717 |
$safe_text = self::_wp_specialchars( $safe_text, ENT_COMPAT );
|
718 |
$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
|
719 |
$safe_text = str_replace( "\r", '', $safe_text );
|
@@ -737,7 +754,7 @@ class DUPX_U
|
|
737 |
* @return string
|
738 |
*/
|
739 |
public static function esc_attr( $text ) {
|
740 |
-
$safe_text =
|
741 |
$safe_text = self::_wp_specialchars( $safe_text, ENT_QUOTES );
|
742 |
/**
|
743 |
* Filters a string cleaned and escaped for output in an HTML attribute.
|
@@ -951,27 +968,28 @@ class DUPX_U
|
|
951 |
}
|
952 |
|
953 |
/**
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
|
|
965 |
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
|
971 |
-
|
972 |
-
|
973 |
|
974 |
-
|
975 |
* Callback for wp_kses_normalize_entities() regular expression.
|
976 |
*
|
977 |
* This function only accepts valid named entity references, which are finite,
|
@@ -1309,23 +1327,24 @@ class DUPX_U
|
|
1309 |
}
|
1310 |
|
1311 |
/**
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
|
|
1324 |
|
1325 |
-
|
1326 |
-
|
1327 |
|
1328 |
-
|
1329 |
* Regex callback for wp_kses_decode_entities()
|
1330 |
*
|
1331 |
* @param array $match preg match
|
@@ -1491,7 +1510,7 @@ class DUPX_U
|
|
1491 |
* @return string Sanitized string.
|
1492 |
*/
|
1493 |
public static function _sanitize_text_fields( $str, $keep_newlines = false ) {
|
1494 |
-
$filtered =
|
1495 |
|
1496 |
if ( strpos($filtered, '<') !== false ) {
|
1497 |
$filtered = self::wp_pre_kses_less_than( $filtered );
|
@@ -1718,7 +1737,7 @@ class DUPX_U
|
|
1718 |
*/
|
1719 |
public static function getEscapedGenericString($str, $addQuote = true)
|
1720 |
{
|
1721 |
-
$result =
|
1722 |
$result = str_replace(array('\/', '$'), array('/', '\\$'), $result);
|
1723 |
$result = preg_replace_callback(
|
1724 |
'/\\\\u[a-fA-F0-9]{4}/m', array(__CLASS__, 'encodeUtf8CharFromRegexMatch'), $result
|
46 |
{
|
47 |
array_push($GLOBALS['REPLACE_LIST'], array('search' => $search, 'replace' => $replace));
|
48 |
|
49 |
+
$search_json = str_replace('"', "", DupLiteSnapJsonU::wp_json_encode($search));
|
50 |
+
$replace_json = str_replace('"', "", DupLiteSnapJsonU::wp_json_encode($replace));
|
51 |
|
52 |
if ($search != $search_json) {
|
53 |
array_push($GLOBALS['REPLACE_LIST'], array('search' => $search_json, 'replace' => $replace_json));
|
652 |
return (version_compare(PHP_VERSION, $version) >= 0);
|
653 |
}
|
654 |
|
655 |
+
/**
|
656 |
+
* Checks if ssl is enabled
|
657 |
+
* @return bool
|
658 |
+
*/
|
659 |
+
public static function is_ssl()
|
660 |
+
{
|
661 |
+
if ( isset($_SERVER['HTTPS']) ) {
|
662 |
+
if ( 'on' == strtolower($_SERVER['HTTPS']) )
|
663 |
+
return true;
|
664 |
+
if ( '1' == $_SERVER['HTTPS'] )
|
665 |
+
return true;
|
666 |
+
} elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
|
667 |
+
return true;
|
668 |
+
}
|
669 |
+
|
670 |
+
return false;
|
671 |
+
}
|
672 |
|
673 |
/**
|
674 |
* @param $url string The URL whichs domain you want to get
|
704 |
* @return string
|
705 |
*/
|
706 |
public static function esc_html( $text ) {
|
707 |
+
$safe_text = DupLiteSnapJsonU::wp_check_invalid_utf8( $text );
|
708 |
$safe_text = self::_wp_specialchars( $safe_text, ENT_QUOTES );
|
709 |
/**
|
710 |
* Filters a string cleaned and escaped for output in HTML.
|
730 |
* @return string Escaped text.
|
731 |
*/
|
732 |
public static function esc_js( $text ) {
|
733 |
+
$safe_text = DupLiteSnapJsonU::wp_check_invalid_utf8( $text );
|
734 |
$safe_text = self::_wp_specialchars( $safe_text, ENT_COMPAT );
|
735 |
$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
|
736 |
$safe_text = str_replace( "\r", '', $safe_text );
|
754 |
* @return string
|
755 |
*/
|
756 |
public static function esc_attr( $text ) {
|
757 |
+
$safe_text = DupLiteSnapJsonU::wp_check_invalid_utf8( $text );
|
758 |
$safe_text = self::_wp_specialchars( $safe_text, ENT_QUOTES );
|
759 |
/**
|
760 |
* Filters a string cleaned and escaped for output in an HTML attribute.
|
968 |
}
|
969 |
|
970 |
/**
|
971 |
+
* Converts and fixes HTML entities.
|
972 |
+
*
|
973 |
+
* This function normalizes HTML entities. It will convert `AT&T` to the correct
|
974 |
+
* `AT&T`, `:` to `:`, `&#XYZZY;` to `&#XYZZY;` and so on.
|
975 |
+
*
|
976 |
+
* @param string $string Content to normalize entities
|
977 |
+
* @return string Content with normalized entities
|
978 |
+
*/
|
979 |
+
public static function wp_kses_normalize_entities($string)
|
980 |
+
{
|
981 |
+
// Disarm all entities by converting & to &
|
982 |
+
$string = str_replace('&', '&', $string);
|
983 |
|
984 |
+
// Change back the allowed entities in our entity whitelist
|
985 |
+
$string = preg_replace_callback('/&([A-Za-z]{2,8}[0-9]{0,2});/', array(__CLASS__, 'wp_kses_named_entities'), $string);
|
986 |
+
$string = preg_replace_callback('/&#(0*[0-9]{1,7});/', array(__CLASS__, 'wp_kses_normalize_entities2'), $string);
|
987 |
+
$string = preg_replace_callback('/&#[Xx](0*[0-9A-Fa-f]{1,6});/', array(__CLASS__, 'wp_kses_normalize_entities3'), $string);
|
988 |
|
989 |
+
return $string;
|
990 |
+
}
|
991 |
|
992 |
+
/**
|
993 |
* Callback for wp_kses_normalize_entities() regular expression.
|
994 |
*
|
995 |
* This function only accepts valid named entity references, which are finite,
|
1327 |
}
|
1328 |
|
1329 |
/**
|
1330 |
+
* Convert all entities to their character counterparts.
|
1331 |
+
*
|
1332 |
+
* This function decodes numeric HTML entities (`A` and `A`).
|
1333 |
+
* It doesn't do anything with other entities like ä, but we don't
|
1334 |
+
* need them in the URL protocol whitelisting system anyway.
|
1335 |
+
*
|
1336 |
+
* @param string $string Content to change entities
|
1337 |
+
* @return string Content after decoded entities
|
1338 |
+
*/
|
1339 |
+
public static function wp_kses_decode_entities($string)
|
1340 |
+
{
|
1341 |
+
$string = preg_replace_callback('/&#([0-9]+);/', array(__CLASS__, '_wp_kses_decode_entities_chr'), $string);
|
1342 |
+
$string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', array(__CLASS__, '_wp_kses_decode_entities_chr_hexdec'), $string);
|
1343 |
|
1344 |
+
return $string;
|
1345 |
+
}
|
1346 |
|
1347 |
+
/**
|
1348 |
* Regex callback for wp_kses_decode_entities()
|
1349 |
*
|
1350 |
* @param array $match preg match
|
1510 |
* @return string Sanitized string.
|
1511 |
*/
|
1512 |
public static function _sanitize_text_fields( $str, $keep_newlines = false ) {
|
1513 |
+
$filtered = DupLiteSnapJsonU::wp_check_invalid_utf8( $str );
|
1514 |
|
1515 |
if ( strpos($filtered, '<') !== false ) {
|
1516 |
$filtered = self::wp_pre_kses_less_than( $filtered );
|
1737 |
*/
|
1738 |
public static function getEscapedGenericString($str, $addQuote = true)
|
1739 |
{
|
1740 |
+
$result = DupLiteSnapJsonU::wp_json_encode(trim($str));
|
1741 |
$result = str_replace(array('\/', '$'), array('/', '\\$'), $result);
|
1742 |
$result = preg_replace_callback(
|
1743 |
'/\\\\u[a-fA-F0-9]{4}/m', array(__CLASS__, 'encodeUtf8CharFromRegexMatch'), $result
|
installer/dup-installer/ctrls/ctrl.s1.php
CHANGED
@@ -418,4 +418,4 @@ DUPX_Log::info("\nSTEP-1 COMPLETE @ " . @date('h:i:s') . " - RUNTIME: {$ajax1_su
|
|
418 |
$JSON['pass'] = 1;
|
419 |
error_reporting($ajax1_error_level);
|
420 |
fclose($GLOBALS["LOG_FILE_HANDLE"]);
|
421 |
-
die(
|
418 |
$JSON['pass'] = 1;
|
419 |
error_reporting($ajax1_error_level);
|
420 |
fclose($GLOBALS["LOG_FILE_HANDLE"]);
|
421 |
+
die(DupLiteSnapJsonU::wp_json_encode($JSON));
|
installer/dup-installer/ctrls/ctrl.s2.base.php
CHANGED
@@ -192,4 +192,4 @@ DUPX_Log::info("\nINSERT DATA RUNTIME: " . DUPX_U::elapsedTime($dbinstall->profi
|
|
192 |
DUPX_Log::info('STEP-2 COMPLETE @ '.@date('h:i:s')." - RUNTIME: {$ajax1_sum}");
|
193 |
|
194 |
error_reporting($ajax2_error_level);
|
195 |
-
die(
|
192 |
DUPX_Log::info('STEP-2 COMPLETE @ '.@date('h:i:s')." - RUNTIME: {$ajax1_sum}");
|
193 |
|
194 |
error_reporting($ajax2_error_level);
|
195 |
+
die(DupLiteSnapJsonU::wp_json_encode($JSON));
|
installer/dup-installer/ctrls/ctrl.s2.dbinstall.php
CHANGED
@@ -191,8 +191,8 @@ class DUPX_DBInstall
|
|
191 |
$errMsg = 'DATABASE: table '.DUPX_Log::varToString($table).' row count mismatch; expected '.DUPX_Log::varToString($rowCount).' in database'.DUPX_Log::varToString($row['cnt']);
|
192 |
DUPX_Log::info($errMsg);
|
193 |
$nManager->addBothNextAndFinalReportNotice(array(
|
194 |
-
'shortMsg' => 'Database Table row count validation
|
195 |
-
'level' => DUPX_NOTICE_ITEM::
|
196 |
'longMsg' => $errMsg."\n",
|
197 |
'sections' => 'database'
|
198 |
), DUPX_NOTICE_MANAGER::ADD_UNIQUE_APPEND, 'row-count-mismatch');
|
191 |
$errMsg = 'DATABASE: table '.DUPX_Log::varToString($table).' row count mismatch; expected '.DUPX_Log::varToString($rowCount).' in database'.DUPX_Log::varToString($row['cnt']);
|
192 |
DUPX_Log::info($errMsg);
|
193 |
$nManager->addBothNextAndFinalReportNotice(array(
|
194 |
+
'shortMsg' => 'Database Table row count validation was failed',
|
195 |
+
'level' => DUPX_NOTICE_ITEM::SOFT_WARNING,
|
196 |
'longMsg' => $errMsg."\n",
|
197 |
'sections' => 'database'
|
198 |
), DUPX_NOTICE_MANAGER::ADD_UNIQUE_APPEND, 'row-count-mismatch');
|
installer/dup-installer/ctrls/ctrl.s2.dbtest.php
CHANGED
@@ -100,7 +100,7 @@ class DUPX_DBTest
|
|
100 |
$result = $this->out;
|
101 |
return $result;
|
102 |
} elseif ($this->responseMode == 'JSON') {
|
103 |
-
$result =
|
104 |
return $result;
|
105 |
} else {
|
106 |
die('Please specific the responseMode property');
|
100 |
$result = $this->out;
|
101 |
return $result;
|
102 |
} elseif ($this->responseMode == 'JSON') {
|
103 |
+
$result = DupLiteSnapJsonU::wp_json_encode($this->out);
|
104 |
return $result;
|
105 |
} else {
|
106 |
die('Please specific the responseMode property');
|
installer/dup-installer/ctrls/ctrl.s3.php
CHANGED
@@ -47,4 +47,4 @@ try {
|
|
47 |
|
48 |
$json = $s3Func->getJsonReport();
|
49 |
DUPX_Log::close();
|
50 |
-
die(
|
47 |
|
48 |
$json = $s3Func->getJsonReport();
|
49 |
DUPX_Log::close();
|
50 |
+
die(DupLiteSnapJsonU::wp_json_encode($json));
|
installer/dup-installer/main.installer.php
CHANGED
@@ -97,7 +97,7 @@ try {
|
|
97 |
'isWPAlreadyExistsError' => 1,
|
98 |
'error' => "<b style='color:#B80000;'>INSTALL ERROR!</b><br/>". ERR_CONFIG_FOUND,
|
99 |
);
|
100 |
-
echo
|
101 |
} else {
|
102 |
require_once($GLOBALS['DUPX_INIT'].'/lib/dup_archive/daws/daws.php');
|
103 |
}
|
97 |
'isWPAlreadyExistsError' => 1,
|
98 |
'error' => "<b style='color:#B80000;'>INSTALL ERROR!</b><br/>". ERR_CONFIG_FOUND,
|
99 |
);
|
100 |
+
echo DupLiteSnapJsonU::wp_json_encode($resp);
|
101 |
} else {
|
102 |
require_once($GLOBALS['DUPX_INIT'].'/lib/dup_archive/daws/daws.php');
|
103 |
}
|
installer/dup-installer/views/view.s2.dbtest.php
CHANGED
@@ -394,7 +394,7 @@ DUPX.testDBConnect = function ()
|
|
394 |
$dbButton = $('#s2-dbtest-btn-basic');
|
395 |
|
396 |
$dbArea.show(250);
|
397 |
-
$dbResult.html("<div class='message'><i class='fas fa-question-circle fa-sm'></i
|
398 |
$dbButton.attr('disabled', 'true');
|
399 |
|
400 |
if (document.location.href.indexOf('?') > -1) {
|
394 |
$dbButton = $('#s2-dbtest-btn-basic');
|
395 |
|
396 |
$dbArea.show(250);
|
397 |
+
$dbResult.html("<div class='message'><i class='fas fa-question-circle fa-sm'></i> Running Database Validation. <br/> Please wait...</div>");
|
398 |
$dbButton.attr('disabled', 'true');
|
399 |
|
400 |
if (document.location.href.indexOf('?') > -1) {
|
installer/dup-installer/views/view.s3.php
CHANGED
@@ -259,18 +259,10 @@ VIEW: STEP 3- INPUT -->
|
|
259 |
</div><br style="clear:both" />
|
260 |
<select id="plugins" name="plugins[]" multiple="multiple" style="width:315px;" <?php echo ($_POST['exe_safe_mode'] > 0) ? 'disabled="true"' : ''; ?> size="10">
|
261 |
<?php
|
262 |
-
$
|
263 |
-
'really-simple-ssl/rlrsssl-really-simple-ssl.php',
|
264 |
-
'simple-google-recaptcha/simple-google-recaptcha.php',
|
265 |
-
);
|
266 |
-
$selected_string = ($_POST['exe_safe_mode'] > 0) ? '' : 'selected="selected"';
|
267 |
foreach ($active_plugins as $plugin) {
|
268 |
$label = dirname($plugin) == '.' ? $plugin : dirname($plugin);
|
269 |
-
|
270 |
-
echo "<option value='" . DUPX_U::esc_attr($plugin) . "'>" . DUPX_U::esc_html($label) . '</option>';
|
271 |
-
} else {
|
272 |
-
echo "<option {$selected_string} value='" . DUPX_U::esc_attr( $plugin ) . "'>" . DUPX_U::esc_html($label) . '</option>';
|
273 |
-
}
|
274 |
}
|
275 |
?>
|
276 |
</select>
|
@@ -602,8 +594,10 @@ DUPX.hideErrorResult2 = function()
|
|
602 |
//DOCUMENT LOAD
|
603 |
$(document).ready(function()
|
604 |
{
|
605 |
-
|
606 |
-
|
|
|
|
|
607 |
$("#tabs").tabs();
|
608 |
DUPX.getNewURL('url_new');
|
609 |
DUPX.getNewURL('siteurl');
|
259 |
</div><br style="clear:both" />
|
260 |
<select id="plugins" name="plugins[]" multiple="multiple" style="width:315px;" <?php echo ($_POST['exe_safe_mode'] > 0) ? 'disabled="true"' : ''; ?> size="10">
|
261 |
<?php
|
262 |
+
$selected_string = 'selected="selected"';
|
|
|
|
|
|
|
|
|
263 |
foreach ($active_plugins as $plugin) {
|
264 |
$label = dirname($plugin) == '.' ? $plugin : dirname($plugin);
|
265 |
+
echo "<option {$selected_string} value='" . DUPX_U::esc_attr( $plugin ) . "'>" . DUPX_U::esc_html($label) . '</option>';
|
|
|
|
|
|
|
|
|
266 |
}
|
267 |
?>
|
268 |
</select>
|
594 |
//DOCUMENT LOAD
|
595 |
$(document).ready(function()
|
596 |
{
|
597 |
+
setTimeout(function() {
|
598 |
+
$('#wp_username').val('');
|
599 |
+
$('#wp_password').val('');
|
600 |
+
}, 100);
|
601 |
$("#tabs").tabs();
|
602 |
DUPX.getNewURL('url_new');
|
603 |
DUPX.getNewURL('siteurl');
|
installer/installer.tpl
CHANGED
@@ -1401,12 +1401,26 @@ class DUPX_Handler
|
|
1401 |
|
1402 |
class DUPX_CSRF {
|
1403 |
|
1404 |
-
/**
|
|
|
1405 |
* @var string
|
1406 |
*/
|
1407 |
public static $prefix = '_DUPX_CSRF';
|
|
|
|
|
|
|
|
|
|
|
1408 |
private static $CSRFVars;
|
1409 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1410 |
public static function setKeyVal($key, $val) {
|
1411 |
$CSRFVars = self::getCSRFVars();
|
1412 |
$CSRFVars[$key] = $val;
|
@@ -1414,6 +1428,13 @@ class DUPX_CSRF {
|
|
1414 |
self::$CSRFVars = false;
|
1415 |
}
|
1416 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1417 |
public static function getVal($key) {
|
1418 |
$CSRFVars = self::getCSRFVars();
|
1419 |
if (isset($CSRFVars[$key])) {
|
@@ -1421,10 +1442,10 @@ class DUPX_CSRF {
|
|
1421 |
} else {
|
1422 |
return false;
|
1423 |
}
|
1424 |
-
|
1425 |
}
|
1426 |
|
1427 |
/** Generate DUPX_CSRF value for form
|
|
|
1428 |
* @param string $form - Form name as session key
|
1429 |
* @return string - token
|
1430 |
*/
|
@@ -1435,14 +1456,16 @@ class DUPX_CSRF {
|
|
1435 |
if (false !== $existingToken) {
|
1436 |
$token = $existingToken;
|
1437 |
} else {
|
1438 |
-
$token =
|
1439 |
}
|
1440 |
|
1441 |
self::setKeyVal($keyName, $token);
|
1442 |
return $token;
|
1443 |
}
|
1444 |
|
1445 |
-
/**
|
|
|
|
|
1446 |
* @param string $token - Token
|
1447 |
* @param string $form - Form name as session key
|
1448 |
* @return boolean
|
@@ -1474,10 +1497,21 @@ class DUPX_CSRF {
|
|
1474 |
return strtoupper(md5(implode('|', array($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']))));
|
1475 |
}
|
1476 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1477 |
private static function getKeyName($form) {
|
1478 |
-
return
|
1479 |
}
|
1480 |
|
|
|
|
|
|
|
|
|
|
|
1481 |
private static function getPackageHash() {
|
1482 |
if (class_exists('DUPX_Bootstrap')) {
|
1483 |
return DUPX_Bootstrap::PACKAGE_HASH;
|
@@ -1486,6 +1520,11 @@ class DUPX_CSRF {
|
|
1486 |
}
|
1487 |
}
|
1488 |
|
|
|
|
|
|
|
|
|
|
|
1489 |
private static function getFilePath() {
|
1490 |
if (class_exists('DUPX_Bootstrap')) {
|
1491 |
$dupInstallerfolderPath = dirname(__FILE__).'/dup-installer/';
|
@@ -1498,6 +1537,11 @@ class DUPX_CSRF {
|
|
1498 |
return $filePath;
|
1499 |
}
|
1500 |
|
|
|
|
|
|
|
|
|
|
|
1501 |
private static function getCSRFVars() {
|
1502 |
if (!isset(self::$CSRFVars) || false === self::$CSRFVars) {
|
1503 |
$filePath = self::getFilePath();
|
@@ -1518,6 +1562,12 @@ class DUPX_CSRF {
|
|
1518 |
return self::$CSRFVars;
|
1519 |
}
|
1520 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1521 |
private static function saveCSRFVars($CSRFVars) {
|
1522 |
$contents = json_encode($CSRFVars);
|
1523 |
$filePath = self::getFilePath();
|
1401 |
|
1402 |
class DUPX_CSRF {
|
1403 |
|
1404 |
+
/**
|
1405 |
+
* Session var name prefix
|
1406 |
* @var string
|
1407 |
*/
|
1408 |
public static $prefix = '_DUPX_CSRF';
|
1409 |
+
|
1410 |
+
/**
|
1411 |
+
* Stores all CSRF values: Key as CSRF name and Val as CRF value
|
1412 |
+
* @var array
|
1413 |
+
*/
|
1414 |
private static $CSRFVars;
|
1415 |
|
1416 |
+
/**
|
1417 |
+
* Set new CSRF
|
1418 |
+
*
|
1419 |
+
* @param $key string CSRF Key
|
1420 |
+
* @param $key string CSRF Val
|
1421 |
+
*
|
1422 |
+
* @return Void
|
1423 |
+
*/
|
1424 |
public static function setKeyVal($key, $val) {
|
1425 |
$CSRFVars = self::getCSRFVars();
|
1426 |
$CSRFVars[$key] = $val;
|
1428 |
self::$CSRFVars = false;
|
1429 |
}
|
1430 |
|
1431 |
+
/**
|
1432 |
+
* Get CSRF value by passing CSRF key
|
1433 |
+
*
|
1434 |
+
* @param $key string CSRF key
|
1435 |
+
*
|
1436 |
+
* @return string|boolean If CSRF value set for give n Key, It returns CRF value otherise returns false
|
1437 |
+
*/
|
1438 |
public static function getVal($key) {
|
1439 |
$CSRFVars = self::getCSRFVars();
|
1440 |
if (isset($CSRFVars[$key])) {
|
1442 |
} else {
|
1443 |
return false;
|
1444 |
}
|
|
|
1445 |
}
|
1446 |
|
1447 |
/** Generate DUPX_CSRF value for form
|
1448 |
+
*
|
1449 |
* @param string $form - Form name as session key
|
1450 |
* @return string - token
|
1451 |
*/
|
1456 |
if (false !== $existingToken) {
|
1457 |
$token = $existingToken;
|
1458 |
} else {
|
1459 |
+
$token = DUPX_CSRF::token() . DUPX_CSRF::fingerprint();
|
1460 |
}
|
1461 |
|
1462 |
self::setKeyVal($keyName, $token);
|
1463 |
return $token;
|
1464 |
}
|
1465 |
|
1466 |
+
/**
|
1467 |
+
* Check DUPX_CSRF value of form
|
1468 |
+
*
|
1469 |
* @param string $token - Token
|
1470 |
* @param string $form - Form name as session key
|
1471 |
* @return boolean
|
1497 |
return strtoupper(md5(implode('|', array($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']))));
|
1498 |
}
|
1499 |
|
1500 |
+
/**
|
1501 |
+
* Generate CSRF Key name
|
1502 |
+
*
|
1503 |
+
* @param string the form name for which CSRF key need to generate
|
1504 |
+
* @return string CSRF key
|
1505 |
+
*/
|
1506 |
private static function getKeyName($form) {
|
1507 |
+
return DUPX_CSRF::$prefix . '_' . $form;
|
1508 |
}
|
1509 |
|
1510 |
+
/**
|
1511 |
+
* Get Package hash
|
1512 |
+
*
|
1513 |
+
* @return string Package hash
|
1514 |
+
*/
|
1515 |
private static function getPackageHash() {
|
1516 |
if (class_exists('DUPX_Bootstrap')) {
|
1517 |
return DUPX_Bootstrap::PACKAGE_HASH;
|
1520 |
}
|
1521 |
}
|
1522 |
|
1523 |
+
/**
|
1524 |
+
* Get file path where CSRF tokens are stored in JSON encoded format
|
1525 |
+
*
|
1526 |
+
* @return string file path where CSRF token stored
|
1527 |
+
*/
|
1528 |
private static function getFilePath() {
|
1529 |
if (class_exists('DUPX_Bootstrap')) {
|
1530 |
$dupInstallerfolderPath = dirname(__FILE__).'/dup-installer/';
|
1537 |
return $filePath;
|
1538 |
}
|
1539 |
|
1540 |
+
/**
|
1541 |
+
* Get all CSRF vars in array format
|
1542 |
+
*
|
1543 |
+
* @return array Key as CSRF name and value as CSRF value
|
1544 |
+
*/
|
1545 |
private static function getCSRFVars() {
|
1546 |
if (!isset(self::$CSRFVars) || false === self::$CSRFVars) {
|
1547 |
$filePath = self::getFilePath();
|
1562 |
return self::$CSRFVars;
|
1563 |
}
|
1564 |
|
1565 |
+
/**
|
1566 |
+
* Stores all CSRF vars
|
1567 |
+
*
|
1568 |
+
* @param $CSRFVars array holds all CSRF key val
|
1569 |
+
* @return void
|
1570 |
+
*/
|
1571 |
private static function saveCSRFVars($CSRFVars) {
|
1572 |
$contents = json_encode($CSRFVars);
|
1573 |
$filePath = self::getFilePath();
|
lib/config/class.wp.config.tranformer.php
CHANGED
@@ -126,18 +126,18 @@ class WPConfigTransformer {
|
|
126 |
|
127 |
public static function getRealValFromVal($val)
|
128 |
{
|
129 |
-
if ($val[0]
|
130 |
// string with '
|
131 |
$result = substr($val, 1, strlen($val) - 2);
|
132 |
-
return str_replace(array('\\\''
|
133 |
-
} else if ($val[0]
|
134 |
// string with "
|
135 |
return json_decode(str_replace('\\$', '$', $val));
|
136 |
-
} else if (strcasecmp($val, 'true')) {
|
137 |
return true;
|
138 |
-
} else if (strcasecmp($val, 'false')) {
|
139 |
return false;
|
140 |
-
} else if (strcasecmp($val, 'null')) {
|
141 |
return null;
|
142 |
} else if (preg_match('/^[-+]?[0-9]+$/', $val)) {
|
143 |
return (int) $val;
|
126 |
|
127 |
public static function getRealValFromVal($val)
|
128 |
{
|
129 |
+
if ($val[0] === '\'') {
|
130 |
// string with '
|
131 |
$result = substr($val, 1, strlen($val) - 2);
|
132 |
+
return str_replace(array('\\\'', '\\\\'), array('\'', '\\'), $result);
|
133 |
+
} else if ($val[0] === '"') {
|
134 |
// string with "
|
135 |
return json_decode(str_replace('\\$', '$', $val));
|
136 |
+
} else if (strcasecmp($val, 'true') === 0) {
|
137 |
return true;
|
138 |
+
} else if (strcasecmp($val, 'false') === 0) {
|
139 |
return false;
|
140 |
+
} else if (strcasecmp($val, 'null') === 0) {
|
141 |
return null;
|
142 |
} else if (preg_match('/^[-+]?[0-9]+$/', $val)) {
|
143 |
return (int) $val;
|
lib/dup_archive/classes/util/class.duparchive.u.json.php
CHANGED
@@ -14,7 +14,7 @@ class DupArchiveJsonU
|
|
14 |
|
15 |
public static function customEncode($value, $iteration = 1)
|
16 |
{
|
17 |
-
$encoded =
|
18 |
|
19 |
switch (json_last_error()) {
|
20 |
case JSON_ERROR_NONE:
|
@@ -41,7 +41,7 @@ class DupArchiveJsonU
|
|
41 |
|
42 |
public static function encode($value, $options = 0)
|
43 |
{
|
44 |
-
$result =
|
45 |
|
46 |
if ($result !== FALSE) {
|
47 |
|
14 |
|
15 |
public static function customEncode($value, $iteration = 1)
|
16 |
{
|
17 |
+
$encoded = DupLiteSnapJsonU::wp_json_encode($value);
|
18 |
|
19 |
switch (json_last_error()) {
|
20 |
case JSON_ERROR_NONE:
|
41 |
|
42 |
public static function encode($value, $options = 0)
|
43 |
{
|
44 |
+
$result = DupLiteSnapJsonU::wp_json_encode($value, $options);
|
45 |
|
46 |
if ($result !== FALSE) {
|
47 |
|
lib/dup_archive/daws/class.daws.state.expand.php
CHANGED
@@ -94,7 +94,7 @@ class DAWSExpandState extends DupArchiveExpandState
|
|
94 |
|
95 |
$this->initMembers();
|
96 |
|
97 |
-
DupLiteSnapLibIOU::fwrite($stateHandle,
|
98 |
|
99 |
DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
|
100 |
|
@@ -110,7 +110,7 @@ class DAWSExpandState extends DupArchiveExpandState
|
|
110 |
DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
|
111 |
|
112 |
DupArchiveUtil::tlog("saving state");
|
113 |
-
DupLiteSnapLibIOU::fwrite($stateHandle,
|
114 |
|
115 |
DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
|
116 |
|
94 |
|
95 |
$this->initMembers();
|
96 |
|
97 |
+
DupLiteSnapLibIOU::fwrite($stateHandle, DupLiteSnapJsonU::wp_json_encode($this));
|
98 |
|
99 |
DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
|
100 |
|
110 |
DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
|
111 |
|
112 |
DupArchiveUtil::tlog("saving state");
|
113 |
+
DupLiteSnapLibIOU::fwrite($stateHandle, DupLiteSnapJsonU::wp_json_encode($this));
|
114 |
|
115 |
DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
|
116 |
|
lib/dup_archive/daws/daws.php
CHANGED
@@ -249,7 +249,7 @@ class DAWS
|
|
249 |
|
250 |
DupLiteSnapLibLogger::logObject("before json encode retval", $retVal);
|
251 |
|
252 |
-
$jsonRetVal =
|
253 |
DupLiteSnapLibLogger::logObject("json encoded retval", $jsonRetVal);
|
254 |
echo $jsonRetVal;
|
255 |
}
|
249 |
|
250 |
DupLiteSnapLibLogger::logObject("before json encode retval", $retVal);
|
251 |
|
252 |
+
$jsonRetVal = DupLiteSnapJsonU::wp_json_encode($retVal);
|
253 |
DupLiteSnapLibLogger::logObject("json encoded retval", $jsonRetVal);
|
254 |
echo $jsonRetVal;
|
255 |
}
|
lib/fileops/class.fileops.state.php
CHANGED
@@ -28,9 +28,9 @@ class FileOpsState
|
|
28 |
self::$instance = new FileOpsState();
|
29 |
|
30 |
if (file_exists($stateFilepath)) {
|
31 |
-
$stateHandle =
|
32 |
|
33 |
-
|
34 |
|
35 |
$stateString = fread($stateHandle, filesize($stateFilepath));
|
36 |
|
@@ -40,9 +40,9 @@ class FileOpsState
|
|
40 |
|
41 |
// self::$instance->fileRenames = (array)(self::$instance->fileRenames);
|
42 |
|
43 |
-
|
44 |
|
45 |
-
|
46 |
} else {
|
47 |
$reset = true;
|
48 |
}
|
@@ -66,29 +66,29 @@ class FileOpsState
|
|
66 |
{
|
67 |
$stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
|
68 |
|
69 |
-
$stateHandle =
|
70 |
|
71 |
-
|
72 |
|
73 |
$this->initMembers();
|
74 |
|
75 |
-
|
76 |
|
77 |
-
|
78 |
}
|
79 |
|
80 |
public function save()
|
81 |
{
|
82 |
$stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
|
83 |
|
84 |
-
$stateHandle =
|
85 |
|
86 |
-
|
87 |
|
88 |
DupArchiveUtil::tlog("saving state");
|
89 |
-
|
90 |
|
91 |
-
|
92 |
}
|
93 |
|
94 |
private function initMembers()
|
28 |
self::$instance = new FileOpsState();
|
29 |
|
30 |
if (file_exists($stateFilepath)) {
|
31 |
+
$stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'rb');
|
32 |
|
33 |
+
DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
|
34 |
|
35 |
$stateString = fread($stateHandle, filesize($stateFilepath));
|
36 |
|
40 |
|
41 |
// self::$instance->fileRenames = (array)(self::$instance->fileRenames);
|
42 |
|
43 |
+
DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
|
44 |
|
45 |
+
DupLiteSnapLibIOU::fclose($stateHandle);
|
46 |
} else {
|
47 |
$reset = true;
|
48 |
}
|
66 |
{
|
67 |
$stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
|
68 |
|
69 |
+
$stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
|
70 |
|
71 |
+
DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
|
72 |
|
73 |
$this->initMembers();
|
74 |
|
75 |
+
DupLiteSnapLibIOU::fwrite($stateHandle, json_encode($this));
|
76 |
|
77 |
+
DupLiteSnapLibIOU::fclose($stateHandle);
|
78 |
}
|
79 |
|
80 |
public function save()
|
81 |
{
|
82 |
$stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
|
83 |
|
84 |
+
$stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
|
85 |
|
86 |
+
DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
|
87 |
|
88 |
DupArchiveUtil::tlog("saving state");
|
89 |
+
DupLiteSnapLibIOU::fwrite($stateHandle, json_encode($this));
|
90 |
|
91 |
+
DupLiteSnapLibIOU::fclose($stateHandle);
|
92 |
}
|
93 |
|
94 |
private function initMembers()
|
lib/fileops/class.fileops.u.move.php
CHANGED
@@ -14,18 +14,18 @@ class FileOpsMoveU
|
|
14 |
// returns: array with list of failures
|
15 |
public static function move($directories, $files, $excludedFiles, $destination)
|
16 |
{
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
$failures = array();
|
23 |
|
24 |
|
25 |
-
$directoryFailures =
|
26 |
-
|
27 |
-
$fileFailures =
|
28 |
-
|
29 |
return array_merge($directoryFailures, $fileFailures);
|
30 |
}
|
31 |
}
|
14 |
// returns: array with list of failures
|
15 |
public static function move($directories, $files, $excludedFiles, $destination)
|
16 |
{
|
17 |
+
DupLiteSnapLibLogger::logObject('directories', $directories);
|
18 |
+
DupLiteSnapLibLogger::logObject('files', $files);
|
19 |
+
DupLiteSnapLibLogger::logObject('excludedFiles', $excludedFiles);
|
20 |
+
DupLiteSnapLibLogger::logObject('destination', $destination);
|
21 |
|
22 |
$failures = array();
|
23 |
|
24 |
|
25 |
+
$directoryFailures = DupLiteSnapLibIOU::massMove($directories, $destination, null, false);
|
26 |
+
DupLiteSnapLibLogger::log('done directories');
|
27 |
+
$fileFailures = DupLiteSnapLibIOU::massMove($files, $destination, $excludedFiles, false);
|
28 |
+
DupLiteSnapLibLogger::log('done files');
|
29 |
return array_merge($directoryFailures, $fileFailures);
|
30 |
}
|
31 |
}
|
lib/fileops/fileops.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/** Absolute path to the DAWS directory. - necessary for php protection */
|
3 |
if ( !defined('ABSPATH') )
|
4 |
define('ABSPATH', dirname(__FILE__) . '/');
|
5 |
-
if (
|
6 |
@ini_set('display_errors', 1);
|
7 |
error_reporting(E_ALL);
|
8 |
set_error_handler("terminate_missing_variables");
|
@@ -22,15 +22,15 @@ class FileOps
|
|
22 |
{
|
23 |
date_default_timezone_set('UTC'); // Some machines don’t have this set so just do it here.
|
24 |
|
25 |
-
|
26 |
}
|
27 |
|
28 |
public function processRequest()
|
29 |
{
|
30 |
try {
|
31 |
-
|
32 |
/* @var $state FileOpsState */
|
33 |
-
|
34 |
$retVal = new StdClass();
|
35 |
|
36 |
$retVal->pass = false;
|
@@ -39,7 +39,7 @@ class FileOps
|
|
39 |
if (isset($_REQUEST['action'])) {
|
40 |
//$params = $_REQUEST;
|
41 |
$params = array();
|
42 |
-
|
43 |
|
44 |
foreach($_REQUEST as $key => $value)
|
45 |
{
|
@@ -48,45 +48,45 @@ class FileOps
|
|
48 |
|
49 |
} else {
|
50 |
$json = file_get_contents('php://input');
|
51 |
-
|
52 |
$params = json_decode($json, true);
|
53 |
-
|
54 |
}
|
55 |
|
56 |
-
|
57 |
-
|
58 |
|
59 |
$action = $params['action'];
|
60 |
|
61 |
if ($action == 'deltree') {
|
62 |
|
63 |
-
|
64 |
|
65 |
|
66 |
|
67 |
$config = DeleteConfig();
|
68 |
|
69 |
-
$config->workerTime =
|
70 |
-
$config->directories =
|
71 |
-
$config->throttleDelayInUs =
|
72 |
-
$config->excludedDirectories =
|
73 |
-
$config->excludedFiles =
|
74 |
-
$config->fileLock =
|
75 |
|
76 |
-
|
77 |
|
78 |
|
79 |
|
80 |
// TODO use appropriate lock type
|
81 |
-
|
82 |
|
83 |
-
$this->lock_handle =
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
-
|
90 |
|
91 |
$retVal->pass = true;
|
92 |
$retVal->status = new stdClass;
|
@@ -94,15 +94,15 @@ class FileOps
|
|
94 |
|
95 |
} else if($action === 'move_files') {
|
96 |
|
97 |
-
$directories =
|
98 |
-
$files =
|
99 |
-
$excludedFiles =
|
100 |
-
$destination =
|
101 |
|
102 |
-
|
103 |
$moveErrors = FileOpsMoveU::move($directories, $files, $excludedFiles, $destination);
|
104 |
|
105 |
-
|
106 |
|
107 |
$retVal->pass = true;
|
108 |
$retVal->status = new stdClass();
|
@@ -118,16 +118,16 @@ class FileOps
|
|
118 |
} catch (Exception $ex) {
|
119 |
$error_message = "Error Encountered:" . $ex->getMessage() . '<br/>' . $ex->getTraceAsString();
|
120 |
|
121 |
-
|
122 |
|
123 |
$retVal->pass = false;
|
124 |
$retVal->error = $error_message;
|
125 |
}
|
126 |
|
127 |
-
|
128 |
|
129 |
$jsonRetVal = json_encode($retVal);
|
130 |
-
|
131 |
echo $jsonRetVal;
|
132 |
}
|
133 |
}
|
@@ -156,8 +156,8 @@ function terminate_missing_variables($errno, $errstr, $errfile, $errline)
|
|
156 |
// if (($errno == E_NOTICE) and ( strstr($errstr, "Undefined variable"))) die("$errstr in $errfile line $errline");
|
157 |
|
158 |
|
159 |
-
|
160 |
-
|
161 |
// DaTesterLogging::clearLog();
|
162 |
|
163 |
// exit(1);
|
2 |
/** Absolute path to the DAWS directory. - necessary for php protection */
|
3 |
if ( !defined('ABSPATH') )
|
4 |
define('ABSPATH', dirname(__FILE__) . '/');
|
5 |
+
if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('display_errors'))
|
6 |
@ini_set('display_errors', 1);
|
7 |
error_reporting(E_ALL);
|
8 |
set_error_handler("terminate_missing_variables");
|
22 |
{
|
23 |
date_default_timezone_set('UTC'); // Some machines don’t have this set so just do it here.
|
24 |
|
25 |
+
DupLiteSnapLibLogger::init(FileOpsConstants::$LOG_FILEPATH);
|
26 |
}
|
27 |
|
28 |
public function processRequest()
|
29 |
{
|
30 |
try {
|
31 |
+
DupLiteSnapLibLogger::clearLog();
|
32 |
/* @var $state FileOpsState */
|
33 |
+
DupLiteSnapLibLogger::log('process request');
|
34 |
$retVal = new StdClass();
|
35 |
|
36 |
$retVal->pass = false;
|
39 |
if (isset($_REQUEST['action'])) {
|
40 |
//$params = $_REQUEST;
|
41 |
$params = array();
|
42 |
+
DupLiteSnapLibLogger::logObject('REQUEST', $_REQUEST);
|
43 |
|
44 |
foreach($_REQUEST as $key => $value)
|
45 |
{
|
48 |
|
49 |
} else {
|
50 |
$json = file_get_contents('php://input');
|
51 |
+
DupLiteSnapLibLogger::logObject('json1', $json);
|
52 |
$params = json_decode($json, true);
|
53 |
+
DupLiteSnapLibLogger::logObject('json2', $json);
|
54 |
}
|
55 |
|
56 |
+
DupLiteSnapLibLogger::logObject('params', $params);
|
57 |
+
DupLiteSnapLibLogger::logObject('keys', array_keys($params));
|
58 |
|
59 |
$action = $params['action'];
|
60 |
|
61 |
if ($action == 'deltree') {
|
62 |
|
63 |
+
DupLiteSnapLibLogger::log('deltree');
|
64 |
|
65 |
|
66 |
|
67 |
$config = DeleteConfig();
|
68 |
|
69 |
+
$config->workerTime = DupLiteSnapLibUtil::GetArrayValue($params, 'worker_time');
|
70 |
+
$config->directories = DupLiteSnapLibUtil::getArrayValue($params, 'directories');
|
71 |
+
$config->throttleDelayInUs = DupLiteSnapLibUtil::getArrayValue($params, 'throttleDelay', false, 0) * 1000000;
|
72 |
+
$config->excludedDirectories = DupLiteSnapLibUtil::getArrayValue($params, 'excluded_directories', false, array());
|
73 |
+
$config->excludedFiles = DupLiteSnapLibUtil::getArrayValue($params, 'excluded_files', false, array());
|
74 |
+
$config->fileLock = DupLiteSnapLibUtil::GetArrayValue($params, 'fileLock');
|
75 |
|
76 |
+
DupLiteSnapLibLogger::logObject('Config', $config);
|
77 |
|
78 |
|
79 |
|
80 |
// TODO use appropriate lock type
|
81 |
+
DupLiteSnapLibIOU::flock($this->lock_handle, LOCK_EX);
|
82 |
|
83 |
+
$this->lock_handle = DupLiteSnapLibIOU::fopen(FileOpsConstants::$PROCESS_LOCK_FILEPATH, 'c+');
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
+
DupLiteSnapLibIOU::flock($this->lock_handle, LOCK_UN);
|
90 |
|
91 |
$retVal->pass = true;
|
92 |
$retVal->status = new stdClass;
|
94 |
|
95 |
} else if($action === 'move_files') {
|
96 |
|
97 |
+
$directories = DupLiteSnapLibUtil::getArrayValue($params, 'directories', false, array());
|
98 |
+
$files = DupLiteSnapLibUtil::getArrayValue($params, 'files', false, array());
|
99 |
+
$excludedFiles = DupLiteSnapLibUtil::getArrayValue($params, 'excluded_files', false, array());
|
100 |
+
$destination = DupLiteSnapLibUtil::getArrayValue($params, 'destination');
|
101 |
|
102 |
+
DupLiteSnapLibLogger::log('before move');
|
103 |
$moveErrors = FileOpsMoveU::move($directories, $files, $excludedFiles, $destination);
|
104 |
|
105 |
+
DupLiteSnapLibLogger::log('after move');
|
106 |
|
107 |
$retVal->pass = true;
|
108 |
$retVal->status = new stdClass();
|
118 |
} catch (Exception $ex) {
|
119 |
$error_message = "Error Encountered:" . $ex->getMessage() . '<br/>' . $ex->getTraceAsString();
|
120 |
|
121 |
+
DupLiteSnapLibLogger::log($error_message);
|
122 |
|
123 |
$retVal->pass = false;
|
124 |
$retVal->error = $error_message;
|
125 |
}
|
126 |
|
127 |
+
DupLiteSnapLibLogger::logObject("before json encode retval", $retVal);
|
128 |
|
129 |
$jsonRetVal = json_encode($retVal);
|
130 |
+
DupLiteSnapLibLogger::logObject("json encoded retval", $jsonRetVal);
|
131 |
echo $jsonRetVal;
|
132 |
}
|
133 |
}
|
156 |
// if (($errno == E_NOTICE) and ( strstr($errstr, "Undefined variable"))) die("$errstr in $errfile line $errline");
|
157 |
|
158 |
|
159 |
+
DupLiteSnapLibLogger::log("ERROR $errno, $errstr, {$errfile}:{$errline}");
|
160 |
+
DupLiteSnapLibLogger::log(generateCallTrace());
|
161 |
// DaTesterLogging::clearLog();
|
162 |
|
163 |
// exit(1);
|
lib/snaplib/class.snaplib.exceptions.php
CHANGED
@@ -16,6 +16,6 @@ if (!class_exists('DupLiteSnapLib_32BitSizeLimitException', false)) {
|
|
16 |
|
17 |
class DupLiteSnapLib_32BitSizeLimitException extends Exception
|
18 |
{
|
19 |
-
|
20 |
}
|
21 |
}
|
16 |
|
17 |
class DupLiteSnapLib_32BitSizeLimitException extends Exception
|
18 |
{
|
19 |
+
|
20 |
}
|
21 |
}
|
lib/snaplib/class.snaplib.jsonSerializable.abstract.php
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Json class serialize / unserialize json
|
4 |
+
*
|
5 |
+
* Standard: PSR-2
|
6 |
+
* @link http://www.php-fig.org/psr/psr-2
|
7 |
+
*
|
8 |
+
* @package SnapLib
|
9 |
+
* @copyright (c) 2019, Snapcreek LLC
|
10 |
+
* @license https://opensource.org/licenses/GPL-3.0 GNU Public License
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
14 |
+
|
15 |
+
if (!class_exists('DupLiteSnapJsonSerializable', false)) {
|
16 |
+
|
17 |
+
abstract class DupLiteSnapJsonSerializable
|
18 |
+
{
|
19 |
+
|
20 |
+
const CLASS_KEY_FOR_JSON_SERIALIZE = '==_CLASS_==_NAME_==';
|
21 |
+
|
22 |
+
protected static function objectToPublicArrayClass($obj = null)
|
23 |
+
{
|
24 |
+
$reflect = new ReflectionObject($obj);
|
25 |
+
$result = array(
|
26 |
+
self::CLASS_KEY_FOR_JSON_SERIALIZE => $reflect->name
|
27 |
+
);
|
28 |
+
|
29 |
+
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
|
30 |
+
/**
|
31 |
+
* get all props of current class but not props private of parent class
|
32 |
+
*/
|
33 |
+
$props = $reflect->getProperties();
|
34 |
+
|
35 |
+
foreach ($props as $prop) {
|
36 |
+
$prop->setAccessible(true);
|
37 |
+
$propName = $prop->getName();
|
38 |
+
$propValue = $prop->getValue($obj);
|
39 |
+
|
40 |
+
$result[$propName] = self::parseValueToArray($propValue);
|
41 |
+
}
|
42 |
+
} else {
|
43 |
+
$objArray = (array) $obj;
|
44 |
+
$re = '/(?:.*\x00)?(.+)/';
|
45 |
+
$subst = '$1';
|
46 |
+
|
47 |
+
foreach ($objArray as $origPropName => $propValue) {
|
48 |
+
$propName = preg_replace($re, $subst, $origPropName, 1);
|
49 |
+
$result[$propName] = self::parseValueToArray($propValue);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return $result;
|
53 |
+
}
|
54 |
+
|
55 |
+
protected static function parseValueToArray($value)
|
56 |
+
{
|
57 |
+
if (is_object($value)) {
|
58 |
+
return self::objectToPublicArrayClass($value);
|
59 |
+
} else if (is_array($value)) {
|
60 |
+
$result = array();
|
61 |
+
foreach ($value as $key => $arrayVal) {
|
62 |
+
$result[$key] = self::parseValueToArray($arrayVal);
|
63 |
+
}
|
64 |
+
return $result;
|
65 |
+
} else {
|
66 |
+
return $value;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
protected static function parseArrayToValue($value, $classFromProp = null)
|
71 |
+
{
|
72 |
+
if (($newClassName = self::getClassFromArray($value, $classFromProp)) !== false) {
|
73 |
+
if (class_exists($newClassName)) {
|
74 |
+
$newObj = new $newClassName();
|
75 |
+
} else {
|
76 |
+
$newObj = new StdClass();
|
77 |
+
}
|
78 |
+
|
79 |
+
if (is_subclass_of($newObj, __CLASS__)) {
|
80 |
+
$newObj->initFromPublicArray($value, $classFromProp);
|
81 |
+
} else {
|
82 |
+
$reflect = new ReflectionObject($newObj);
|
83 |
+
$excludeProps = array(self::CLASS_KEY_FOR_JSON_SERIALIZE);
|
84 |
+
|
85 |
+
$privateProps = $reflect->getProperties(ReflectionProperty::IS_PROTECTED + ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_STATIC);
|
86 |
+
foreach ($privateProps as $pros) {
|
87 |
+
$excludeProps[] = $pros->getName();
|
88 |
+
}
|
89 |
+
|
90 |
+
foreach ($value as $arrayProp => $arrayValue) {
|
91 |
+
if (in_array($arrayProp, $excludeProps)) {
|
92 |
+
continue;
|
93 |
+
}
|
94 |
+
$newObj->{$arrayProp} = self::parseArrayToValue($arrayValue, $classFromProp);
|
95 |
+
}
|
96 |
+
}
|
97 |
+
return $newObj;
|
98 |
+
} else if (is_array($value)) {
|
99 |
+
$result = array();
|
100 |
+
foreach ($value as $key => $arrayVal) {
|
101 |
+
$result[$key] = self::parseArrayToValue($arrayVal);
|
102 |
+
}
|
103 |
+
return $result;
|
104 |
+
} else {
|
105 |
+
return $value;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
protected function initFromPublicArray($array, $classFromProp = null)
|
110 |
+
{
|
111 |
+
if (!is_array($array)) {
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
$reflect = new ReflectionObject($this);
|
116 |
+
$classFromArray = self::getClassFromArray($array, $classFromProp);
|
117 |
+
|
118 |
+
if ($classFromArray == false || $classFromArray !== $reflect->name) {
|
119 |
+
return false;
|
120 |
+
}
|
121 |
+
|
122 |
+
$excludeProps = array(self::CLASS_KEY_FOR_JSON_SERIALIZE);
|
123 |
+
$privateProps = $reflect->getProperties(ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_STATIC);
|
124 |
+
|
125 |
+
foreach ($privateProps as $pros) {
|
126 |
+
$excludeProps[] = $pros->getName();
|
127 |
+
}
|
128 |
+
|
129 |
+
foreach ($array as $propName => $propValue) {
|
130 |
+
if (in_array($propName, $excludeProps)) {
|
131 |
+
continue;
|
132 |
+
}
|
133 |
+
$this->{$propName} = self::parseArrayToValue($propValue, $classFromProp);
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
protected static function getClassFromArray($array, $classFromProp = null)
|
138 |
+
{
|
139 |
+
if (!is_array($array)) {
|
140 |
+
return false;
|
141 |
+
} else if (isset($array[self::CLASS_KEY_FOR_JSON_SERIALIZE])) {
|
142 |
+
return $array[self::CLASS_KEY_FOR_JSON_SERIALIZE];
|
143 |
+
} else if (!is_null($classFromProp) && isset($array[$classFromProp])) {
|
144 |
+
return $array[$classFromProp];
|
145 |
+
} else {
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
*
|
152 |
+
*/
|
153 |
+
public function jsonSerialize()
|
154 |
+
{
|
155 |
+
return DupLiteSnapJsonU::wp_json_encode_pprint(self::objectToPublicArrayClass($this));
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
*
|
160 |
+
* @param string $json
|
161 |
+
* @return type
|
162 |
+
*/
|
163 |
+
public static function jsonUnserialize($json, $classFromProp = null)
|
164 |
+
{
|
165 |
+
$publicArray = json_decode($json, true);
|
166 |
+
return self::parseArrayToValue($publicArray, $classFromProp);
|
167 |
+
}
|
168 |
+
}
|
169 |
+
}
|
lib/snaplib/class.snaplib.logger.php
CHANGED
@@ -16,6 +16,7 @@ if (!class_exists('DupLiteSnapLibLogger', false)) {
|
|
16 |
|
17 |
class DupLiteSnapLibLogger
|
18 |
{
|
|
|
19 |
public static $logFilepath = null;
|
20 |
static $logHandle = null;
|
21 |
|
16 |
|
17 |
class DupLiteSnapLibLogger
|
18 |
{
|
19 |
+
|
20 |
public static $logFilepath = null;
|
21 |
static $logHandle = null;
|
22 |
|
lib/snaplib/class.snaplib.u.io.php
CHANGED
@@ -19,6 +19,7 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
19 |
|
20 |
class DupLiteSnapLibIOU
|
21 |
{
|
|
|
22 |
// Real upper bound of a signed int is 214748364.
|
23 |
// The value chosen below, makes sure we have a buffer of ~4.7 million.
|
24 |
const FileSizeLimit32BitPHP = 1900000000;
|
@@ -237,21 +238,36 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
|
|
237 |
}
|
238 |
}
|
239 |
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
{
|
242 |
-
if (is_dir($
|
243 |
-
$
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
252 |
}
|
253 |
}
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
}
|
257 |
|
19 |
|
20 |
class DupLiteSnapLibIOU
|
21 |
{
|
22 |
+
|
23 |
// Real upper bound of a signed int is 214748364.
|
24 |
// The value chosen below, makes sure we have a buffer of ~4.7 million.
|
25 |
const FileSizeLimit32BitPHP = 1900000000;
|
238 |
}
|
239 |
}
|
240 |
|
241 |
+
/**
|
242 |
+
* Safely remove a directory and recursively files adnd directory upto multiple sublevels
|
243 |
+
*
|
244 |
+
* @param path $dir The full path to the directory to remove
|
245 |
+
*
|
246 |
+
* @return bool Returns true if all content was removed
|
247 |
+
*/
|
248 |
+
public static function rrmdir($path)
|
249 |
{
|
250 |
+
if (is_dir($path)) {
|
251 |
+
if (($dh = opendir($path)) === false) {
|
252 |
+
return false;
|
253 |
+
}
|
254 |
+
while (($object = readdir($dh)) !== false) {
|
255 |
+
if ($object == "." || $object == "..") {
|
256 |
+
continue;
|
257 |
+
}
|
258 |
+
if (!self::rrmdir($path."/".$object)) {
|
259 |
+
closedir($dh);
|
260 |
+
return false;
|
261 |
}
|
262 |
}
|
263 |
+
closedir($dh);
|
264 |
+
return @rmdir($path);
|
265 |
+
} else {
|
266 |
+
if (is_writable($path)) {
|
267 |
+
return @unlink($path);
|
268 |
+
} else {
|
269 |
+
return false;
|
270 |
+
}
|
271 |
}
|
272 |
}
|
273 |
|
lib/snaplib/class.snaplib.u.json.php
ADDED
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Snap JSON utils
|
4 |
+
*
|
5 |
+
* Standard: PSR-2
|
6 |
+
* @link http://www.php-fig.org/psr/psr-2
|
7 |
+
*
|
8 |
+
* @package SnapLib
|
9 |
+
* @copyright (c) 2019, Snapcreek LLC
|
10 |
+
* @license https://opensource.org/licenses/GPL-3.0 GNU Public License
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
14 |
+
|
15 |
+
if (!interface_exists('JsonSerializable')) {
|
16 |
+
define('SNAP_WP_JSON_SERIALIZE_COMPATIBLE', true);
|
17 |
+
|
18 |
+
/**
|
19 |
+
* JsonSerializable interface.
|
20 |
+
*
|
21 |
+
* Compatibility shim for PHP <5.4
|
22 |
+
*
|
23 |
+
* @link https://secure.php.net/jsonserializable
|
24 |
+
*
|
25 |
+
* @since 4.4.0
|
26 |
+
*/
|
27 |
+
interface JsonSerializable
|
28 |
+
{
|
29 |
+
|
30 |
+
public function jsonSerialize();
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
if (!class_exists('DupLiteSnapJsonU', false)) {
|
35 |
+
|
36 |
+
|
37 |
+
class DupLiteSnapJsonU
|
38 |
+
{
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Encode a variable into JSON, with some sanity checks.
|
42 |
+
*
|
43 |
+
* @since 4.1.0
|
44 |
+
*
|
45 |
+
* @param mixed $data Variable (usually an array or object) to encode as JSON.
|
46 |
+
* @param int $options Optional. Options to be passed to json_encode(). Default 0.
|
47 |
+
* @param int $depth Optional. Maximum depth to walk through $data. Must be
|
48 |
+
* greater than 0. Default 512.
|
49 |
+
* @return string|false The JSON encoded string, or false if it cannot be encoded.
|
50 |
+
*/
|
51 |
+
public static function wp_json_encode($data, $options = 0, $depth = 512)
|
52 |
+
{
|
53 |
+
if (function_exists('wp_json_encode')) {
|
54 |
+
return wp_json_encode($data, $options, $depth);
|
55 |
+
}
|
56 |
+
|
57 |
+
/*
|
58 |
+
* json_encode() has had extra params added over the years.
|
59 |
+
* $options was added in 5.3, and $depth in 5.5.
|
60 |
+
* We need to make sure we call it with the correct arguments.
|
61 |
+
*/
|
62 |
+
if (version_compare(PHP_VERSION, '5.5', '>=')) {
|
63 |
+
$args = array($data, $options, $depth);
|
64 |
+
} elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
|
65 |
+
$args = array($data, $options);
|
66 |
+
} else {
|
67 |
+
$args = array($data);
|
68 |
+
}
|
69 |
+
|
70 |
+
// Prepare the data for JSON serialization.
|
71 |
+
$args[0] = self::_wp_json_prepare_data($data);
|
72 |
+
|
73 |
+
$json = @call_user_func_array('json_encode', $args);
|
74 |
+
|
75 |
+
// If json_encode() was successful, no need to do more sanity checking.
|
76 |
+
// ... unless we're in an old version of PHP, and json_encode() returned
|
77 |
+
// a string containing 'null'. Then we need to do more sanity checking.
|
78 |
+
if (false !== $json && ( version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null') )) {
|
79 |
+
return $json;
|
80 |
+
}
|
81 |
+
|
82 |
+
try {
|
83 |
+
$args[0] = self::_wp_json_sanity_check($data, $depth);
|
84 |
+
}
|
85 |
+
catch (Exception $e) {
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
|
89 |
+
return call_user_func_array('json_encode', $args);
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* wp_json_encode with pretty print if define exists
|
94 |
+
*
|
95 |
+
* @param mixed $data Variable (usually an array or object) to encode as JSON.
|
96 |
+
* @param int $options Optional. Options to be passed to json_encode(). Default 0.
|
97 |
+
* @param int $depth Optional. Maximum depth to walk through $data. Must be
|
98 |
+
* greater than 0. Default 512.
|
99 |
+
* @return string|false The JSON encoded string, or false if it cannot be encoded.
|
100 |
+
*/
|
101 |
+
public static function wp_json_encode_pprint($data, $options = 0, $depth = 512)
|
102 |
+
{
|
103 |
+
if (defined('JSON_PRETTY_PRINT')) {
|
104 |
+
return self::wp_json_encode($data, JSON_PRETTY_PRINT | $options, $depth);
|
105 |
+
} else {
|
106 |
+
return self::wp_json_encode($data, $options, $depth);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Prepares response data to be serialized to JSON.
|
112 |
+
*
|
113 |
+
* This supports the JsonSerializable interface for PHP 5.2-5.3 as well.
|
114 |
+
*
|
115 |
+
* @ignore
|
116 |
+
* @since 4.4.0
|
117 |
+
* @access private
|
118 |
+
*
|
119 |
+
* @param mixed $data Native representation.
|
120 |
+
* @return bool|int|float|null|string|array Data ready for `json_encode()`.
|
121 |
+
*/
|
122 |
+
private static function _wp_json_prepare_data($data)
|
123 |
+
{
|
124 |
+
if (!defined('SNAP_WP_JSON_SERIALIZE_COMPATIBLE') || SNAP_WP_JSON_SERIALIZE_COMPATIBLE === false || !defined('WP_JSON_SERIALIZE_COMPATIBLE') || WP_JSON_SERIALIZE_COMPATIBLE === false) {
|
125 |
+
return $data;
|
126 |
+
}
|
127 |
+
|
128 |
+
switch (gettype($data)) {
|
129 |
+
case 'boolean':
|
130 |
+
case 'integer':
|
131 |
+
case 'double':
|
132 |
+
case 'string':
|
133 |
+
case 'NULL':
|
134 |
+
// These values can be passed through.
|
135 |
+
return $data;
|
136 |
+
|
137 |
+
case 'array':
|
138 |
+
// Arrays must be mapped in case they also return objects.
|
139 |
+
return array_map(array(__CLASS__, '_wp_json_prepare_data'), $data);
|
140 |
+
|
141 |
+
case 'object':
|
142 |
+
// If this is an incomplete object (__PHP_Incomplete_Class), bail.
|
143 |
+
if (!is_object($data)) {
|
144 |
+
return null;
|
145 |
+
}
|
146 |
+
|
147 |
+
if ($data instanceof JsonSerializable) {
|
148 |
+
$data = $data->jsonSerialize();
|
149 |
+
} else {
|
150 |
+
$data = get_object_vars($data);
|
151 |
+
}
|
152 |
+
|
153 |
+
// Now, pass the array (or whatever was returned from jsonSerialize through).
|
154 |
+
return self::_wp_json_prepare_data($data);
|
155 |
+
|
156 |
+
default:
|
157 |
+
return null;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Perform sanity checks on data that shall be encoded to JSON.
|
163 |
+
*
|
164 |
+
* @ignore
|
165 |
+
* @since 4.1.0
|
166 |
+
* @access private
|
167 |
+
*
|
168 |
+
* @see wp_json_encode()
|
169 |
+
*
|
170 |
+
* @param mixed $data Variable (usually an array or object) to encode as JSON.
|
171 |
+
* @param int $depth Maximum depth to walk through $data. Must be greater than 0.
|
172 |
+
* @return mixed The sanitized data that shall be encoded to JSON.
|
173 |
+
*/
|
174 |
+
private static function _wp_json_sanity_check($data, $depth)
|
175 |
+
{
|
176 |
+
if ($depth < 0) {
|
177 |
+
throw new Exception('Reached depth limit');
|
178 |
+
}
|
179 |
+
|
180 |
+
if (is_array($data)) {
|
181 |
+
$output = array();
|
182 |
+
foreach ($data as $id => $el) {
|
183 |
+
// Don't forget to sanitize the ID!
|
184 |
+
if (is_string($id)) {
|
185 |
+
$clean_id = self::_wp_json_convert_string($id);
|
186 |
+
} else {
|
187 |
+
$clean_id = $id;
|
188 |
+
}
|
189 |
+
|
190 |
+
// Check the element type, so that we're only recursing if we really have to.
|
191 |
+
if (is_array($el) || is_object($el)) {
|
192 |
+
$output[$clean_id] = self::_wp_json_sanity_check($el, $depth - 1);
|
193 |
+
} elseif (is_string($el)) {
|
194 |
+
$output[$clean_id] = self::_wp_json_convert_string($el);
|
195 |
+
} else {
|
196 |
+
$output[$clean_id] = $el;
|
197 |
+
}
|
198 |
+
}
|
199 |
+
} elseif (is_object($data)) {
|
200 |
+
$output = new stdClass;
|
201 |
+
foreach ($data as $id => $el) {
|
202 |
+
if (is_string($id)) {
|
203 |
+
$clean_id = self::_wp_json_convert_string($id);
|
204 |
+
} else {
|
205 |
+
$clean_id = $id;
|
206 |
+
}
|
207 |
+
|
208 |
+
if (is_array($el) || is_object($el)) {
|
209 |
+
$output->$clean_id = self::_wp_json_sanity_check($el, $depth - 1);
|
210 |
+
} elseif (is_string($el)) {
|
211 |
+
$output->$clean_id = self::_wp_json_convert_string($el);
|
212 |
+
} else {
|
213 |
+
$output->$clean_id = $el;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
} elseif (is_string($data)) {
|
217 |
+
return self::_wp_json_convert_string($data);
|
218 |
+
} else {
|
219 |
+
return $data;
|
220 |
+
}
|
221 |
+
|
222 |
+
return $output;
|
223 |
+
}
|
224 |
+
|
225 |
+
private static function _wp_json_convert_string($string)
|
226 |
+
{
|
227 |
+
static $use_mb = null;
|
228 |
+
if (is_null($use_mb)) {
|
229 |
+
$use_mb = function_exists('mb_convert_encoding');
|
230 |
+
}
|
231 |
+
|
232 |
+
if ($use_mb) {
|
233 |
+
$encoding = mb_detect_encoding($string, mb_detect_order(), true);
|
234 |
+
if ($encoding) {
|
235 |
+
return mb_convert_encoding($string, 'UTF-8', $encoding);
|
236 |
+
} else {
|
237 |
+
return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
|
238 |
+
}
|
239 |
+
} else {
|
240 |
+
return self::wp_check_invalid_utf8($string, true);
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Checks for invalid UTF8 in a string.
|
246 |
+
*
|
247 |
+
* @since 2.8.0
|
248 |
+
*
|
249 |
+
* @staticvar bool $utf8_pcre
|
250 |
+
*
|
251 |
+
* @param string $string The text which is to be checked.
|
252 |
+
* @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
|
253 |
+
* @return string The checked text.
|
254 |
+
*/
|
255 |
+
public static function wp_check_invalid_utf8($string, $strip = false)
|
256 |
+
{
|
257 |
+
$string = (string) $string;
|
258 |
+
|
259 |
+
if (0 === strlen($string)) {
|
260 |
+
return '';
|
261 |
+
}
|
262 |
+
|
263 |
+
// Check for support for utf8 in the installed PCRE library once and store the result in a static
|
264 |
+
static $utf8_pcre = null;
|
265 |
+
if (!isset($utf8_pcre)) {
|
266 |
+
$utf8_pcre = @preg_match('/^./u', 'a');
|
267 |
+
}
|
268 |
+
// We can't demand utf8 in the PCRE installation, so just return the string in those cases
|
269 |
+
if (!$utf8_pcre) {
|
270 |
+
return $string;
|
271 |
+
}
|
272 |
+
|
273 |
+
// preg_match fails when it encounters invalid UTF8 in $string
|
274 |
+
if (1 === @preg_match('/^./us', $string)) {
|
275 |
+
return $string;
|
276 |
+
}
|
277 |
+
|
278 |
+
// Attempt to strip the bad chars if requested (not recommended)
|
279 |
+
if ($strip && function_exists('iconv')) {
|
280 |
+
return iconv('utf-8', 'utf-8', $string);
|
281 |
+
}
|
282 |
+
|
283 |
+
return '';
|
284 |
+
}
|
285 |
+
}
|
286 |
+
}
|
lib/snaplib/class.snaplib.u.os.php
CHANGED
@@ -16,6 +16,7 @@ if (!class_exists('DupLiteSnapLibOSU', false)) {
|
|
16 |
|
17 |
class DupLiteSnapLibOSU
|
18 |
{
|
|
|
19 |
const DEFAULT_WINDOWS_MAXPATH = 260;
|
20 |
const DEFAULT_LINUX_MAXPATH = 4096;
|
21 |
|
16 |
|
17 |
class DupLiteSnapLibOSU
|
18 |
{
|
19 |
+
|
20 |
const DEFAULT_WINDOWS_MAXPATH = 260;
|
21 |
const DEFAULT_LINUX_MAXPATH = 4096;
|
22 |
|
lib/snaplib/class.snaplib.u.util.php
CHANGED
@@ -13,25 +13,6 @@
|
|
13 |
*/
|
14 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
15 |
|
16 |
-
if (!interface_exists('JsonSerializable')) {
|
17 |
-
define('SNAP_WP_JSON_SERIALIZE_COMPATIBLE', true);
|
18 |
-
|
19 |
-
/**
|
20 |
-
* JsonSerializable interface.
|
21 |
-
*
|
22 |
-
* Compatibility shim for PHP <5.4
|
23 |
-
*
|
24 |
-
* @link https://secure.php.net/jsonserializable
|
25 |
-
*
|
26 |
-
* @since 4.4.0
|
27 |
-
*/
|
28 |
-
interface JsonSerializable
|
29 |
-
{
|
30 |
-
|
31 |
-
public function jsonSerialize();
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
if (!class_exists('DupLiteSnapLibUtil', false)) {
|
36 |
|
37 |
class DupLiteSnapLibUtil
|
@@ -62,7 +43,7 @@ if (!class_exists('DupLiteSnapLibUtil', false)) {
|
|
62 |
public static function getWorkPercent($startingPercent, $endingPercent, $totalTaskCount, $currentTaskCount)
|
63 |
{
|
64 |
if ($totalTaskCount > 0) {
|
65 |
-
$percent =
|
66 |
} else {
|
67 |
$percent = 0;
|
68 |
}
|
@@ -79,7 +60,8 @@ if (!class_exists('DupLiteSnapLibUtil', false)) {
|
|
79 |
} else {
|
80 |
return strtolower(md5(uniqid(rand(), true))).'_'.date("YmdHis");
|
81 |
}
|
82 |
-
}
|
|
|
83 |
return strtolower(md5(uniqid(rand(), true))).'_'.date("YmdHis");
|
84 |
}
|
85 |
}
|
@@ -133,7 +115,7 @@ if (!class_exists('DupLiteSnapLibUtil', false)) {
|
|
133 |
$args = func_get_args();
|
134 |
foreach ($grouped as $key => $value) {
|
135 |
$params = array_merge(array($value), array_slice($args, 2, func_num_args()));
|
136 |
-
$grouped[$key] = call_user_func_array('
|
137 |
}
|
138 |
}
|
139 |
return $grouped;
|
@@ -184,6 +166,17 @@ if (!class_exists('DupLiteSnapLibUtil', false)) {
|
|
184 |
return filter_var($input, FILTER_SANITIZE_STRING);
|
185 |
}
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
/**
|
188 |
* Determines whether a PHP ini value is changeable at runtime.
|
189 |
*
|
@@ -226,248 +219,16 @@ if (!class_exists('DupLiteSnapLibUtil', false)) {
|
|
226 |
}
|
227 |
|
228 |
/**
|
229 |
-
*
|
230 |
-
*
|
231 |
-
* @
|
232 |
-
*
|
233 |
-
* @param
|
234 |
-
* @
|
235 |
-
* @param int $depth Optional. Maximum depth to walk through $data. Must be
|
236 |
-
* greater than 0. Default 512.
|
237 |
-
* @return string|false The JSON encoded string, or false if it cannot be encoded.
|
238 |
-
*/
|
239 |
-
public static function wp_json_encode($data, $options = 0, $depth = 512)
|
240 |
-
{
|
241 |
-
if (function_exists('wp_json_encode')) {
|
242 |
-
return wp_json_encode($data, $options, $depth);
|
243 |
-
}
|
244 |
-
|
245 |
-
/*
|
246 |
-
* json_encode() has had extra params added over the years.
|
247 |
-
* $options was added in 5.3, and $depth in 5.5.
|
248 |
-
* We need to make sure we call it with the correct arguments.
|
249 |
-
*/
|
250 |
-
if (version_compare(PHP_VERSION, '5.5', '>=')) {
|
251 |
-
$args = array($data, $options, $depth);
|
252 |
-
} elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
|
253 |
-
$args = array($data, $options);
|
254 |
-
} else {
|
255 |
-
$args = array($data);
|
256 |
-
}
|
257 |
-
|
258 |
-
// Prepare the data for JSON serialization.
|
259 |
-
$args[0] = self::_wp_json_prepare_data($data);
|
260 |
-
|
261 |
-
$json = @call_user_func_array('json_encode', $args);
|
262 |
-
|
263 |
-
// If json_encode() was successful, no need to do more sanity checking.
|
264 |
-
// ... unless we're in an old version of PHP, and json_encode() returned
|
265 |
-
// a string containing 'null'. Then we need to do more sanity checking.
|
266 |
-
if (false !== $json && ( version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null') )) {
|
267 |
-
return $json;
|
268 |
-
}
|
269 |
-
|
270 |
-
try {
|
271 |
-
$args[0] = self::_wp_json_sanity_check($data, $depth);
|
272 |
-
} catch (Exception $e) {
|
273 |
-
return false;
|
274 |
-
}
|
275 |
-
|
276 |
-
return call_user_func_array('json_encode', $args);
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* wp_json_encode with pretty print if define exists
|
281 |
-
*
|
282 |
-
* @param mixed $data Variable (usually an array or object) to encode as JSON.
|
283 |
-
* @param int $options Optional. Options to be passed to json_encode(). Default 0.
|
284 |
-
* @param int $depth Optional. Maximum depth to walk through $data. Must be
|
285 |
-
* greater than 0. Default 512.
|
286 |
-
* @return string|false The JSON encoded string, or false if it cannot be encoded.
|
287 |
*/
|
288 |
-
public static function
|
289 |
{
|
290 |
-
|
291 |
-
return self::wp_json_encode($data, JSON_PRETTY_PRINT | $options, $depth);
|
292 |
-
} else {
|
293 |
-
return self::wp_json_encode($data, $options, $depth);
|
294 |
-
}
|
295 |
-
}
|
296 |
-
|
297 |
-
/**
|
298 |
-
* Prepares response data to be serialized to JSON.
|
299 |
-
*
|
300 |
-
* This supports the JsonSerializable interface for PHP 5.2-5.3 as well.
|
301 |
-
*
|
302 |
-
* @ignore
|
303 |
-
* @since 4.4.0
|
304 |
-
* @access private
|
305 |
-
*
|
306 |
-
* @param mixed $data Native representation.
|
307 |
-
* @return bool|int|float|null|string|array Data ready for `json_encode()`.
|
308 |
-
*/
|
309 |
-
private static function _wp_json_prepare_data($data)
|
310 |
-
{
|
311 |
-
if (!defined('SNAP_WP_JSON_SERIALIZE_COMPATIBLE') || SNAP_WP_JSON_SERIALIZE_COMPATIBLE === false || !defined('WP_JSON_SERIALIZE_COMPATIBLE') || WP_JSON_SERIALIZE_COMPATIBLE === false) {
|
312 |
-
return $data;
|
313 |
-
}
|
314 |
-
|
315 |
-
switch (gettype($data)) {
|
316 |
-
case 'boolean':
|
317 |
-
case 'integer':
|
318 |
-
case 'double':
|
319 |
-
case 'string':
|
320 |
-
case 'NULL':
|
321 |
-
// These values can be passed through.
|
322 |
-
return $data;
|
323 |
-
|
324 |
-
case 'array':
|
325 |
-
// Arrays must be mapped in case they also return objects.
|
326 |
-
return array_map('self::_wp_json_prepare_data', $data);
|
327 |
-
|
328 |
-
case 'object':
|
329 |
-
// If this is an incomplete object (__PHP_Incomplete_Class), bail.
|
330 |
-
if (!is_object($data)) {
|
331 |
-
return null;
|
332 |
-
}
|
333 |
-
|
334 |
-
if ($data instanceof JsonSerializable) {
|
335 |
-
$data = $data->jsonSerialize();
|
336 |
-
} else {
|
337 |
-
$data = get_object_vars($data);
|
338 |
-
}
|
339 |
-
|
340 |
-
// Now, pass the array (or whatever was returned from jsonSerialize through).
|
341 |
-
return self::_wp_json_prepare_data($data);
|
342 |
-
|
343 |
-
default:
|
344 |
-
return null;
|
345 |
-
}
|
346 |
-
}
|
347 |
-
|
348 |
-
/**
|
349 |
-
* Perform sanity checks on data that shall be encoded to JSON.
|
350 |
-
*
|
351 |
-
* @ignore
|
352 |
-
* @since 4.1.0
|
353 |
-
* @access private
|
354 |
-
*
|
355 |
-
* @see wp_json_encode()
|
356 |
-
*
|
357 |
-
* @param mixed $data Variable (usually an array or object) to encode as JSON.
|
358 |
-
* @param int $depth Maximum depth to walk through $data. Must be greater than 0.
|
359 |
-
* @return mixed The sanitized data that shall be encoded to JSON.
|
360 |
-
*/
|
361 |
-
private static function _wp_json_sanity_check($data, $depth)
|
362 |
-
{
|
363 |
-
if ($depth < 0) {
|
364 |
-
throw new Exception('Reached depth limit');
|
365 |
-
}
|
366 |
-
|
367 |
-
if (is_array($data)) {
|
368 |
-
$output = array();
|
369 |
-
foreach ($data as $id => $el) {
|
370 |
-
// Don't forget to sanitize the ID!
|
371 |
-
if (is_string($id)) {
|
372 |
-
$clean_id = self::_wp_json_convert_string($id);
|
373 |
-
} else {
|
374 |
-
$clean_id = $id;
|
375 |
-
}
|
376 |
-
|
377 |
-
// Check the element type, so that we're only recursing if we really have to.
|
378 |
-
if (is_array($el) || is_object($el)) {
|
379 |
-
$output[$clean_id] = self::_wp_json_sanity_check($el, $depth - 1);
|
380 |
-
} elseif (is_string($el)) {
|
381 |
-
$output[$clean_id] = self::_wp_json_convert_string($el);
|
382 |
-
} else {
|
383 |
-
$output[$clean_id] = $el;
|
384 |
-
}
|
385 |
-
}
|
386 |
-
} elseif (is_object($data)) {
|
387 |
-
$output = new stdClass;
|
388 |
-
foreach ($data as $id => $el) {
|
389 |
-
if (is_string($id)) {
|
390 |
-
$clean_id = self::_wp_json_convert_string($id);
|
391 |
-
} else {
|
392 |
-
$clean_id = $id;
|
393 |
-
}
|
394 |
-
|
395 |
-
if (is_array($el) || is_object($el)) {
|
396 |
-
$output->$clean_id = self::_wp_json_sanity_check($el, $depth - 1);
|
397 |
-
} elseif (is_string($el)) {
|
398 |
-
$output->$clean_id = self::_wp_json_convert_string($el);
|
399 |
-
} else {
|
400 |
-
$output->$clean_id = $el;
|
401 |
-
}
|
402 |
-
}
|
403 |
-
} elseif (is_string($data)) {
|
404 |
-
return self::_wp_json_convert_string($data);
|
405 |
-
} else {
|
406 |
-
return $data;
|
407 |
-
}
|
408 |
-
|
409 |
-
return $output;
|
410 |
-
}
|
411 |
-
|
412 |
-
private static function _wp_json_convert_string($string)
|
413 |
-
{
|
414 |
-
static $use_mb = null;
|
415 |
-
if (is_null($use_mb)) {
|
416 |
-
$use_mb = function_exists('mb_convert_encoding');
|
417 |
-
}
|
418 |
-
|
419 |
-
if ($use_mb) {
|
420 |
-
$encoding = mb_detect_encoding($string, mb_detect_order(), true);
|
421 |
-
if ($encoding) {
|
422 |
-
return mb_convert_encoding($string, 'UTF-8', $encoding);
|
423 |
-
} else {
|
424 |
-
return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
|
425 |
-
}
|
426 |
-
} else {
|
427 |
-
return self::wp_check_invalid_utf8($string, true);
|
428 |
-
}
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* Checks for invalid UTF8 in a string.
|
433 |
-
*
|
434 |
-
* @since 2.8.0
|
435 |
-
*
|
436 |
-
* @staticvar bool $utf8_pcre
|
437 |
-
*
|
438 |
-
* @param string $string The text which is to be checked.
|
439 |
-
* @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
|
440 |
-
* @return string The checked text.
|
441 |
-
*/
|
442 |
-
public static function wp_check_invalid_utf8($string, $strip = false)
|
443 |
-
{
|
444 |
-
$string = (string) $string;
|
445 |
-
|
446 |
-
if (0 === strlen($string)) {
|
447 |
-
return '';
|
448 |
-
}
|
449 |
-
|
450 |
-
// Check for support for utf8 in the installed PCRE library once and store the result in a static
|
451 |
-
static $utf8_pcre = null;
|
452 |
-
if (!isset($utf8_pcre)) {
|
453 |
-
$utf8_pcre = @preg_match('/^./u', 'a');
|
454 |
-
}
|
455 |
-
// We can't demand utf8 in the PCRE installation, so just return the string in those cases
|
456 |
-
if (!$utf8_pcre) {
|
457 |
-
return $string;
|
458 |
-
}
|
459 |
-
|
460 |
-
// preg_match fails when it encounters invalid UTF8 in $string
|
461 |
-
if (1 === @preg_match('/^./us', $string)) {
|
462 |
-
return $string;
|
463 |
-
}
|
464 |
-
|
465 |
-
// Attempt to strip the bad chars if requested (not recommended)
|
466 |
-
if ($strip && function_exists('iconv')) {
|
467 |
-
return iconv('utf-8', 'utf-8', $string);
|
468 |
-
}
|
469 |
-
|
470 |
-
return '';
|
471 |
}
|
472 |
}
|
473 |
-
}
|
13 |
*/
|
14 |
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
if (!class_exists('DupLiteSnapLibUtil', false)) {
|
17 |
|
18 |
class DupLiteSnapLibUtil
|
43 |
public static function getWorkPercent($startingPercent, $endingPercent, $totalTaskCount, $currentTaskCount)
|
44 |
{
|
45 |
if ($totalTaskCount > 0) {
|
46 |
+
$percent = $startingPercent + (($endingPercent - $startingPercent) * ($currentTaskCount / (float) $totalTaskCount));
|
47 |
} else {
|
48 |
$percent = 0;
|
49 |
}
|
60 |
} else {
|
61 |
return strtolower(md5(uniqid(rand(), true))).'_'.date("YmdHis");
|
62 |
}
|
63 |
+
}
|
64 |
+
catch (Exception $exc) {
|
65 |
return strtolower(md5(uniqid(rand(), true))).'_'.date("YmdHis");
|
66 |
}
|
67 |
}
|
115 |
$args = func_get_args();
|
116 |
foreach ($grouped as $key => $value) {
|
117 |
$params = array_merge(array($value), array_slice($args, 2, func_num_args()));
|
118 |
+
$grouped[$key] = call_user_func_array(array(__CLASS__, 'arrayGroupBy'), $params);
|
119 |
}
|
120 |
}
|
121 |
return $grouped;
|
166 |
return filter_var($input, FILTER_SANITIZE_STRING);
|
167 |
}
|
168 |
|
169 |
+
/**
|
170 |
+
* remove all non stamo chars from string
|
171 |
+
*
|
172 |
+
* @param string $string
|
173 |
+
* @return string
|
174 |
+
*/
|
175 |
+
public static function sanitize_non_stamp_chars($string)
|
176 |
+
{
|
177 |
+
return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/u', '', $string);
|
178 |
+
}
|
179 |
+
|
180 |
/**
|
181 |
* Determines whether a PHP ini value is changeable at runtime.
|
182 |
*
|
219 |
}
|
220 |
|
221 |
/**
|
222 |
+
* The val value returns if it is between min and max otherwise it returns min or max
|
223 |
+
*
|
224 |
+
* @param int $val
|
225 |
+
* @param int $min
|
226 |
+
* @param int $max
|
227 |
+
* @return int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
*/
|
229 |
+
public static function getIntBetween($val, $min, $max)
|
230 |
{
|
231 |
+
return min((int) $max, max((int) $min, (int) $val));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
}
|
233 |
}
|
234 |
+
}
|
lib/snaplib/class.snaplib.u.wp.php
CHANGED
@@ -20,6 +20,7 @@ if (!class_exists('DupLiteSnapLibUtilWp', false)) {
|
|
20 |
*/
|
21 |
class DupLiteSnapLibUtilWp
|
22 |
{
|
|
|
23 |
const PATH_FULL = 0;
|
24 |
const PATH_RELATIVE = 1;
|
25 |
const PATH_AUTO = 2;
|
20 |
*/
|
21 |
class DupLiteSnapLibUtilWp
|
22 |
{
|
23 |
+
|
24 |
const PATH_FULL = 0;
|
25 |
const PATH_RELATIVE = 1;
|
26 |
const PATH_AUTO = 2;
|
lib/snaplib/snaplib.all.php
CHANGED
@@ -22,6 +22,8 @@ if (!defined('DUPLITE_SNAPLIB_INCLUDE_ALL')) {
|
|
22 |
require_once($dir.'/class.snaplib.logger.php');
|
23 |
require_once($dir.'/class.snaplib.u.util.php');
|
24 |
require_once($dir.'/class.snaplib.u.io.php');
|
|
|
|
|
25 |
require_once($dir.'/class.snaplib.u.net.php');
|
26 |
require_once($dir.'/class.snaplib.u.os.php');
|
27 |
require_once($dir.'/class.snaplib.u.stream.php');
|
22 |
require_once($dir.'/class.snaplib.logger.php');
|
23 |
require_once($dir.'/class.snaplib.u.util.php');
|
24 |
require_once($dir.'/class.snaplib.u.io.php');
|
25 |
+
require_once($dir.'/class.snaplib.u.json.php');
|
26 |
+
require_once($dir.'/class.snaplib.jsonSerializable.abstract.php');
|
27 |
require_once($dir.'/class.snaplib.u.net.php');
|
28 |
require_once($dir.'/class.snaplib.u.os.php');
|
29 |
require_once($dir.'/class.snaplib.u.stream.php');
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: migration, backup, restore, move, migrate, duplicate, transfer, clone, aut
|
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 5.2
|
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.
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 5.2
|
6 |
Requires PHP: 5.2.17
|
7 |
+
Stable tag: 1.3.20
|
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.
|
views/packages/main/s1.setup2.php
CHANGED
@@ -285,29 +285,30 @@ ARCHIVE -->
|
|
285 |
|
286 |
echo '<table id="dup-dbtables"><tr><td valign="top">';
|
287 |
foreach ($tables as $table) {
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
|
|
311 |
}
|
312 |
}
|
313 |
echo '</td></tr></table>';
|
285 |
|
286 |
echo '<table id="dup-dbtables"><tr><td valign="top">';
|
287 |
foreach ($tables as $table) {
|
288 |
+
if (DUP_Util::isTableExists($table[0])) {
|
289 |
+
if (DUP_Util::isWPCoreTable($table[0])) {
|
290 |
+
$core_css = 'core-table';
|
291 |
+
$core_note = '*';
|
292 |
+
} else {
|
293 |
+
$core_css = 'non-core-table';
|
294 |
+
$core_note = '';
|
295 |
+
}
|
296 |
+
|
297 |
+
if (in_array($table[0], $tableList)) {
|
298 |
+
$checked = 'checked="checked"';
|
299 |
+
$css = 'text-decoration:line-through';
|
300 |
+
} else {
|
301 |
+
$checked = '';
|
302 |
+
$css = '';
|
303 |
+
}
|
304 |
+
echo "<label for='dbtables-{$table[0]}' style='{$css}' class='{$core_css}'>"
|
305 |
+
. "<input class='checkbox dbtable' $checked type='checkbox' name='dbtables[]' id='dbtables-{$table[0]}' value='{$table[0]}' onclick='Duplicator.Pack.ExcludeTable(this)' />"
|
306 |
+
. " {$table[0]}{$core_note}</label><br />";
|
307 |
+
$counter++;
|
308 |
+
if ($next_row <= $counter) {
|
309 |
+
echo '</td><td valign="top">';
|
310 |
+
$counter = 0;
|
311 |
+
}
|
312 |
}
|
313 |
}
|
314 |
echo '</td></tr></table>';
|
views/packages/main/s2.scan3.php
CHANGED
@@ -9,7 +9,7 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
|
9 |
echo "<div title='{$root}' class='divider'><i class='fa fa-folder-open'></i> {$sroot}</div>";
|
10 |
}
|
11 |
|
12 |
-
$archive_type_label = DUP_Settings::Get('archive_build_mode') == DUP_Archive_Build_Mode::ZipArchive ? "ZipArchive" : "DupArchive
|
13 |
$archive_type_extension = DUP_Settings::Get('archive_build_mode') == DUP_Archive_Build_Mode::ZipArchive ? "zip" : "daf";
|
14 |
$duparchive_max_limit = DUP_Util::readableByteSize(DUPLICATOR_MAX_DUPARCHIVE_SIZE);
|
15 |
$skip_archive_scan = DUP_Settings::Get('skip_archive_scan');
|
9 |
echo "<div title='{$root}' class='divider'><i class='fa fa-folder-open'></i> {$sroot}</div>";
|
10 |
}
|
11 |
|
12 |
+
$archive_type_label = DUP_Settings::Get('archive_build_mode') == DUP_Archive_Build_Mode::ZipArchive ? "ZipArchive" : "DupArchive";
|
13 |
$archive_type_extension = DUP_Settings::Get('archive_build_mode') == DUP_Archive_Build_Mode::ZipArchive ? "zip" : "daf";
|
14 |
$duparchive_max_limit = DUP_Util::readableByteSize(DUPLICATOR_MAX_DUPARCHIVE_SIZE);
|
15 |
$skip_archive_scan = DUP_Settings::Get('skip_archive_scan');
|
views/packages/main/s3.build.php
CHANGED
@@ -44,7 +44,7 @@ $rand_txt[0] = $atext0;
|
|
44 |
div#dup-create-area-link {display:none; margin-left: -5px}
|
45 |
div#dup-progress-area div.dup-panel-panel { border-top: 1px solid silver}
|
46 |
fieldset.download-area {border:2px dashed #dfdfdf; padding:20px 20px 10px 20px; border-radius:9px; margin: auto; width:400px }
|
47 |
-
fieldset.download-area legend {font-weight: bold; font-size: 16px}
|
48 |
button#dup-btn-installer, button#dup-btn-archive {min-width: 150px}
|
49 |
div.one-click-download {margin:15px 0 10px 0; font-size:16px; font-weight: bold}
|
50 |
div.one-click-download i.fa-bolt{padding-right: 5px}
|
@@ -400,7 +400,7 @@ jQuery(document).ready(function ($)
|
|
400 |
cache: false,
|
401 |
dataType: "text",
|
402 |
url: ajaxurl,
|
403 |
-
timeout:
|
404 |
data: data,
|
405 |
beforeSend: function () {
|
406 |
startTime = new Date().getTime();
|
@@ -445,10 +445,10 @@ jQuery(document).ready(function ($)
|
|
445 |
console.log('Duplicator.Pack.CreateDupArchive');
|
446 |
var data = {action: 'duplicator_duparchive_package_build', nonce: '<?php echo esc_js($duparchive_build_nonce); ?>'}
|
447 |
var statusInterval = setInterval(Duplicator.Pack.GetActivePackageStatus, Duplicator.Pack.StatusFrequency);
|
448 |
-
|
449 |
$.ajax({
|
450 |
type: "POST",
|
451 |
-
timeout:
|
452 |
dataType: "text",
|
453 |
url: ajaxurl,
|
454 |
data: data,
|
@@ -459,8 +459,8 @@ jQuery(document).ready(function ($)
|
|
459 |
try {
|
460 |
var data = Duplicator.parseJSON(respData);
|
461 |
} catch(err) {
|
462 |
-
console.
|
463 |
-
console.
|
464 |
console.log('DupArchive AJAX error!');
|
465 |
console.log("jqHr:");
|
466 |
console.log(xHr);
|
@@ -559,7 +559,7 @@ jQuery(document).ready(function ($)
|
|
559 |
type: "POST",
|
560 |
url: ajaxurl,
|
561 |
dataType: "text",
|
562 |
-
timeout:
|
563 |
data: data,
|
564 |
success: function (respData, textStatus, xHr) {
|
565 |
try {
|
44 |
div#dup-create-area-link {display:none; margin-left: -5px}
|
45 |
div#dup-progress-area div.dup-panel-panel { border-top: 1px solid silver}
|
46 |
fieldset.download-area {border:2px dashed #dfdfdf; padding:20px 20px 10px 20px; border-radius:9px; margin: auto; width:400px }
|
47 |
+
fieldset.download-area legend {font-weight: bold; font-size: 16px; margin:auto}
|
48 |
button#dup-btn-installer, button#dup-btn-archive {min-width: 150px}
|
49 |
div.one-click-download {margin:15px 0 10px 0; font-size:16px; font-weight: bold}
|
50 |
div.one-click-download i.fa-bolt{padding-right: 5px}
|
400 |
cache: false,
|
401 |
dataType: "text",
|
402 |
url: ajaxurl,
|
403 |
+
timeout: 0, // no timeout
|
404 |
data: data,
|
405 |
beforeSend: function () {
|
406 |
startTime = new Date().getTime();
|
445 |
console.log('Duplicator.Pack.CreateDupArchive');
|
446 |
var data = {action: 'duplicator_duparchive_package_build', nonce: '<?php echo esc_js($duparchive_build_nonce); ?>'}
|
447 |
var statusInterval = setInterval(Duplicator.Pack.GetActivePackageStatus, Duplicator.Pack.StatusFrequency);
|
448 |
+
|
449 |
$.ajax({
|
450 |
type: "POST",
|
451 |
+
timeout: 0, // no timeout
|
452 |
dataType: "text",
|
453 |
url: ajaxurl,
|
454 |
data: data,
|
459 |
try {
|
460 |
var data = Duplicator.parseJSON(respData);
|
461 |
} catch(err) {
|
462 |
+
console.log(err);
|
463 |
+
console.log('JSON parse failed for response data: ' + respData);
|
464 |
console.log('DupArchive AJAX error!');
|
465 |
console.log("jqHr:");
|
466 |
console.log(xHr);
|
559 |
type: "POST",
|
560 |
url: ajaxurl,
|
561 |
dataType: "text",
|
562 |
+
timeout: 0, // no timeout
|
563 |
data: data,
|
564 |
success: function (respData, textStatus, xHr) {
|
565 |
try {
|
views/settings/general.php
CHANGED
@@ -23,9 +23,15 @@ if (isset($_POST['action']) && $_POST['action'] == 'save') {
|
|
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'
|
27 |
DUP_Settings::Set('skip_archive_scan', $skip_archive_scan);
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
if(isset($_REQUEST['trace_log_enabled'])) {
|
30 |
|
31 |
dup_log::trace("#### trace log enabled");
|
@@ -58,6 +64,8 @@ $wpfront_integrate = DUP_Settings::Get('wpfront_integrate');
|
|
58 |
$wpfront_ready = apply_filters('wpfront_user_role_editor_duplicator_integration_ready', false);
|
59 |
$package_debug = DUP_Settings::Get('package_debug');
|
60 |
$skip_archive_scan = DUP_Settings::Get('skip_archive_scan');
|
|
|
|
|
61 |
?>
|
62 |
|
63 |
<style>
|
@@ -173,7 +181,7 @@ $skip_archive_scan = DUP_Settings::Get('skip_archive_scan');
|
|
173 |
<button class="button" onclick="Duplicator.Pack.ConfirmResetAll(); return false;">
|
174 |
<i class="fas fa-redo fa-sm"></i> <?php esc_html_e('Reset Packages', 'duplicator'); ?>
|
175 |
</button>
|
176 |
-
<p class="description"
|
177 |
<?php esc_html_e("This process will reset all packages by deleting those without a completed status, reset the active package id and perform a "
|
178 |
. "cleanup of the build tmp file.", 'duplicator'); ?>
|
179 |
<i class="fas fa-question-circle fa-sm"
|
@@ -183,16 +191,48 @@ $skip_archive_scan = DUP_Settings::Get('skip_archive_scan');
|
|
183 |
</td>
|
184 |
</tr>
|
185 |
<tr valign="top">
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
</table>
|
197 |
|
198 |
<p class="submit" style="margin: 20px 0px 0xp 5px;">
|
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 |
|
29 |
+
$unhook_third_party_js = filter_input(INPUT_POST, 'unhook_third_party_js', FILTER_VALIDATE_BOOLEAN);
|
30 |
+
DUP_Settings::Set('unhook_third_party_js', $unhook_third_party_js);
|
31 |
+
|
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 |
if(isset($_REQUEST['trace_log_enabled'])) {
|
36 |
|
37 |
dup_log::trace("#### trace log enabled");
|
64 |
$wpfront_ready = apply_filters('wpfront_user_role_editor_duplicator_integration_ready', false);
|
65 |
$package_debug = DUP_Settings::Get('package_debug');
|
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 |
?>
|
70 |
|
71 |
<style>
|
181 |
<button class="button" onclick="Duplicator.Pack.ConfirmResetAll(); return false;">
|
182 |
<i class="fas fa-redo fa-sm"></i> <?php esc_html_e('Reset Packages', 'duplicator'); ?>
|
183 |
</button>
|
184 |
+
<p class="description">
|
185 |
<?php esc_html_e("This process will reset all packages by deleting those without a completed status, reset the active package id and perform a "
|
186 |
. "cleanup of the build tmp file.", 'duplicator'); ?>
|
187 |
<i class="fas fa-question-circle fa-sm"
|
191 |
</td>
|
192 |
</tr>
|
193 |
<tr valign="top">
|
194 |
+
<th scope="row"><label><?php esc_html_e('Archive scan', 'duplicator'); ?></label></th>
|
195 |
+
<td>
|
196 |
+
<input type="checkbox" name="skip_archive_scan" id="_skip_archive_scan" <?php checked( $skip_archive_scan , true ); ?> value="1" />
|
197 |
+
<label for="_skip_archive_scan"><?php esc_html_e("Skip", 'duplicator') ?> </label><br/>
|
198 |
+
<p class="description">
|
199 |
+
<?php 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 |
+
</p>
|
202 |
+
</td>
|
203 |
+
</tr>
|
204 |
+
<tr>
|
205 |
+
<th scope="row"><label><?php esc_html_e("Other Plugins/Themes JS", 'duplicator'); ?></label></th>
|
206 |
+
<td>
|
207 |
+
<input type="checkbox" name="unhook_third_party_js" id="unhook_third_party_js" <?php checked($unhook_third_party_js, true); ?> value="1"/>
|
208 |
+
<label for="unhook_third_party_js"><?php esc_html_e("Unhook them on Duplicator pages", 'duplicator'); ?></label> <br/>
|
209 |
+
<p class="description">
|
210 |
+
<?php
|
211 |
+
esc_html_e("Check this option if other plugins/themes JavaScript files are conflicting with Duplicator.", 'duplicator');
|
212 |
+
?>
|
213 |
+
<br>
|
214 |
+
<?php
|
215 |
+
esc_html_e("Do not modify this setting unless you know the expected result or have talked to support.", 'duplicator');
|
216 |
+
?>
|
217 |
+
</p>
|
218 |
+
</td>
|
219 |
+
</tr>
|
220 |
+
<tr>
|
221 |
+
<th scope="row"><label><?php esc_html_e("Other Plugins/Themes CSS", 'duplicator'); ?></label></th>
|
222 |
+
<td>
|
223 |
+
<input type="checkbox" name="unhook_third_party_css" id="unhook_third_party_css" <?php checked($unhook_third_party_css, true); ?> value="1"/>
|
224 |
+
<label for="unhook_third_party_css"><?php esc_html_e("Unhook them on Duplicator pages", 'duplicator'); ?></label> <br/>
|
225 |
+
<p class="description">
|
226 |
+
<?php
|
227 |
+
esc_html_e("Check this option if other plugins/themes CSS files are conflicting with Duplicator.", 'duplicator');
|
228 |
+
?>
|
229 |
+
<br>
|
230 |
+
<?php
|
231 |
+
esc_html_e("Do not modify this setting unless you know the expected result or have talked to support.", 'duplicator');
|
232 |
+
?>
|
233 |
+
</p>
|
234 |
+
</td>
|
235 |
+
</tr>
|
236 |
</table>
|
237 |
|
238 |
<p class="submit" style="margin: 20px 0px 0xp 5px;">
|
views/settings/packages.php
CHANGED
@@ -216,7 +216,7 @@ $archive_build_mode = DUP_Settings::Get('archive_build_mode')
|
|
216 |
<div class="engine-radio">
|
217 |
<input type="radio" name="archive_build_mode" id="archive_build_mode2" onclick="Duplicator.Pack.ToggleArchiveEngine()"
|
218 |
value="<?php echo esc_attr(DUP_Archive_Build_Mode::DupArchive); ?>" <?php echo ($archive_build_mode == DUP_Archive_Build_Mode::DupArchive) ? 'checked="checked"' : ''; ?> />
|
219 |
-
<label for="archive_build_mode2"><?php esc_html_e('DupArchive
|
220 |
</div>
|
221 |
|
222 |
<br style="clear:both"/>
|
216 |
<div class="engine-radio">
|
217 |
<input type="radio" name="archive_build_mode" id="archive_build_mode2" onclick="Duplicator.Pack.ToggleArchiveEngine()"
|
218 |
value="<?php echo esc_attr(DUP_Archive_Build_Mode::DupArchive); ?>" <?php echo ($archive_build_mode == DUP_Archive_Build_Mode::DupArchive) ? 'checked="checked"' : ''; ?> />
|
219 |
+
<label for="archive_build_mode2"><?php esc_html_e('DupArchive'); ?></label>
|
220 |
</div>
|
221 |
|
222 |
<br style="clear:both"/>
|
views/tools/diagnostics/inc.settings.php
CHANGED
@@ -69,7 +69,16 @@ SERVER SETTINGS -->
|
|
69 |
</tr>
|
70 |
<tr>
|
71 |
<td><?php esc_html_e("Server IP", 'duplicator'); ?></td>
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
</tr>
|
74 |
<tr>
|
75 |
<td><?php esc_html_e("Client IP", 'duplicator'); ?></td>
|
69 |
</tr>
|
70 |
<tr>
|
71 |
<td><?php esc_html_e("Server IP", 'duplicator'); ?></td>
|
72 |
+
<?php
|
73 |
+
if (isset($_SERVER['SERVER_ADDR'])) {
|
74 |
+
$server_address = $_SERVER['SERVER_ADDR'];
|
75 |
+
} elseif (isset($_SERVER['SERVER_NAME']) && function_exists('gethostbyname')) {
|
76 |
+
$server_address = gethostbyname($_SERVER['SERVER_NAME']);
|
77 |
+
} else {
|
78 |
+
$server_address = __("Can't detect", 'duplicator');
|
79 |
+
}
|
80 |
+
?>
|
81 |
+
<td><?php echo esc_html($server_address); ?></td>
|
82 |
</tr>
|
83 |
<tr>
|
84 |
<td><?php esc_html_e("Client IP", 'duplicator'); ?></td>
|
views/tools/diagnostics/logging.php
CHANGED
@@ -36,22 +36,32 @@ $logfound = (strlen($logname) > 0) ? true :false;
|
|
36 |
?>
|
37 |
|
38 |
<style>
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
</style>
|
56 |
|
57 |
<script>
|
36 |
?>
|
37 |
|
38 |
<style>
|
39 |
+
div#dup-refresh-count {display: inline-block}
|
40 |
+
table#dup-log-panels {width:100%; }
|
41 |
+
td#dup-log-panel-left {width:75%;}
|
42 |
+
td#dup-log-panel-left div.name {float:left; margin: 0px 0px 5px 5px;}
|
43 |
+
td#dup-log-panel-left div.opts {float:right;}
|
44 |
+
td#dup-log-panel-right {vertical-align: top; padding-left:15px; max-width: 375px}
|
45 |
+
#dup-log-content {
|
46 |
+
padding:5px;
|
47 |
+
background: #fff;
|
48 |
+
min-height:500px;
|
49 |
+
width: calc(100vw - 630px);;
|
50 |
+
border:1px solid silver;
|
51 |
+
overflow:scroll;
|
52 |
+
word-wrap: break-word;
|
53 |
+
margin:0;
|
54 |
+
line-height: 2;
|
55 |
+
}
|
56 |
+
|
57 |
+
/* OPTIONS */
|
58 |
+
div.dup-log-hdr {font-weight: bold; font-size:16px; padding:2px; }
|
59 |
+
div.dup-log-hdr small{font-weight:normal; font-style: italic}
|
60 |
+
div.dup-log-file-list {font-family:monospace;}
|
61 |
+
div.dup-log-file-list a, span.dup-log{display: inline-block; white-space: nowrap; text-overflow: ellipsis; max-width: 375px; overflow:hidden}
|
62 |
+
div.dup-log-file-list span {color:green}
|
63 |
+
div.dup-opts-items {border:1px solid silver; background: #efefef; padding: 5px; border-radius: 4px; margin:2px 0px 10px -2px;}
|
64 |
+
label#dup-auto-refresh-lbl {display: inline-block;}
|
65 |
</style>
|
66 |
|
67 |
<script>
|