/** * duplicator_package_build * Returns the package result status * * @return json json object of package results */ function duplicator_package_build() { header('Content-Type: application/json'); DUP_Util::CheckPermissions('export'); @set_time_limit(0); $errLevel = error_reporting(); error_reporting(E_ERROR); DUP_Util::InitSnapshotDirectory(); $Package = DUP_Package::GetActive(); if (!is_readable(DUPLICATOR_SSDIR_PATH_TMP . "/{$Package->ScanFile}")) { die("The scan result file was not found. Please run the scan step before building the package."); } $Package->Build(); //JSON:Debug Response //Pass = 1, Warn = 2, Fail = 3 $json = array(); $json['Status'] = 1; $json['Package'] = $Package; $json['Runtime'] = $Package->Runtime; $json['ExeSize'] = $Package->ExeSize; $json['ZipSize'] = $Package->ZipSize; $json_response = json_encode($json); error_reporting($errLevel); die($json_response); }
/** * Gets the system checks which are not required * @return array An array of system checks */ public static function GetChecks() { $checks = array(); //WEB SERVER $web_test1 = false; foreach ($GLOBALS['DUPLICATOR_SERVER_LIST'] as $value) { if (stristr($_SERVER['SERVER_SOFTWARE'], $value)) { $web_test1 = true; break; } } $checks['SRV']['WEB']['model'] = $web_test1; $checks['SRV']['WEB']['ALL'] = $web_test1 ? 'Good' : 'Warn'; //PHP SETTINGS $php_test1 = ini_get("open_basedir"); $php_test1 = empty($php_test1) ? true : false; $php_test2 = ini_get("max_execution_time"); $php_test2 = $php_test2 > DUPLICATOR_SCAN_TIMEOUT || (strcmp($php_test2, 'Off') == 0 || $php_test2 == 0) ? true : false; $php_test3 = function_exists('mysqli_connect'); $checks['SRV']['PHP']['openbase'] = $php_test1; $checks['SRV']['PHP']['maxtime'] = $php_test2; $checks['SRV']['PHP']['mysqli'] = $php_test3; $checks['SRV']['PHP']['ALL'] = $php_test1 && $php_test2 && $php_test3 ? 'Good' : 'Warn'; //WORDPRESS SETTINGS global $wp_version; $wp_test1 = version_compare($wp_version, DUPLICATOR_SCAN_MIN_WP) >= 0 ? true : false; //Core Files $files = array(); $files['wp-config.php'] = file_exists(DUP_Util::SafePath(DUPLICATOR_WPROOTPATH . '/wp-config.php')); $wp_test2 = $files['wp-config.php']; //Cache $Package = DUP_Package::GetActive(); $cache_path = DUP_Util::SafePath(WP_CONTENT_DIR) . '/cache'; $dirEmpty = DUP_Util::IsDirectoryEmpty($cache_path); $dirSize = DUP_Util::GetDirectorySize($cache_path); $cach_filtered = in_array($cache_path, explode(';', $Package->Archive->FilterDirs)); $wp_test3 = $cach_filtered || $dirEmpty || $dirSize < DUPLICATOR_SCAN_CACHESIZE ? true : false; $checks['SRV']['WP']['version'] = $wp_test1; $checks['SRV']['WP']['core'] = $wp_test2; $checks['SRV']['WP']['cache'] = $wp_test3; $checks['SRV']['WP']['ALL'] = $wp_test1 && $wp_test2 && $wp_test3 ? 'Good' : 'Warn'; return $checks; }
/** * Gets the system checks which are not required * @return array An array of system checks */ public static function GetChecks() { $checks = array(); //CHK-SRV-100: PHP SETTINGS $php_test1 = ini_get("open_basedir"); $php_test1 = empty($php_test1) ? true : false; $php_test2 = ini_get("max_execution_time"); $php_test2 = $php_test2 > DUPLICATOR_SCAN_TIMEOUT || strcmp($php_test2, 'Off') == 0 || $php_test2 == 0 ? 'Good' : 'Warn'; $checks['CHK-SRV-100'] = $php_test1 && $php_test2 ? 'Good' : 'Warn'; //CHK-SRV-101: WORDPRESS SETTINGS //Version global $wp_version; $version_test = version_compare($wp_version, DUPLICATOR_SCAN_MIN_WP) >= 0 ? true : false; //Cache $Package = DUP_Package::GetActive(); $cache_path = DUP_Util::SafePath(WP_CONTENT_DIR) . '/cache'; $dirEmpty = DUP_Util::IsDirectoryEmpty($cache_path); $dirSize = DUP_Util::GetDirectorySize($cache_path); $cach_filtered = in_array($cache_path, explode(';', $Package->Archive->FilterDirs)); $cache_test = $cach_filtered || $dirEmpty || $dirSize < DUPLICATOR_SCAN_CACHESIZE ? true : false; //Core Files $files = array(); $files['wp-config.php'] = file_exists(DUP_Util::SafePath(DUPLICATOR_WPROOTPATH . '/wp-config.php')); $files_test = $files['wp-config.php']; $checks['CHK-SRV-101'] = $files_test && $cache_test && $version_test ? 'Good' : 'Warn'; //CHK-SRV-102: WEB SERVER $servers = $GLOBALS['DUPLICATOR_SERVER_LIST']; $test = false; foreach ($servers as $value) { if (stristr($_SERVER['SERVER_SOFTWARE'], $value)) { $test = true; break; } } $checks['CHK-SRV-102'] = $test ? 'Good' : 'Warn'; //RESULTS $result = in_array('Warn', $checks); $checks['Success'] = !$result; return $checks; }
} } $txt_found = DUP_Util::__("File Found"); $txt_not_found = DUP_Util::__("File Removed"); $installer_files = DUP_Server::GetInstallerFiles(); switch ($_GET['action']) { case 'installer': $action_response = __('Installer file cleanup ran!'); $css_hide_msg = 'div.error {display:none}'; break; case 'legacy': DUP_Settings::LegacyClean(); $action_response = __('Legacy data removed.'); break; case 'tmp-cache': DUP_Package::TmpCleanup(true); $action_response = __('Build cache removed.'); break; } ?> <style type="text/css"> <?php echo isset($css_hide_msg) ? $css_hide_msg : ''; ?> div.success {color:#4A8254} div.failed {color:red} table.dup-reset-opts td:first-child {font-weight: bold} table.dup-reset-opts td {padding:10px} form#dup-settings-form {padding: 0px 10px 0px 10px} a.dup-fixed-btn {min-width: 150px; text-align: center}
require_once DUPLICATOR_PLUGIN_PATH . 'classes/package.php'; require_once DUPLICATOR_PLUGIN_PATH . 'classes/utility.php'; if (empty($_POST)) { //F5 Refresh Check $redirect = admin_url('admin.php?page=duplicator&tab=new1'); echo "<script>window.location.href = '{$redirect}'</script>"; exit; } global $wp_version; $Package = new DUP_Package(); if (isset($_POST['package-hash'])) { // If someone is trying to pass the hasn into us that is illegal so stop it immediately. die('Unauthorized'); } $Package->SaveActive($_POST); $Package = DUP_Package::GetActive(); $mysqldump_on = DUP_Settings::Get('package_mysqldump') && DUP_Database::GetMySqlDumpPath(); $mysqlcompat_on = isset($Package->Database->Compatible) && strlen($Package->Database->Compatible); $mysqlcompat_on = $mysqldump_on && $mysqlcompat_on ? true : false; $dbbuild_mode = $mysqldump_on ? 'mysqldump (fast)' : 'PHP (slow)'; $zip_check = DUP_Util::GetZipPath(); ?> <style> /* ============---------- PROGRESS ARES-CHECKS */ div#dup-progress-area {text-align:center; max-width:650px; min-height:200px; margin:0px auto 0px auto; padding:0px;} div.dup-progress-title {font-size:22px;padding:5px 0 20px 0; font-weight: bold} div#dup-msg-success {color:#18592A; padding:5px; text-align: left} div#dup-msg-success-subtitle {font-style: italic; margin:7px 0px} div#dup-msg-error {color:#A62426; padding:5px; max-width: 790px;}
//POST BACK $action_updated = null; if (isset($_POST['action'])) { $action_result = DUP_Settings::DeleteWPOption($_POST['action']); switch ($_POST['action']) { case 'duplicator_package_active': $action_response = __('Package settings have been reset.', 'duplicator'); break; } } DUP_Util::InitSnapshotDirectory(); $Package = DUP_Package::GetActive(); $package_hash = $Package->MakeHash(); $dup_tests = array(); $dup_tests = DUP_Server::GetRequirements(); $default_name = DUP_Package::GetDefaultName(); $view_state = DUP_UI::GetViewStateArray(); $ui_css_storage = isset($view_state['dup-pack-storage-panel']) && $view_state['dup-pack-storage-panel'] ? 'display:block' : 'display:none'; $ui_css_archive = isset($view_state['dup-pack-archive-panel']) && $view_state['dup-pack-archive-panel'] ? 'display:block' : 'display:none'; $ui_css_installer = isset($view_state['dup-pack-installer-panel']) && $view_state['dup-pack-installer-panel'] ? 'display:block' : 'display:none'; $dup_intaller_files = implode(", ", array_keys(DUP_Server::GetInstallerFiles())); $dbbuild_mode = DUP_Settings::Get('package_mysqldump') && DUP_Database::GetMySqlDumpPath() ? 'mysqldump' : 'PHP'; ?> <style> /* ----------------------------- REQUIREMENTS*/ div.dup-sys-section {margin:1px 0px 5px 0px} div.dup-sys-title {display:inline-block; width:250px; padding:1px; } div.dup-sys-title div {display:inline-block;float:right; } div.dup-sys-info {display:none; max-width: 98%; margin:4px 4px 12px 4px}
<?php require_once DUPLICATOR_PLUGIN_PATH . 'classes/package.php'; $Package = new DUP_Package(); $Package->SaveActive($_POST); $Package = $Package->GetActive(); $package_mysqldump = DUP_Settings::Get('package_mysqldump'); $mysqlDumpPath = DUP_Database::GetMySqlDumpPath(); $build_mode = $mysqlDumpPath && $package_mysqldump ? 'mysqldump (fast)' : 'PHP (slow)'; ?> <style> /* ----------------------------- PROGRESS ARES-CHECKS */ div#dup-progress-area {text-align:center; max-width:650px; min-height:200px; margin:0px auto 0px auto; padding:0px;} div#dup-msg-success {color:#18592A; padding:5px; text-align: left} div#dup-msg-success-subtitle {font-style: italic; margin:7px 0px} div#dup-msg-error {color:#A62426; padding:5px; max-width: 790px;} div#dup-msg-error-response-text { max-height:350px; overflow-y:scroll; border:1px solid silver; border-radius: 3px; padding:8px;background:#fff} div.dup-panel {margin-bottom: 25px} div.dup-scan-filter-status {display:inline; float: right; font-size:11px; margin-right:10px; color:#AF0000; font-style: italic} /* SERVER-CHECKS */ div.dup-scan-title {display:inline-block; padding:1px; font-weight: bold;} div.dup-scan-title a {display:inline-block; width:225px; padding:1px; } div.dup-scan-title div {display:inline-block; } div.dup-scan-info {display:none;} div.dup-scan-good {display:inline-block; color:green;font-weight: bold;} div.dup-scan-warn {display:inline-block; color:#AF0000;font-weight: bold;} span.dup-toggle {float:left; margin:0 2px 2px 0; } /*DATABASE*/
/** * Shows a display message in the wp-admin if any researved files are found * @return type void */ public static function ShowReservedFilesNotice() { $hide = isset($_REQUEST['page']) && $_REQUEST['page'] == 'duplicator-tools' ? true : false; $perms = current_user_can('install_plugins') && current_user_can('import'); if (!$perms || $hide) { return; } $metaKey = 'dup-wpnotice01'; if (isset($_GET[$metaKey]) && $_GET[$metaKey] == '1') { self::SaveViewState($metaKey, true); } if (!self::GetViewStateValue($metaKey, false)) { if (DUP_Package::RequiredFilesFound()) { $queryStr = $_SERVER['QUERY_STRING']; echo '<div class="updated"><p>'; printf("%s <br/> <a href='admin.php?page=duplicator-tools&tab=cleanup&action=installer'>%s</a> | <a href='?{$queryStr}&{$metaKey}=1'>%s</a>", __('Reserved Duplicator install file(s) still exsist in the root directory. Please delete these file(s) to avoid possible security issues.'), __('Remove file(s) now'), __('Dismiss this notice')); echo "</p></div>"; } else { self::SaveViewState($metaKey, true); } } }
<?php DUP_Util::CheckPermissions('manage_options'); global $wpdb; //COMMON HEADER DISPLAY $current_tab = isset($_REQUEST['tab']) ? esc_html($_REQUEST['tab']) : 'detail'; $package_id = isset($_REQUEST["id"]) ? $_REQUEST["id"] : 0; $package = DUP_Package::GetByID($package_id); $err_found = $package == null || $package->Status < 100; $err_link_pack = "Duplicator.Pack.DownloadPackageFile(3, {$package->ID});return false;"; $err_link_log = "<a target='_blank' href='#' onclick='{$err_link_pack}'>" . DUP_Util::__('Package Log') . '</a>'; $err_link_faq = '<a target="_blank" href="https://snapcreek.com/duplicator/docs/faqs-tech/">' . DUP_Util::__('FAQ Pages') . '</a>'; $err_link_ticket = '<a target="_blank" href="https://snapcreek.com/ticket/">' . DUP_Util::__('Help Ticket') . '</a>'; ?> <style> .narrow-input { width: 80px; } .wide-input {width: 400px; } table.form-table tr td { padding-top: 25px; } div.all-packages {float:right; margin-top: -30px; } div.all-packages a.add-new-h2 {font-size: 16px} </style> <div class="wrap"> <?php duplicator_header(DUP_Util::__("Package Details » {$package->Name}")); ?> <?php if ($err_found) { ?>