Example #1
0
$mu_newDomainHost = $mu_newDomain['host'];
$mu_oldDomainHost = $mu_oldDomain['host'];
$mu_newUrlPath = parse_url($_POST['url_new'], PHP_URL_PATH);
$mu_oldUrlPath = parse_url($_POST['url_old'], PHP_URL_PATH);
//Force a path for PATH_CURRENT_SITE
$mu_newUrlPath = empty($mu_newUrlPath) || $mu_newUrlPath == '/' ? '/' : rtrim($mu_newUrlPath, '/') . '/';
$mu_oldUrlPath = empty($mu_oldUrlPath) || $mu_oldUrlPath == '/' ? '/' : rtrim($mu_oldUrlPath, '/') . '/';
$mu_updates = @mysqli_query($dbh, "UPDATE `{$GLOBALS['FW_TABLEPREFIX']}blogs` SET domain = '{$mu_newDomainHost}' WHERE domain = '{$mu_oldDomainHost}'");
if ($mu_updates) {
    DUPX_Log::Info("Update MU table blogs: domain {$mu_newDomainHost} ");
} else {
    DUPX_Log::Info("UPDATE `{$GLOBALS['FW_TABLEPREFIX']}blogs` SET domain = '{$mu_newDomainHost}' WHERE domain = '{$mu_oldDomainHost}'");
}
/* ==============================
 * UPDATE WP-CONFIG FILE */
$config_file = DUPX_WPConfig::UpdateStep2();
//Create snapshots directory in order to
//compensate for permissions on some servers
if (!file_exists(DUPLICATOR_SSDIR_NAME)) {
    mkdir(DUPLICATOR_SSDIR_NAME, 0755);
}
$fp = fopen(DUPLICATOR_SSDIR_NAME . '/index.php', 'w');
fclose($fp);
/* ==============================
NOTICE TESTS */
DUPX_Log::Info("\n--------------------------------------");
DUPX_Log::Info("NOTICES");
DUPX_Log::Info("--------------------------------------");
$config_vars = array('WP_CONTENT_DIR', 'WP_CONTENT_URL', 'WPCACHEHOME', 'COOKIE_DOMAIN', 'WP_SITEURL', 'WP_HOME', 'WP_TEMP_DIR');
$config_items = DUPX_Util::search_list_values($config_vars, $config_file);
//Files:
    if ($zip->open($_POST['package_name']) === TRUE) {
        DUPX_Log::Info("EXTRACTING");
        if (!$zip->extractTo($target)) {
            DUPX_Log::Error(ERR_ZIPEXTRACTION);
        }
        $log = print_r($zip, true);
        $close_response = $zip->close();
        $log .= "COMPLETE: " . var_export($close_response, true);
        DUPX_Log::Info($log);
    } else {
        DUPX_Log::Error(ERR_ZIPOPEN);
    }
    $zip = null;
}
//CONFIG FILE RESETS
DUPX_WPConfig::UpdateStep1();
DUPX_ServerConfig::Reset();
//====================================================================================================
//DATABASE ROUTINES
//====================================================================================================
@chmod("{$root_path}/database.sql", 0777);
if (filesize("{$root_path}/database.sql") > 100000000) {
    DUPX_Log::Info("\nWARNING: Database Script is larger than 100MB this may lead to PHP memory allocation issues on some budget hosts.");
}
$sql_file = file_get_contents('database.sql', true);
if ($sql_file == false || strlen($sql_file) < 10) {
    $sql_file = file_get_contents('installer-data.sql', true);
    if ($sql_file == false || strlen($sql_file) < 10) {
        DUPX_Log::Info("ERROR: Unable to read from the extracted database.sql file .\nValidate the permissions and/or group-owner rights on directory '{$root_path}'\n");
    }
}