return $backupSiteUrl; } function processConfigAndDatabaseFile($databaseFileInZip) { global $wp_filesystem; $dbFileContent = $wp_filesystem->get_contents($databaseFileInZip); /* we don't want to nuke the curret database if if something went wrong with the above operation */ if (false === $dbFileContent) { wpa_backup_error('dbrest', sprintf(__('Cannot read <code>%s</code>'), $databaseFileInZip), true); } $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); /* and we cannot nuke the db if the connection failed now can we */ if (false === $conn) { wpa_backup_error('dbrest', __('database connection failed'), true); } mysql_select_db(DB_NAME, $conn); $query = mysql_query("SHOW TABLES", $conn); /* point of no return,if it fails after this you're royally boned ;) */ while ($fetch = mysql_fetch_array($query)) { mysql_query("Drop table `{$fetch[0]}`"); } flush(); $res = explode(";\n", $dbFileContent); foreach ($res as $query) { mysql_query($query, $conn); } mysql_close($conn); $backupSiteUrl = replaceSiteUrlFromDatabaseFile($databaseFileInZip); /* don't let the name fool you,it just returns the old site's url */ $currentSiteUrl = site_url(); $backupSiteUrl = untrailingslashit($backupSiteUrl); $currentSiteUrl = untrailingslashit($currentSiteUrl); wpa_safe_replace_wrapper($backupSiteUrl, $currentSiteUrl);
function processConfigAndDatabaseFile($databaseFileInZip) { global $wp_filesystem; $dbFileContent = $wp_filesystem->get_contents($databaseFileInZip); /* we don't want to nuke the curret database if if something went wrong with the above operation */ if (false === $dbFileContent) { wpa_backup_error('dbrest', sprintf(__('Cannot read <code>%s</code>'), $databaseFileInZip), true); } $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); /* and we cannot nuke the db if the connection failed now can we */ if (false === $conn) { wpa_backup_error('dbrest', __('database connection failed'), true); } mysql_select_db(DB_NAME, $conn); mysql_set_charset(DB_CHARSET, $conn); $res = explode(";\n", $dbFileContent); foreach ($res as $query) { mysql_query($query, $conn); } mysql_close($conn); $backupSiteUrl = replaceSiteUrlFromDatabaseFile($databaseFileInZip); /* don't let the name fool you,it just returns the old site's url */ $currentSiteUrl = site_url(); $backupSiteUrl = untrailingslashit($backupSiteUrl); $currentSiteUrl = untrailingslashit($currentSiteUrl); $report = wpa_safe_replace_wrapper($backupSiteUrl, $currentSiteUrl); return array('url' => $currentSiteUrl, 'report' => $report); }