Version Description
- 2013-03-18 =
- Fixed: When javascript is disabled,submit button shows "Create Backup" but the plugin attempts to do a restore.
- Changed: The temporary directory location during the restore process from '/wp-content/' to '/wp-content/wpclone-temp/'.
Download this release
Release Info
| Developer | wpacademy |
| Plugin | |
| Version | 2.1.4 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.3 to 2.1.4
- lib/functions.php +1 -1
- lib/view.php +1 -2
- readme.txt +5 -1
- wpclone.php +1 -1
lib/functions.php
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
<?php
|
| 2 |
return str_replace("\\", "/", $path);
|
| 3 |
return rtrim(str_replace("//", "/", wpCloneSafePathMode($path)), '/') . '/';
|
| 4 |
return str_replace(rtrim(WPCLONE_ROOT, "/\\"), site_url(), $path);
|
| 5 |
return str_replace(site_url(), rtrim(WPCLONE_ROOT, "/\\"), $url);
|
| 6 |
global $wpdb;
|
| 7 |
$WPCLONE_DB_ICONV_IN = "UTF-8";
|
| 8 |
$WPCLONE_DB_ICONV_OUT = "ISO-8859-1//TRANSLIT";
|
| 9 |
$return = '';
|
| 10 |
// Get all of the tables
|
| 11 |
$tables = $wpdb->get_col('SHOW TABLES');
|
| 12 |
// Cycle through each provided table
|
| 13 |
foreach ($tables as $table) {
|
| 14 |
// First part of the output � remove the table
|
| 15 |
$result = $wpdb->get_results("SELECT * FROM {$table}", ARRAY_N);
|
| 16 |
$numberOfFields = count($result[0]);
|
| 17 |
$numberOfItems = count($result);
|
| 18 |
// Second part of the output � create table
|
| 19 |
$row2 = $wpdb->get_row("SHOW CREATE TABLE {$table}", ARRAY_N);
|
| 20 |
$return .= "\n\n" . $row2[1] . ";\n\n";
|
| 21 |
// Third part of the output � insert values into new table
|
| 22 |
for ($currentRowNumber = 0; $currentRowNumber < $numberOfItems; $currentRowNumber++) {
|
| 23 |
$row = $result[$currentRowNumber];
|
| 24 |
$query = "INSERT INTO {$table} VALUES(";
|
| 25 |
for ($j = 0; $j < $numberOfFields; $j++) {
|
| 26 |
$row[$j] = iconv($WPCLONE_DB_ICONV_IN, $WPCLONE_DB_ICONV_OUT, $row[$j]);
|
| 27 |
$query .= (empty($row[$j])) ? '"", ' : '"' . mysql_real_escape_string($row[$j]) . '", ';
|
| 28 |
}
|
| 29 |
$return .= substr($query, 0, -2) . ");\n";
|
| 30 |
}
|
| 31 |
$return .= "\n";
|
| 32 |
}
|
| 33 |
// Generate the filename for the sql file
|
| 34 |
$File_open = fopen($destination . '/database.sql', 'w+');
|
| 35 |
// Save the sql file
|
| 36 |
fwrite($File_open, $return);
|
| 37 |
//file close
|
| 38 |
fclose($File_open);
|
| 39 |
$wpdb->flush();
|
| 40 |
* @link http://davidwalsh.name/backup-mysql-database-php
|
| 41 |
*/
|
| 42 |
if ( false === $link ) {
|
| 43 |
wpa_backup_error('db', mysql_error() );
|
| 44 |
}
|
| 45 |
if ( false === $result ) {
|
| 46 |
wpa_backup_error('db', mysql_error() );
|
| 47 |
}
|
| 48 |
if ( false === $result ) {
|
| 49 |
wpa_backup_error('db', mysql_error() );
|
| 50 |
}
|
| 51 |
global $wpdb;
|
| 52 |
global $current_user;
|
| 53 |
$wpdb->insert($wpdb->prefix . "wpclone", array(
|
| 54 |
'backup_name' => $name,
|
| 55 |
'data_time' => current_time('mysql', get_option('gmt_offset')),
|
| 56 |
'creator' => $current_user->user_login,
|
| 57 |
'backup_size' => $size)
|
| 58 |
);
|
| 59 |
$wpdb->flush();
|
| 60 |
$folderToBeZipped = WPCLONE_DIR_BACKUP . 'wpclone_backup';
|
| 61 |
$destinationPath = $folderToBeZipped . '/' . basename(WPCLONE_WP_CONTENT);
|
| 62 |
$zipFileName = WPCLONE_DIR_BACKUP . $backupName . '.zip';
|
| 63 |
global $wp_filesystem;
|
| 64 |
|
| 65 |
/* create the backup directory and call the cleanup function if it failed to do so */
|
| 66 |
$dir = $wp_filesystem->mkdir( $folderToBeZipped );
|
| 67 |
if( is_wp_error($dir) ) {
|
| 68 |
wpa_backup_error ( 'file', $dir->get_error_message() . $folderToBeZipped );
|
| 69 |
}
|
| 70 |
/* copy wp-content directory into the newly created backup directory. call the cleanup function if it fails.
|
| 71 |
* (wpa_copy doesn't return anything at the moment)*/
|
| 72 |
$files = wpa_copy(WPCLONE_WP_CONTENT, $destinationPath);
|
| 73 |
if( is_wp_error($files) ) {
|
| 74 |
wpa_backup_error ( 'file', $files->get_error_message() );
|
| 75 |
}
|
| 76 |
wpa_save_prefix($folderToBeZipped);
|
| 77 |
/* error handler is called from within the db backup functions */
|
| 78 |
if ( $use_wpdb ) {
|
| 79 |
wpa_db_backup_wpdb( $folderToBeZipped );
|
| 80 |
} else {
|
| 81 |
wpa_db_backup_direct( $folderToBeZipped );
|
| 82 |
}
|
| 83 |
|
| 84 |
/* error haldler is called from within the wpa_zip function */
|
| 85 |
wpa_zip($zipFileName, $folderToBeZipped, $zipmode);
|
| 86 |
$zipSize = filesize($zipFileName);
|
| 87 |
$wp_filesystem->delete( $folderToBeZipped, true );
|
| 88 |
return array($backupName . '.zip', $zipSize);
|
| 89 |
global $wpdb;
|
| 90 |
$wp_backup = "{$wpdb->prefix}wpclone";
|
| 91 |
$deleteRow = $wpdb->get_row("SELECT * FROM {$wp_backup} WHERE id = '{$nm}'");
|
| 92 |
$wpdb->query("DELETE FROM {$wp_backup} WHERE id = '{$nm}' ");
|
| 93 |
if (file_exists(WPCLONE_DIR_BACKUP . $deleteRow->backup_name)) unlink(WPCLONE_DIR_BACKUP . $deleteRow->backup_name) or die ('unable to delete backup file.');
|
| 94 |
return $deleteRow;
|
| 95 |
$kilobyte = 1024;
|
| 96 |
$megabyte = $kilobyte * 1024;
|
| 97 |
$gigabyte = $megabyte * 1024;
|
| 98 |
$terabyte = $gigabyte * 1024;
|
| 99 |
if (($bytes >= 0) && ($bytes < $kilobyte)) {
|
| 100 |
return $bytes . ' B';
|
| 101 |
} elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) {
|
| 102 |
return round($bytes / $kilobyte, $precision) . ' KB';
|
| 103 |
} elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) {
|
| 104 |
return round($bytes / $megabyte, $precision) . ' MB';
|
| 105 |
} elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) {
|
| 106 |
return round($bytes / $gigabyte, $precision) . ' GB';
|
| 107 |
} elseif ($bytes >= $terabyte) {
|
| 108 |
return round($bytes / $terabyte, $precision) . ' TB';
|
| 109 |
} else {
|
| 110 |
return $bytes . ' B';
|
| 111 |
}
|
| 112 |
$fileContent = file_get_contents($databaseFile, true);
|
| 113 |
$pos = strpos($fileContent, 'siteurl') + 8;
|
| 114 |
$urlStartPos = strpos($fileContent, '"', $pos) + 1;
|
| 115 |
$urlEndPos = strpos($fileContent, '"', $urlStartPos);
|
| 116 |
$backupSiteUrl = substr($fileContent, $urlStartPos, $urlEndPos - $urlStartPos);
|
| 117 |
return $backupSiteUrl;
|
| 118 |
|
| 119 |
$dbFileContent = file_get_contents($databaseFileInZip);
|
| 120 |
/* we don't want to nuke the curret database if if something went wrong with the above operation */
|
| 121 |
if ( false === $dbFileContent ) {
|
| 122 |
wpa_backup_error( 'dbrest', sprintf ( __( 'Cannot read <code>%s</code>' ), $databaseFileInZip ) , true );
|
| 123 |
}
|
| 124 |
|
| 125 |
|
| 126 |
$conn = mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
| 127 |
/* and we cannot nuke the db if the connection failed now can we */
|
| 128 |
if ( false === $conn ) {
|
| 129 |
wpa_backup_error('dbrest', __( 'database connection failed' ), true );
|
| 130 |
}
|
| 131 |
|
| 132 |
mysql_select_db( DB_NAME, $conn);
|
| 133 |
|
| 134 |
$query = mysql_query("SHOW TABLES", $conn);
|
| 135 |
/* point of no return,if it fails after this you're royally boned ;) */
|
| 136 |
while (($fetch = mysql_fetch_array($query))) {
|
| 137 |
mysql_query("Drop table `{$fetch[0]}`");
|
| 138 |
}
|
| 139 |
flush();
|
| 140 |
|
| 141 |
$res = explode(";\n", $dbFileContent);
|
| 142 |
foreach ($res AS $query) {
|
| 143 |
mysql_query($query, $conn);
|
| 144 |
}
|
| 145 |
mysql_close($conn);
|
| 146 |
$backupSiteUrl = replaceSiteUrlFromDatabaseFile($databaseFileInZip); /* don't let the name fool you,it just returns the old site's url */
|
| 147 |
$currentSiteUrl = site_url();
|
| 148 |
$backupSiteUrl = untrailingslashit($backupSiteUrl);
|
| 149 |
$currentSiteUrl = untrailingslashit($currentSiteUrl);
|
| 150 |
wpa_safe_replace_wrapper ( $backupSiteUrl, $currentSiteUrl );
|
| 151 |
|
| 152 |
return $currentSiteUrl;
|
| 153 |
* @param type $search URL of the previous site.
|
| 154 |
* @param type $replace URL of the current site.
|
| 155 |
* @return type total time it took for the operation.
|
| 156 |
*/
|
| 157 |
if ( !function_exists( 'icit_srdb_replacer' ) && !function_exists( 'recursive_unserialize_replace' ) ) {
|
| 158 |
require_once 'icit_srdb_replacer.php';
|
| 159 |
}
|
| 160 |
$connection = @mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
| 161 |
$all_tables = array( );
|
| 162 |
@mysql_select_db( DB_NAME, $connection );
|
| 163 |
$all_tables_mysql = @mysql_query( 'SHOW TABLES', $connection );
|
| 164 |
if ( ! $all_tables_mysql ) {
|
| 165 |
wpa_backup_error( 'dbrest', mysql_error(), true );
|
| 166 |
} else {
|
| 167 |
while ( $table = mysql_fetch_array( $all_tables_mysql ) ) {
|
| 168 |
$all_tables[] = $table[ 0 ];
|
| 169 |
}
|
| 170 |
}
|
| 171 |
$report = icit_srdb_replacer( $connection, $search, $replace, $all_tables );
|
| 172 |
return $report;
|
| 173 |
wpa_cleanup( true );
|
| 174 |
if (!is_string($url) || '' == $url) {
|
| 175 |
wpa_backup_error( 'restore', sprintf( __( 'The provided URL (<code>%s<code>) is either not valid or empty' ), $url ), true );
|
| 176 |
}
|
| 177 |
|
| 178 |
$pathParts = pathinfo($url);
|
| 179 |
$zipFilename = wpa_fetch_file($url);
|
| 180 |
$result = wpa_unzip($zipFilename, WPCLONE_WP_CONTENT, $zipmode);
|
| 181 |
if ($result) {
|
| 182 |
$unzippedFolderPath = wpCloneSafePathMode( trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone_backup' );
|
| 183 |
if ( !file_exists( $unzippedFolderPath ) ) {
|
| 184 |
$unzippedFolderPath = wpCloneSafePathMode( trailingslashit( WPCLONE_WP_CONTENT ) . $pathParts['filename'] );
|
| 185 |
}
|
| 186 |
|
| 187 |
/* if we're here then the file extraction worked,but let's make doubly sure */
|
| 188 |
if( !is_dir( $unzippedFolderPath ) ) {
|
| 189 |
wpa_backup_error( 'restore', sprintf( __( 'Cannot find <code>%s<code>' ), $unzippedFolderPath ), true );
|
| 190 |
}
|
| 191 |
/* check the table prefixes */
|
| 192 |
$old_db_prefix = $unzippedFolderPath . '/prefix.txt';
|
| 193 |
$prefix = wpa_check_prefix($old_db_prefix);
|
| 194 |
if ($prefix) {
|
| 195 |
wpa_replace_prefix( $prefix );
|
| 196 |
}
|
| 197 |
/* import db */
|
| 198 |
$databaseFile = $unzippedFolderPath . '/database.sql';
|
| 199 |
$currentSiteUrl = processConfigAndDatabaseFile($databaseFile);
|
| 200 |
/* */
|
| 201 |
wpa_copy( $unzippedFolderPath, WPCLONE_ROOT );
|
| 202 |
global $wp_filesystem;
|
| 203 |
$wp_filesystem->delete( $unzippedFolderPath, true );
|
| 204 |
/* remove the zip file only if it was downloaded from an external location. */
|
| 205 |
$wptmp = explode('.', $zipFilename);
|
| 206 |
if ( in_array( 'tmp', $wptmp ) ) {
|
| 207 |
$wp_filesystem->delete( $zipFilename );
|
| 208 |
}
|
| 209 |
echo "<h1>Restore Successful!</h1>";
|
| 210 |
echo "Visit your restored site [ <a href='{$currentSiteUrl}' target=blank>here</a> ]<br><br>";
|
| 211 |
echo "<strong>You may need to re-save your permalink structure <a href='{$currentSiteUrl}/wp-admin/options-permalink.php' target=blank>Here</a></strong>";
|
| 212 |
} else {
|
| 213 |
echo "<h1>Restore unsuccessful!!!</h1>";
|
| 214 |
echo "Please try again.";
|
| 215 |
}
|
| 216 |
global $wpdb;
|
| 217 |
$prefix = $wpdb->prefix;
|
| 218 |
$file = $path . '/prefix.txt';
|
| 219 |
if ( is_dir($path) && is_writable($path) ) {
|
| 220 |
file_put_contents($file, $prefix);
|
| 221 |
}
|
| 222 |
* Checks to see whether the destination site's table prefix matches that of the origin site.old prefix is returned in case of a mismatch.
|
| 223 |
*
|
| 224 |
* @param type $file path to the prefix.txt file.
|
| 225 |
* @return type bool string
|
| 226 |
*/
|
| 227 |
global $wpdb;
|
| 228 |
$prefix = $wpdb->prefix;
|
| 229 |
if (file_exists($file) && is_readable($file)) {
|
| 230 |
$old_prefix = file_get_contents($file);
|
| 231 |
if ( $prefix !== $old_prefix ) {
|
| 232 |
return $old_prefix;
|
| 233 |
}
|
| 234 |
else {
|
| 235 |
return false;
|
| 236 |
}
|
| 237 |
}
|
| 238 |
return false;
|
| 239 |
* @since 2.0.6
|
| 240 |
*
|
| 241 |
* @param type $zipfile path to the zip file that needs to be extracted.
|
| 242 |
* @param type $path the place to where the file needs to be extracted.
|
| 243 |
* @return as false in the event of failure.
|
| 244 |
*/
|
| 245 |
if ( $zipmode ) {
|
| 246 |
if ( ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding') ) {
|
| 247 |
$previous_encoding = mb_internal_encoding();
|
| 248 |
mb_internal_encoding('ISO-8859-1');
|
| 249 |
}
|
| 250 |
define('PCLZIP_TEMPORARY_DIR', WPCLONE_DIR_BACKUP);
|
| 251 |
require_once ( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
| 252 |
$z = new PclZip($zipfile);
|
| 253 |
$files = $z->extract(PCLZIP_OPT_PATH, $path);
|
| 254 |
if ( isset($previous_encoding) ) mb_internal_encoding($previous_encoding);
|
| 255 |
if ( $files == 0 ) {
|
| 256 |
wpa_backup_error( 'pclunzip', $z->errorInfo(true), true );
|
| 257 |
}
|
| 258 |
return true;
|
| 259 |
}
|
| 260 |
else {
|
| 261 |
$z= unzip_file($zipfile, $path);
|
| 262 |
if (is_wp_error($z)) {
|
| 263 |
wpa_backup_error( 'unzip', $z->get_error_message(), true );
|
| 264 |
}
|
| 265 |
return true;
|
| 266 |
}
|
| 267 |
* @since 2.0.6
|
| 268 |
*
|
| 269 |
* @param type $name name of the zip file.
|
| 270 |
* @param type $file_list an array of files that needs to be archived.
|
| 271 |
*/
|
| 272 |
if ( $zipmode || (!in_array('ZipArchive', get_declared_classes()) || !class_exists('ZipArchive')) ) {
|
| 273 |
define('PCLZIP_TEMPORARY_DIR', WPCLONE_DIR_BACKUP);
|
| 274 |
require_once ( ABSPATH . 'wp-admin/includes/class-pclzip.php');
|
| 275 |
$z = new PclZip($zip_name);
|
| 276 |
$v_list = $z->create($folder, PCLZIP_OPT_REMOVE_PATH, WPCLONE_DIR_BACKUP);
|
| 277 |
if ($v_list == 0) {
|
| 278 |
wpa_backup_error( 'pclzip', $z->errorInfo(true) );
|
| 279 |
}
|
| 280 |
} else {
|
| 281 |
$z = new ZipArchive();
|
| 282 |
if ( true !== $z->open( $zip_name, ZIPARCHIVE::CREATE ) ) {
|
| 283 |
wpa_backup_error( 'zip', $z );
|
| 284 |
}
|
| 285 |
wpa_ziparc($z, $folder, WPCLONE_DIR_BACKUP);
|
| 286 |
$z->close();
|
| 287 |
}
|
| 288 |
$new_folder = str_replace($base, '', $dir);
|
| 289 |
$zip->addEmptyDir($new_folder);
|
| 290 |
foreach( glob( $dir . '/*' ) as $file ){
|
| 291 |
if( is_dir($file) ) {
|
| 292 |
wpa_ziparc($zip, $file, $base);
|
| 293 |
} else {
|
| 294 |
$new_file = str_replace( $base, '', $file );
|
| 295 |
$zip->addFile($file, $new_file);
|
| 296 |
}
|
| 297 |
}
|
| 298 |
* just a simple function to increase PHP limits.
|
| 299 |
* @since 2.0.6
|
| 300 |
*/
|
| 301 |
$time = isset( $_POST['maxexec'] ) && '' != $_POST['maxexec'] ? $_POST['maxexec'] : 900;
|
| 302 |
$mem = isset ( $_POST['maxmem'] ) && '' != $_POST['maxmem'] ? $_POST['maxmem'] . 'M' : '512M';
|
| 303 |
@ini_set('memory_limit', $mem);
|
| 304 |
@ini_set('max_execution_time', $time); //900 seconds = 15 minutes
|
| 305 |
* @since 2.0.6
|
| 306 |
*/
|
| 307 |
if (!empty($_REQUEST['del'])) {
|
| 308 |
wpa_remove_backup();
|
| 309 |
return true;
|
| 310 |
}
|
| 311 |
if (empty($_POST)) return false;
|
| 312 |
check_admin_referer('wpclone-submit');
|
| 313 |
$form_post = wp_nonce_url('admin.php?page=wp-clone', 'wpclone-submit');
|
| 314 |
$extra_fields = array('restore_from_url', 'maxmem', 'maxexec', 'zipmode', 'restoreBackup');
|
| 315 |
$type = '';
|
| 316 |
if ( false === ($creds = request_filesystem_credentials($form_post, $type, false, false, $extra_fields)) ){
|
| 317 |
return true;
|
| 318 |
}
|
| 319 |
if (!WP_Filesystem($creds)) {
|
| 320 |
request_filesystem_credentials($form_post, $type, true, false, $extra_fields);
|
| 321 |
return true;
|
| 322 |
}
|
| 323 |
wpa_bump_limits();
|
| 324 |
|
| 325 |
if (isset($_POST['createBackup'])) {
|
| 326 |
wpa_create_backup();
|
| 327 |
return true;
|
| 328 |
}
|
| 329 |
|
| 330 |
$zipmode = isset($_POST['zipmode']) ? true : false;
|
| 331 |
$url = isset($_POST['restoreBackup']) ? $_POST['restoreBackup'] : $_POST['restore_from_url'];
|
| 332 |
processRestoringBackup($url, $zipmode);
|
| 333 |
return true;
|
| 334 |
* @since 2.0.6
|
| 335 |
*/
|
| 336 |
global $wp_filesystem;
|
| 337 |
if (is_readable($source)) {
|
| 338 |
if (is_dir($source)) {
|
| 339 |
if (!strstr(wpCloneSafePathMode($source), rtrim(WPCLONE_DIR_BACKUP, "/\\"))) {
|
| 340 |
if (!file_exists($target)) {
|
| 341 |
$wp_filesystem->mkdir($target);
|
| 342 |
}
|
| 343 |
$d = dir($source);
|
| 344 |
while (FALSE !== ($entry = $d->read())) {
|
| 345 |
if ($entry == '.' || $entry == '..') {
|
| 346 |
continue;
|
| 347 |
}
|
| 348 |
$Entry = "{$source}/{$entry}";
|
| 349 |
if (is_dir($Entry)) {
|
| 350 |
wpa_copy($Entry, $target . '/' . $entry);
|
| 351 |
} else {
|
| 352 |
$wp_filesystem->copy($Entry, $target . '/' . $entry, true, FS_CHMOD_FILE);
|
| 353 |
}
|
| 354 |
}
|
| 355 |
$d->close();
|
| 356 |
}
|
| 357 |
}
|
| 358 |
else {
|
| 359 |
$wp_filesystem->copy($source, $target, true);
|
| 360 |
}
|
| 361 |
}
|
| 362 |
* @since 2.0.6
|
| 363 |
*/
|
| 364 |
$wpconfig = wpa_wpconfig_path();
|
| 365 |
if ( ! is_writable($wpconfig) ) {
|
| 366 |
wpa_backup_error('wpconfig', sprintf( __( "<code>%s</code> is not writable." ), $wpconfig ), true );
|
| 367 |
}
|
| 368 |
|
| 369 |
global $wp_filesystem;
|
| 370 |
$fileContent = file_get_contents($wpconfig);
|
| 371 |
$pos = strpos($fileContent, '$table_prefix');
|
| 372 |
$str = substr($fileContent, $pos, strpos($fileContent, PHP_EOL, $pos) - $pos);
|
| 373 |
$fileContent = str_replace($str, '$table_prefix = "' . $newPrefix . '";', $fileContent);
|
| 374 |
$wp_filesystem->put_contents($wpconfig, $fileContent, 0600);
|
| 375 |
* @since 2.0.6
|
| 376 |
*/
|
| 377 |
wpa_cleanup();
|
| 378 |
$use_wpdb = isset( $_POST['use_wpdb'] ) && 'true' == $_POST['use_wpdb'] ? true : false;
|
| 379 |
$backupName = wpa_backup_name();
|
| 380 |
$zipmode = isset($_POST['zipmode']) ? true : false;
|
| 381 |
list($zipFileName, $zipSize) = CreateWPFullBackupZip($backupName, $zipmode, $use_wpdb);
|
| 382 |
wpa_insert_data($zipFileName, $zipSize);
|
| 383 |
$backZipPath = convertPathIntoUrl(WPCLONE_DIR_BACKUP . $zipFileName);
|
| 384 |
$zipSize = bytesToSize($zipSize);
|
| 385 |
echo <<<EOF
|
| 386 |
<a href='{$backZipPath}'><span>{$backZipPath}</span></a> ( {$zipSize} ) |
|
| 387 |
<input type='hidden' name='backupUrl' class='backupUrl' value="{$backZipPath}" />
|
| 388 |
<a class='copy-button' href='#' data-clipboard-text='{$backZipPath}'>Copy URL</a> <br /><br />
|
| 389 |
(Copy that link and paste it into the "Restore URL" of your new WordPress installation to clone this site)
|
| 390 |
* @since 2.0.6
|
| 391 |
*/
|
| 392 |
$deleteRow = DeleteWPBackupZip($_REQUEST['del']);
|
| 393 |
echo <<<EOT
|
| 394 |
<h1>Deleted Successful!</h1> <br />
|
| 395 |
{$deleteRow->backup_name} <br />
|
| 396 |
File deleted from backup folder and database...
|
| 397 |
* @since 2.1.2
|
| 398 |
* copypasta from wp-load.php
|
| 399 |
* @return the path to wp-config.php
|
| 400 |
*/
|
| 401 |
$z = pathinfo($path);
|
| 402 |
if (file_exists(WPCLONE_DIR_BACKUP . $z['basename'])) {
|
| 403 |
return WPCLONE_DIR_BACKUP . $z['basename'];
|
| 404 |
}
|
| 405 |
else {
|
| 406 |
$url = download_url($path, 750);
|
| 407 |
if ( is_wp_error($url) ) wpa_backup_error( 'url', $url->get_error_message(), true );
|
| 408 |
return $url;
|
| 409 |
}
|
| 410 |
$backup_name = 'wpclone_backup_' . date( 'dS_M_Y_h-iA' ) . '_' . get_option( 'blogname' );
|
| 411 |
$backup_name = substr( str_replace( ' ', '', $backup_name ), 0, 40 );
|
| 412 |
$rand_str = substr( str_shuffle( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ), 0, 10 );
|
| 413 |
$backup_name = sanitize_file_name( $backup_name ) . '_' . $rand_str;
|
| 414 |
return $backup_name;
|
| 415 |
|
| 416 |
$backup_dir = $restore ? trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone_backup' : trailingslashit( WPCLONE_DIR_BACKUP ) . 'wpclone_backup';
|
| 417 |
if( $restore ) {
|
| 418 |
$url = isset($_POST['restoreBackup']) ? $_POST['restoreBackup'] : $_POST['restore_from_url'];
|
| 419 |
if ( !file_exists( $backup_dir ) ) {
|
| 420 |
$path = pathinfo( $url );
|
| 421 |
$backup_dir = trailingslashit( WPCLONE_WP_CONTENT ) . $path['filename'];
|
| 422 |
}
|
| 423 |
if( !file_exists( $backup_dir ) ) {
|
| 424 |
unset( $backup_dir );
|
| 425 |
}
|
| 426 |
}
|
| 427 |
switch ( $error ) :
|
| 428 |
/* during backup */
|
| 429 |
case 'file' :
|
| 430 |
$error = __( 'while copying files into the temp directory' );
|
| 431 |
break;
|
| 432 |
case 'db' :
|
| 433 |
$error = __( 'during the database backup' );
|
| 434 |
break;
|
| 435 |
case 'zip' :
|
| 436 |
$error = __( 'while creating the zip file using PHP\'s ZipArchive library' );
|
| 437 |
break;
|
| 438 |
case 'pclzip' :
|
| 439 |
$error = __( 'while creating the zip file using the PclZip library' );
|
| 440 |
break;
|
| 441 |
/* during restore */
|
| 442 |
case 'filerest' :
|
| 443 |
$error = __( 'while copying files from the temp directory into the wp-content directory' );
|
| 444 |
break;
|
| 445 |
case 'dbrest' :
|
| 446 |
$error = __( 'while cloning the database' );
|
| 447 |
break;
|
| 448 |
case 'unzip' :
|
| 449 |
$error = __( 'while extracting the zip file using WP\'s zip file extractor' );
|
| 450 |
break;
|
| 451 |
case 'pclunzip' :
|
| 452 |
$error = __( 'while extracting the zip file using the PclZip library' );
|
| 453 |
break;
|
| 454 |
case 'url' :
|
| 455 |
$error = __( 'while downloading the zip file' );
|
| 456 |
break;
|
| 457 |
case 'wpconfig' :
|
| 458 |
$error = __( 'while trying to modify the table prefix in the wp-config.php file' );
|
| 459 |
break;
|
| 460 |
/* and a catch all for the things that aren't covered above */
|
| 461 |
default :
|
| 462 |
$error = sprintf( __( 'during the %s process' ), $error );
|
| 463 |
endswitch;
|
| 464 |
|
| 465 |
echo '<div class="wpclone_notice updated">';
|
| 466 |
printf( __( 'The plugin encountered an error %s,the following error message was returned:</br>' ), $error );
|
| 467 |
echo '<div class="error">' . __( 'Error Message : ' ) . $data . '</div></br>';
|
| 468 |
if( isset( $backup_dir) ) {
|
| 469 |
printf( __( 'Temporary files created in <code>%s</code> will be deleted.' ), $backup_dir );
|
| 470 |
echo '</div>';
|
| 471 |
global $wp_filesystem;
|
| 472 |
$wp_filesystem->delete($backup_dir, true);
|
| 473 |
} else {
|
| 474 |
echo '</div>';
|
| 475 |
}
|
| 476 |
die;
|
| 477 |
$backup_dir = $restore ? trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone_backup' : trailingslashit( WPCLONE_DIR_BACKUP ) . 'wpclone_backup';
|
| 478 |
if ( file_exists( $backup_dir ) && is_dir( $backup_dir ) ) {
|
| 479 |
global $wp_filesystem;
|
| 480 |
$wp_filesystem->delete($backup_dir, true);
|
| 481 |
}
|
|
|
|
| 482 |
return str_replace("\\", "/", $path);
|
| 483 |
return rtrim(str_replace("//", "/", wpCloneSafePathMode($path)), '/') . '/';
|
| 484 |
return str_replace(rtrim(WPCLONE_ROOT, "/\\"), site_url(), $path);
|
| 485 |
return str_replace(site_url(), rtrim(WPCLONE_ROOT, "/\\"), $url);
|
| 486 |
global $wpdb;
|
| 487 |
$WPCLONE_DB_ICONV_IN = "UTF-8";
|
| 488 |
$WPCLONE_DB_ICONV_OUT = "ISO-8859-1//TRANSLIT";
|
| 489 |
$return = '';
|
| 490 |
// Get all of the tables
|
| 491 |
$tables = $wpdb->get_col('SHOW TABLES');
|
| 492 |
// Cycle through each provided table
|
| 493 |
foreach ($tables as $table) {
|
| 494 |
// First part of the output � remove the table
|
| 495 |
$result = $wpdb->get_results("SELECT * FROM {$table}", ARRAY_N);
|
| 496 |
$numberOfFields = count($result[0]);
|
| 497 |
$numberOfItems = count($result);
|
| 498 |
// Second part of the output � create table
|
| 499 |
$row2 = $wpdb->get_row("SHOW CREATE TABLE {$table}", ARRAY_N);
|
| 500 |
$return .= "\n\n" . $row2[1] . ";\n\n";
|
| 501 |
// Third part of the output � insert values into new table
|
| 502 |
for ($currentRowNumber = 0; $currentRowNumber < $numberOfItems; $currentRowNumber++) {
|
| 503 |
$row = $result[$currentRowNumber];
|
| 504 |
$query = "INSERT INTO {$table} VALUES(";
|
| 505 |
for ($j = 0; $j < $numberOfFields; $j++) {
|
| 506 |
$row[$j] = iconv($WPCLONE_DB_ICONV_IN, $WPCLONE_DB_ICONV_OUT, $row[$j]);
|
| 507 |
$query .= (empty($row[$j])) ? '"", ' : '"' . mysql_real_escape_string($row[$j]) . '", ';
|
| 508 |
}
|
| 509 |
$return .= substr($query, 0, -2) . ");\n";
|
| 510 |
}
|
| 511 |
$return .= "\n";
|
| 512 |
}
|
| 513 |
// Generate the filename for the sql file
|
| 514 |
$File_open = fopen($destination . '/database.sql', 'w+');
|
| 515 |
// Save the sql file
|
| 516 |
fwrite($File_open, $return);
|
| 517 |
//file close
|
| 518 |
fclose($File_open);
|
| 519 |
$wpdb->flush();
|
| 520 |
* @link http://davidwalsh.name/backup-mysql-database-php
|
| 521 |
*/
|
| 522 |
if ( false === $link ) {
|
| 523 |
wpa_backup_error('db', mysql_error() );
|
| 524 |
}
|
| 525 |
if ( false === $result ) {
|
| 526 |
wpa_backup_error('db', mysql_error() );
|
| 527 |
}
|
| 528 |
|
| 529 |
if ( false === $result ) {
|
| 530 |
wpa_backup_error('db', mysql_error() );
|
| 531 |
}
|
| 532 |
|
| 533 |
global $wpdb;
|
| 534 |
global $current_user;
|
| 535 |
$wpdb->insert($wpdb->prefix . "wpclone", array(
|
| 536 |
'backup_name' => $name,
|
| 537 |
'data_time' => current_time('mysql', get_option('gmt_offset')),
|
| 538 |
'creator' => $current_user->user_login,
|
| 539 |
'backup_size' => $size)
|
| 540 |
);
|
| 541 |
$wpdb->flush();
|
| 542 |
$folderToBeZipped = WPCLONE_DIR_BACKUP . 'wpclone_backup';
|
| 543 |
$destinationPath = $folderToBeZipped . '/' . basename(WPCLONE_WP_CONTENT);
|
| 544 |
$zipFileName = WPCLONE_DIR_BACKUP . $backupName . '.zip';
|
| 545 |
global $wp_filesystem;
|
| 546 |
|
| 547 |
/* create the backup directory and call the cleanup function if it failed to do so */
|
| 548 |
$dir = $wp_filesystem->mkdir( $folderToBeZipped );
|
| 549 |
if( is_wp_error($dir) ) {
|
| 550 |
wpa_backup_error ( 'file', $dir->get_error_message() . $folderToBeZipped );
|
| 551 |
}
|
| 552 |
/* copy wp-content directory into the newly created backup directory. call the cleanup function if it fails.
|
| 553 |
* (wpa_copy doesn't return anything at the moment)*/
|
| 554 |
$files = wpa_copy(WPCLONE_WP_CONTENT, $destinationPath);
|
| 555 |
if( is_wp_error($files) ) {
|
| 556 |
wpa_backup_error ( 'file', $files->get_error_message() );
|
| 557 |
}
|
| 558 |
wpa_save_prefix($folderToBeZipped);
|
| 559 |
/* error handler is called from within the db backup functions */
|
| 560 |
if ( $use_wpdb ) {
|
| 561 |
wpa_db_backup_wpdb( $folderToBeZipped );
|
| 562 |
} else {
|
| 563 |
wpa_db_backup_direct( $folderToBeZipped );
|
| 564 |
}
|
| 565 |
|
| 566 |
/* error haldler is called from within the wpa_zip function */
|
| 567 |
wpa_zip($zipFileName, $folderToBeZipped, $zipmode);
|
| 568 |
$zipSize = filesize($zipFileName);
|
| 569 |
$wp_filesystem->delete( $folderToBeZipped, true );
|
| 570 |
return array($backupName . '.zip', $zipSize);
|
| 571 |
global $wpdb;
|
| 572 |
$wp_backup = "{$wpdb->prefix}wpclone";
|
| 573 |
$deleteRow = $wpdb->get_row("SELECT * FROM {$wp_backup} WHERE id = '{$nm}'");
|
| 574 |
$wpdb->query("DELETE FROM {$wp_backup} WHERE id = '{$nm}' ");
|
| 575 |
if (file_exists(WPCLONE_DIR_BACKUP . $deleteRow->backup_name)) unlink(WPCLONE_DIR_BACKUP . $deleteRow->backup_name) or die ('unable to delete backup file.');
|
| 576 |
return $deleteRow;
|
| 577 |
$kilobyte = 1024;
|
| 578 |
$megabyte = $kilobyte * 1024;
|
| 579 |
$gigabyte = $megabyte * 1024;
|
| 580 |
$terabyte = $gigabyte * 1024;
|
| 581 |
if (($bytes >= 0) && ($bytes < $kilobyte)) {
|
| 582 |
return $bytes . ' B';
|
| 583 |
} elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) {
|
| 584 |
return round($bytes / $kilobyte, $precision) . ' KB';
|
| 585 |
} elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) {
|
| 586 |
return round($bytes / $megabyte, $precision) . ' MB';
|
| 587 |
} elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) {
|
| 588 |
return round($bytes / $gigabyte, $precision) . ' GB';
|
| 589 |
} elseif ($bytes >= $terabyte) {
|
| 590 |
return round($bytes / $terabyte, $precision) . ' TB';
|
| 591 |
} else {
|
| 592 |
return $bytes . ' B';
|
| 593 |
}
|
| 594 |
$fileContent = file_get_contents($databaseFile, true);
|
| 595 |
$pos = strpos($fileContent, 'siteurl') + 8;
|
| 596 |
$urlStartPos = strpos($fileContent, '"', $pos) + 1;
|
| 597 |
$urlEndPos = strpos($fileContent, '"', $urlStartPos);
|
| 598 |
$backupSiteUrl = substr($fileContent, $urlStartPos, $urlEndPos - $urlStartPos);
|
| 599 |
return $backupSiteUrl;
|
| 600 |
|
| 601 |
$dbFileContent = file_get_contents($databaseFileInZip);
|
| 602 |
/* we don't want to nuke the curret database if if something went wrong with the above operation */
|
| 603 |
if ( false === $dbFileContent ) {
|
| 604 |
wpa_backup_error( 'dbrest', sprintf ( __( 'Cannot read <code>%s</code>' ), $databaseFileInZip ) , true );
|
| 605 |
}
|
| 606 |
|
| 607 |
|
| 608 |
$conn = mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
| 609 |
/* and we cannot nuke the db if the connection failed now can we */
|
| 610 |
if ( false === $conn ) {
|
| 611 |
wpa_backup_error('dbrest', __( 'database connection failed' ), true );
|
| 612 |
}
|
| 613 |
|
| 614 |
mysql_select_db( DB_NAME, $conn);
|
| 615 |
|
| 616 |
$query = mysql_query("SHOW TABLES", $conn);
|
| 617 |
/* point of no return,if it fails after this you're royally boned ;) */
|
| 618 |
while (($fetch = mysql_fetch_array($query))) {
|
| 619 |
mysql_query("Drop table `{$fetch[0]}`");
|
| 620 |
}
|
| 621 |
flush();
|
| 622 |
|
| 623 |
$res = explode(";\n", $dbFileContent);
|
| 624 |
foreach ($res AS $query) {
|
| 625 |
mysql_query($query, $conn);
|
| 626 |
}
|
| 627 |
mysql_close($conn);
|
| 628 |
$backupSiteUrl = replaceSiteUrlFromDatabaseFile($databaseFileInZip); /* don't let the name fool you,it just returns the old site's url */
|
| 629 |
$currentSiteUrl = site_url();
|
| 630 |
$backupSiteUrl = untrailingslashit($backupSiteUrl);
|
| 631 |
$currentSiteUrl = untrailingslashit($currentSiteUrl);
|
| 632 |
wpa_safe_replace_wrapper ( $backupSiteUrl, $currentSiteUrl );
|
| 633 |
|
| 634 |
return $currentSiteUrl;
|
| 635 |
* @param type $search URL of the previous site.
|
| 636 |
* @param type $replace URL of the current site.
|
| 637 |
* @return type total time it took for the operation.
|
| 638 |
*/
|
| 639 |
if ( !function_exists( 'icit_srdb_replacer' ) && !function_exists( 'recursive_unserialize_replace' ) ) {
|
| 640 |
require_once 'icit_srdb_replacer.php';
|
| 641 |
}
|
| 642 |
$connection = @mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
| 643 |
$all_tables = array( );
|
| 644 |
@mysql_select_db( DB_NAME, $connection );
|
| 645 |
$all_tables_mysql = @mysql_query( 'SHOW TABLES', $connection );
|
| 646 |
if ( ! $all_tables_mysql ) {
|
| 647 |
wpa_backup_error( 'dbrest', mysql_error(), true );
|
| 648 |
} else {
|
| 649 |
while ( $table = mysql_fetch_array( $all_tables_mysql ) ) {
|
| 650 |
$all_tables[] = $table[ 0 ];
|
| 651 |
}
|
| 652 |
}
|
| 653 |
$report = icit_srdb_replacer( $connection, $search, $replace, $all_tables );
|
| 654 |
return $report;
|
| 655 |
wpa_cleanup( true );
|
| 656 |
if (!is_string($url) || '' == $url) {
|
| 657 |
wpa_backup_error( 'restore', sprintf( __( 'The provided URL "<code>%s</code>" is either not valid or empty' ), $url ), true );
|
| 658 |
}
|
| 659 |
|
| 660 |
global $wp_filesystem;
|
| 661 |
$temp_dir = trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone-temp';
|
| 662 |
$temp_dir_err = $wp_filesystem->mkdir( $temp_dir );
|
| 663 |
if ( is_wp_error($temp_dir_err) ) {
|
| 664 |
wpa_backup_error('dirrest', $temp_dir_err->get_error_message(), true );
|
| 665 |
}
|
| 666 |
$pathParts = pathinfo($url);
|
| 667 |
$zipFilename = wpa_fetch_file($url);
|
| 668 |
$result = wpa_unzip($zipFilename, $temp_dir, $zipmode);
|
| 669 |
if ($result) {
|
| 670 |
$unzippedFolderPath = wpCloneSafePathMode( trailingslashit( $temp_dir ) . 'wpclone_backup' );
|
| 671 |
if ( !file_exists( $unzippedFolderPath ) ) {
|
| 672 |
$unzippedFolderPath = wpCloneSafePathMode( trailingslashit( $temp_dir ) . $pathParts['filename'] );
|
| 673 |
}
|
| 674 |
|
| 675 |
/* if we're here then the file extraction worked,but let's make doubly sure */
|
| 676 |
if( !is_dir( $unzippedFolderPath ) ) {
|
| 677 |
wpa_backup_error( 'restore', sprintf( __( 'Cannot find <code>%s<code>' ), $unzippedFolderPath ), true );
|
| 678 |
}
|
| 679 |
/* check the table prefixes */
|
| 680 |
$old_db_prefix = $unzippedFolderPath . '/prefix.txt';
|
| 681 |
$prefix = wpa_check_prefix($old_db_prefix);
|
| 682 |
if ($prefix) {
|
| 683 |
wpa_replace_prefix( $prefix );
|
| 684 |
}
|
| 685 |
/* import db */
|
| 686 |
$databaseFile = $unzippedFolderPath . '/database.sql';
|
| 687 |
$currentSiteUrl = processConfigAndDatabaseFile($databaseFile);
|
| 688 |
/* */
|
| 689 |
wpa_copy( $unzippedFolderPath, WPCLONE_ROOT );
|
| 690 |
|
| 691 |
$wp_filesystem->delete( $temp_dir, true );
|
| 692 |
/* remove the zip file only if it was downloaded from an external location. */
|
| 693 |
$wptmp = explode('.', $zipFilename);
|
| 694 |
if ( in_array( 'tmp', $wptmp ) ) {
|
| 695 |
$wp_filesystem->delete( $zipFilename );
|
| 696 |
}
|
| 697 |
echo "<h1>Restore Successful!</h1>";
|
| 698 |
echo "Visit your restored site [ <a href='{$currentSiteUrl}' target=blank>here</a> ]<br><br>";
|
| 699 |
echo "<strong>You may need to re-save your permalink structure <a href='{$currentSiteUrl}/wp-admin/options-permalink.php' target=blank>Here</a></strong>";
|
| 700 |
} else {
|
| 701 |
echo "<h1>Restore unsuccessful!!!</h1>";
|
| 702 |
echo "Please try again.";
|
| 703 |
}
|
| 704 |
global $wpdb;
|
| 705 |
$prefix = $wpdb->prefix;
|
| 706 |
$file = $path . '/prefix.txt';
|
| 707 |
if ( is_dir($path) && is_writable($path) ) {
|
| 708 |
file_put_contents($file, $prefix);
|
| 709 |
}
|
| 710 |
* Checks to see whether the destination site's table prefix matches that of the origin site.old prefix is returned in case of a mismatch.
|
| 711 |
*
|
| 712 |
* @param type $file path to the prefix.txt file.
|
| 713 |
* @return type bool string
|
| 714 |
*/
|
| 715 |
global $wpdb;
|
| 716 |
$prefix = $wpdb->prefix;
|
| 717 |
if (file_exists($file) && is_readable($file)) {
|
| 718 |
$old_prefix = file_get_contents($file);
|
| 719 |
if ( $prefix !== $old_prefix ) {
|
| 720 |
return $old_prefix;
|
| 721 |
}
|
| 722 |
else {
|
| 723 |
return false;
|
| 724 |
}
|
| 725 |
}
|
| 726 |
return false;
|
| 727 |
* @since 2.0.6
|
| 728 |
*
|
| 729 |
* @param type $zipfile path to the zip file that needs to be extracted.
|
| 730 |
* @param type $path the place to where the file needs to be extracted.
|
| 731 |
* @return as false in the event of failure.
|
| 732 |
*/
|
| 733 |
if ( $zipmode ) {
|
| 734 |
if ( ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding') ) {
|
| 735 |
$previous_encoding = mb_internal_encoding();
|
| 736 |
mb_internal_encoding('ISO-8859-1');
|
| 737 |
}
|
| 738 |
define('PCLZIP_TEMPORARY_DIR', WPCLONE_DIR_BACKUP);
|
| 739 |
require_once ( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
| 740 |
$z = new PclZip($zipfile);
|
| 741 |
$files = $z->extract(PCLZIP_OPT_PATH, $path);
|
| 742 |
if ( isset($previous_encoding) ) mb_internal_encoding($previous_encoding);
|
| 743 |
if ( $files == 0 ) {
|
| 744 |
wpa_backup_error( 'pclunzip', $z->errorInfo(true), true );
|
| 745 |
}
|
| 746 |
return true;
|
| 747 |
}
|
| 748 |
else {
|
| 749 |
$z= unzip_file($zipfile, $path);
|
| 750 |
if (is_wp_error($z)) {
|
| 751 |
wpa_backup_error( 'unzip', $z->get_error_message(), true );
|
| 752 |
}
|
| 753 |
return true;
|
| 754 |
}
|
| 755 |
* @since 2.0.6
|
| 756 |
*
|
| 757 |
* @param type $name name of the zip file.
|
| 758 |
* @param type $file_list an array of files that needs to be archived.
|
| 759 |
*/
|
| 760 |
if ( $zipmode || (!in_array('ZipArchive', get_declared_classes()) || !class_exists('ZipArchive')) ) {
|
| 761 |
define('PCLZIP_TEMPORARY_DIR', WPCLONE_DIR_BACKUP);
|
| 762 |
require_once ( ABSPATH . 'wp-admin/includes/class-pclzip.php');
|
| 763 |
$z = new PclZip($zip_name);
|
| 764 |
$v_list = $z->create($folder, PCLZIP_OPT_REMOVE_PATH, WPCLONE_DIR_BACKUP);
|
| 765 |
if ($v_list == 0) {
|
| 766 |
wpa_backup_error( 'pclzip', $z->errorInfo(true) );
|
| 767 |
}
|
| 768 |
} else {
|
| 769 |
$z = new ZipArchive();
|
| 770 |
if ( true !== $z->open( $zip_name, ZIPARCHIVE::CREATE ) ) {
|
| 771 |
wpa_backup_error( 'zip', $z );
|
| 772 |
}
|
| 773 |
wpa_ziparc($z, $folder, WPCLONE_DIR_BACKUP);
|
| 774 |
$z->close();
|
| 775 |
}
|
| 776 |
$new_folder = str_replace($base, '', $dir);
|
| 777 |
$zip->addEmptyDir($new_folder);
|
| 778 |
foreach( glob( $dir . '/*' ) as $file ){
|
| 779 |
if( is_dir($file) ) {
|
| 780 |
wpa_ziparc($zip, $file, $base);
|
| 781 |
} else {
|
| 782 |
$new_file = str_replace( $base, '', $file );
|
| 783 |
$zip->addFile($file, $new_file);
|
| 784 |
}
|
| 785 |
}
|
| 786 |
* just a simple function to increase PHP limits.
|
| 787 |
* @since 2.0.6
|
| 788 |
*/
|
| 789 |
$time = isset( $_POST['maxexec'] ) && '' != $_POST['maxexec'] ? $_POST['maxexec'] : 900;
|
| 790 |
$mem = isset ( $_POST['maxmem'] ) && '' != $_POST['maxmem'] ? $_POST['maxmem'] . 'M' : '512M';
|
| 791 |
@ini_set('memory_limit', $mem);
|
| 792 |
@ini_set('max_execution_time', $time); //900 seconds = 15 minutes
|
| 793 |
* @since 2.0.6
|
| 794 |
*/
|
| 795 |
if (!empty($_REQUEST['del'])) {
|
| 796 |
wpa_remove_backup();
|
| 797 |
return true;
|
| 798 |
}
|
| 799 |
if (empty($_POST)) return false;
|
| 800 |
check_admin_referer('wpclone-submit');
|
| 801 |
$form_post = wp_nonce_url('admin.php?page=wp-clone', 'wpclone-submit');
|
| 802 |
$extra_fields = array('restore_from_url', 'maxmem', 'maxexec', 'zipmode', 'restoreBackup');
|
| 803 |
$type = '';
|
| 804 |
if ( false === ($creds = request_filesystem_credentials($form_post, $type, false, false, $extra_fields)) ){
|
| 805 |
return true;
|
| 806 |
}
|
| 807 |
if (!WP_Filesystem($creds)) {
|
| 808 |
request_filesystem_credentials($form_post, $type, true, false, $extra_fields);
|
| 809 |
return true;
|
| 810 |
}
|
| 811 |
wpa_bump_limits();
|
| 812 |
|
| 813 |
if (isset($_POST['createBackup'])) {
|
| 814 |
wpa_create_backup();
|
| 815 |
return true;
|
| 816 |
}
|
| 817 |
|
| 818 |
$zipmode = isset($_POST['zipmode']) ? true : false;
|
| 819 |
$url = isset($_POST['restoreBackup']) ? $_POST['restoreBackup'] : $_POST['restore_from_url'];
|
| 820 |
processRestoringBackup($url, $zipmode);
|
| 821 |
return true;
|
| 822 |
* @since 2.0.6
|
| 823 |
*/
|
| 824 |
global $wp_filesystem;
|
| 825 |
if (is_readable($source)) {
|
| 826 |
if (is_dir($source)) {
|
| 827 |
if (!strstr(wpCloneSafePathMode($source), rtrim(WPCLONE_DIR_BACKUP, "/\\"))) {
|
| 828 |
if (!file_exists($target)) {
|
| 829 |
$wp_filesystem->mkdir($target);
|
| 830 |
}
|
| 831 |
$d = dir($source);
|
| 832 |
while (FALSE !== ($entry = $d->read())) {
|
| 833 |
if ($entry == '.' || $entry == '..') {
|
| 834 |
continue;
|
| 835 |
}
|
| 836 |
$Entry = "{$source}/{$entry}";
|
| 837 |
if (is_dir($Entry)) {
|
| 838 |
wpa_copy($Entry, $target . '/' . $entry);
|
| 839 |
} else {
|
| 840 |
$wp_filesystem->copy($Entry, $target . '/' . $entry, true, FS_CHMOD_FILE);
|
| 841 |
}
|
| 842 |
}
|
| 843 |
$d->close();
|
| 844 |
}
|
| 845 |
}
|
| 846 |
else {
|
| 847 |
$wp_filesystem->copy($source, $target, true);
|
| 848 |
}
|
| 849 |
}
|
| 850 |
* @since 2.0.6
|
| 851 |
*/
|
| 852 |
$wpconfig = wpa_wpconfig_path();
|
| 853 |
if ( ! is_writable($wpconfig) ) {
|
| 854 |
wpa_backup_error('wpconfig', sprintf( __( "<code>%s</code> is not writable." ), $wpconfig ), true );
|
| 855 |
}
|
| 856 |
|
| 857 |
global $wp_filesystem;
|
| 858 |
$fileContent = file_get_contents($wpconfig);
|
| 859 |
$pos = strpos($fileContent, '$table_prefix');
|
| 860 |
$str = substr($fileContent, $pos, strpos($fileContent, PHP_EOL, $pos) - $pos);
|
| 861 |
$fileContent = str_replace($str, '$table_prefix = "' . $newPrefix . '";', $fileContent);
|
| 862 |
$wp_filesystem->put_contents($wpconfig, $fileContent, 0600);
|
| 863 |
* @since 2.0.6
|
| 864 |
*/
|
| 865 |
if ( !file_exists(WPCLONE_DIR_BACKUP) ) {
|
| 866 |
wpa_create_directory();
|
| 867 |
}
|
| 868 |
wpa_cleanup();
|
| 869 |
$use_wpdb = isset( $_POST['use_wpdb'] ) && 'true' == $_POST['use_wpdb'] ? true : false;
|
| 870 |
$backupName = wpa_backup_name();
|
| 871 |
$zipmode = isset($_POST['zipmode']) ? true : false;
|
| 872 |
list($zipFileName, $zipSize) = CreateWPFullBackupZip($backupName, $zipmode, $use_wpdb);
|
| 873 |
wpa_insert_data($zipFileName, $zipSize);
|
| 874 |
$backZipPath = convertPathIntoUrl(WPCLONE_DIR_BACKUP . $zipFileName);
|
| 875 |
$zipSize = bytesToSize($zipSize);
|
| 876 |
echo <<<EOF
|
| 877 |
<a href='{$backZipPath}'><span>{$backZipPath}</span></a> ( {$zipSize} ) |
|
| 878 |
<input type='hidden' name='backupUrl' class='backupUrl' value="{$backZipPath}" />
|
| 879 |
<a class='copy-button' href='#' data-clipboard-text='{$backZipPath}'>Copy URL</a> <br /><br />
|
| 880 |
(Copy that link and paste it into the "Restore URL" of your new WordPress installation to clone this site)
|
| 881 |
* @since 2.0.6
|
| 882 |
*/
|
| 883 |
$deleteRow = DeleteWPBackupZip($_REQUEST['del']);
|
| 884 |
echo <<<EOT
|
| 885 |
<h1>Deleted Successful!</h1> <br />
|
| 886 |
{$deleteRow->backup_name} <br />
|
| 887 |
File deleted from backup folder and database...
|
| 888 |
* @since 2.1.2
|
| 889 |
* copypasta from wp-load.php
|
| 890 |
* @return the path to wp-config.php
|
| 891 |
*/
|
| 892 |
$z = pathinfo($path);
|
| 893 |
if (file_exists(WPCLONE_DIR_BACKUP . $z['basename'])) {
|
| 894 |
return WPCLONE_DIR_BACKUP . $z['basename'];
|
| 895 |
}
|
| 896 |
else {
|
| 897 |
$url = download_url($path, 750);
|
| 898 |
if ( is_wp_error($url) ) wpa_backup_error( 'url', $url->get_error_message(), true );
|
| 899 |
return $url;
|
| 900 |
}
|
| 901 |
$backup_name = 'wpclone_backup_' . date( 'dS_M_Y_h-iA' ) . '_' . get_option( 'blogname' );
|
| 902 |
$backup_name = substr( str_replace( ' ', '', $backup_name ), 0, 40 );
|
| 903 |
$rand_str = substr( str_shuffle( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ), 0, 10 );
|
| 904 |
$backup_name = sanitize_file_name( $backup_name ) . '_' . $rand_str;
|
| 905 |
return $backup_name;
|
| 906 |
|
| 907 |
$temp_dir = $restore ? trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone-temp' : trailingslashit( WPCLONE_DIR_BACKUP ) . 'wpclone_backup';
|
| 908 |
|
| 909 |
if( !file_exists( $temp_dir ) ) {
|
| 910 |
unset($temp_dir);
|
| 911 |
}
|
| 912 |
switch ( $error ) :
|
| 913 |
/* during backup */
|
| 914 |
case 'file' :
|
| 915 |
$error = __( 'while copying files into the temp directory' );
|
| 916 |
break;
|
| 917 |
case 'db' :
|
| 918 |
$error = __( 'during the database backup' );
|
| 919 |
break;
|
| 920 |
case 'zip' :
|
| 921 |
$error = __( 'while creating the zip file using PHP\'s ZipArchive library' );
|
| 922 |
break;
|
| 923 |
case 'pclzip' :
|
| 924 |
$error = __( 'while creating the zip file using the PclZip library' );
|
| 925 |
break;
|
| 926 |
/* during restore */
|
| 927 |
case 'dirrest' :
|
| 928 |
$error = __( 'while creating the temp directory' );
|
| 929 |
break;
|
| 930 |
case 'filerest' :
|
| 931 |
$error = __( 'while copying files from the temp directory into the wp-content directory' );
|
| 932 |
break;
|
| 933 |
case 'dbrest' :
|
| 934 |
$error = __( 'while cloning the database' );
|
| 935 |
break;
|
| 936 |
case 'unzip' :
|
| 937 |
$error = __( 'while extracting the zip file using WP\'s zip file extractor' );
|
| 938 |
break;
|
| 939 |
case 'pclunzip' :
|
| 940 |
$error = __( 'while extracting the zip file using the PclZip library' );
|
| 941 |
break;
|
| 942 |
case 'url' :
|
| 943 |
$error = __( 'while downloading the zip file' );
|
| 944 |
break;
|
| 945 |
case 'wpconfig' :
|
| 946 |
$error = __( 'while trying to modify the table prefix in the wp-config.php file' );
|
| 947 |
break;
|
| 948 |
/* and a catch all for the things that aren't covered above */
|
| 949 |
default :
|
| 950 |
$error = sprintf( __( 'during the %s process' ), $error );
|
| 951 |
endswitch;
|
| 952 |
|
| 953 |
echo '<div class="wpclone_notice updated">';
|
| 954 |
printf( __( 'The plugin encountered an error %s,the following error message was returned:</br>' ), $error );
|
| 955 |
echo '<div class="error">' . __( 'Error Message : ' ) . $data . '</div></br>';
|
| 956 |
if( isset( $temp_dir ) ) {
|
| 957 |
printf( __( 'Temporary files created in <code>%s</code> will be deleted.' ), $temp_dir );
|
| 958 |
echo '</div>';
|
| 959 |
global $wp_filesystem;
|
| 960 |
$wp_filesystem->delete($temp_dir, true);
|
| 961 |
} else {
|
| 962 |
echo '</div>';
|
| 963 |
}
|
| 964 |
die;
|
| 965 |
$backup_dir = $restore ? trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone-temp' : trailingslashit( WPCLONE_DIR_BACKUP ) . 'wpclone_backup';
|
| 966 |
if ( file_exists( $backup_dir ) && is_dir( $backup_dir ) ) {
|
| 967 |
global $wp_filesystem;
|
| 968 |
$wp_filesystem->delete($backup_dir, true);
|
| 969 |
}
|
|
|
|
| 1 |
return str_replace("\\", "/", $path);
|
| 2 |
return rtrim(str_replace("//", "/", wpCloneSafePathMode($path)), '/') . '/';
|
| 3 |
return str_replace(rtrim(WPCLONE_ROOT, "/\\"), site_url(), $path);
|
| 4 |
return str_replace(site_url(), rtrim(WPCLONE_ROOT, "/\\"), $url);
|
| 5 |
global $wpdb;
|
| 6 |
$WPCLONE_DB_ICONV_IN = "UTF-8";
|
| 7 |
$WPCLONE_DB_ICONV_OUT = "ISO-8859-1//TRANSLIT";
|
| 8 |
$return = '';
|
| 9 |
// Get all of the tables
|
| 10 |
$tables = $wpdb->get_col('SHOW TABLES');
|
| 11 |
// Cycle through each provided table
|
| 12 |
foreach ($tables as $table) {
|
| 13 |
// First part of the output � remove the table
|
| 14 |
$result = $wpdb->get_results("SELECT * FROM {$table}", ARRAY_N);
|
| 15 |
$numberOfFields = count($result[0]);
|
| 16 |
$numberOfItems = count($result);
|
| 17 |
// Second part of the output � create table
|
| 18 |
$row2 = $wpdb->get_row("SHOW CREATE TABLE {$table}", ARRAY_N);
|
| 19 |
$return .= "\n\n" . $row2[1] . ";\n\n";
|
| 20 |
// Third part of the output � insert values into new table
|
| 21 |
for ($currentRowNumber = 0; $currentRowNumber < $numberOfItems; $currentRowNumber++) {
|
| 22 |
$row = $result[$currentRowNumber];
|
| 23 |
$query = "INSERT INTO {$table} VALUES(";
|
| 24 |
for ($j = 0; $j < $numberOfFields; $j++) {
|
| 25 |
$row[$j] = iconv($WPCLONE_DB_ICONV_IN, $WPCLONE_DB_ICONV_OUT, $row[$j]);
|
| 26 |
$query .= (empty($row[$j])) ? '"", ' : '"' . mysql_real_escape_string($row[$j]) . '", ';
|
| 27 |
}
|
| 28 |
$return .= substr($query, 0, -2) . ");\n";
|
| 29 |
}
|
| 30 |
$return .= "\n";
|
| 31 |
}
|
| 32 |
// Generate the filename for the sql file
|
| 33 |
$File_open = fopen($destination . '/database.sql', 'w+');
|
| 34 |
// Save the sql file
|
| 35 |
fwrite($File_open, $return);
|
| 36 |
//file close
|
| 37 |
fclose($File_open);
|
| 38 |
$wpdb->flush();
|
| 39 |
* @link http://davidwalsh.name/backup-mysql-database-php
|
| 40 |
*/
|
| 41 |
if ( false === $link ) {
|
| 42 |
wpa_backup_error('db', mysql_error() );
|
| 43 |
}
|
| 44 |
if ( false === $result ) {
|
| 45 |
wpa_backup_error('db', mysql_error() );
|
| 46 |
}
|
| 47 |
if ( false === $result ) {
|
| 48 |
wpa_backup_error('db', mysql_error() );
|
| 49 |
}
|
| 50 |
global $wpdb;
|
| 51 |
global $current_user;
|
| 52 |
$wpdb->insert($wpdb->prefix . "wpclone", array(
|
| 53 |
'backup_name' => $name,
|
| 54 |
'data_time' => current_time('mysql', get_option('gmt_offset')),
|
| 55 |
'creator' => $current_user->user_login,
|
| 56 |
'backup_size' => $size)
|
| 57 |
);
|
| 58 |
$wpdb->flush();
|
| 59 |
$folderToBeZipped = WPCLONE_DIR_BACKUP . 'wpclone_backup';
|
| 60 |
$destinationPath = $folderToBeZipped . '/' . basename(WPCLONE_WP_CONTENT);
|
| 61 |
$zipFileName = WPCLONE_DIR_BACKUP . $backupName . '.zip';
|
| 62 |
global $wp_filesystem;
|
| 63 |
|
| 64 |
/* create the backup directory and call the cleanup function if it failed to do so */
|
| 65 |
$dir = $wp_filesystem->mkdir( $folderToBeZipped );
|
| 66 |
if( is_wp_error($dir) ) {
|
| 67 |
wpa_backup_error ( 'file', $dir->get_error_message() . $folderToBeZipped );
|
| 68 |
}
|
| 69 |
/* copy wp-content directory into the newly created backup directory. call the cleanup function if it fails.
|
| 70 |
* (wpa_copy doesn't return anything at the moment)*/
|
| 71 |
$files = wpa_copy(WPCLONE_WP_CONTENT, $destinationPath);
|
| 72 |
if( is_wp_error($files) ) {
|
| 73 |
wpa_backup_error ( 'file', $files->get_error_message() );
|
| 74 |
}
|
| 75 |
wpa_save_prefix($folderToBeZipped);
|
| 76 |
/* error handler is called from within the db backup functions */
|
| 77 |
if ( $use_wpdb ) {
|
| 78 |
wpa_db_backup_wpdb( $folderToBeZipped );
|
| 79 |
} else {
|
| 80 |
wpa_db_backup_direct( $folderToBeZipped );
|
| 81 |
}
|
| 82 |
|
| 83 |
/* error haldler is called from within the wpa_zip function */
|
| 84 |
wpa_zip($zipFileName, $folderToBeZipped, $zipmode);
|
| 85 |
$zipSize = filesize($zipFileName);
|
| 86 |
$wp_filesystem->delete( $folderToBeZipped, true );
|
| 87 |
return array($backupName . '.zip', $zipSize);
|
| 88 |
global $wpdb;
|
| 89 |
$wp_backup = "{$wpdb->prefix}wpclone";
|
| 90 |
$deleteRow = $wpdb->get_row("SELECT * FROM {$wp_backup} WHERE id = '{$nm}'");
|
| 91 |
$wpdb->query("DELETE FROM {$wp_backup} WHERE id = '{$nm}' ");
|
| 92 |
if (file_exists(WPCLONE_DIR_BACKUP . $deleteRow->backup_name)) unlink(WPCLONE_DIR_BACKUP . $deleteRow->backup_name) or die ('unable to delete backup file.');
|
| 93 |
return $deleteRow;
|
| 94 |
$kilobyte = 1024;
|
| 95 |
$megabyte = $kilobyte * 1024;
|
| 96 |
$gigabyte = $megabyte * 1024;
|
| 97 |
$terabyte = $gigabyte * 1024;
|
| 98 |
if (($bytes >= 0) && ($bytes < $kilobyte)) {
|
| 99 |
return $bytes . ' B';
|
| 100 |
} elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) {
|
| 101 |
return round($bytes / $kilobyte, $precision) . ' KB';
|
| 102 |
} elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) {
|
| 103 |
return round($bytes / $megabyte, $precision) . ' MB';
|
| 104 |
} elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) {
|
| 105 |
return round($bytes / $gigabyte, $precision) . ' GB';
|
| 106 |
} elseif ($bytes >= $terabyte) {
|
| 107 |
return round($bytes / $terabyte, $precision) . ' TB';
|
| 108 |
} else {
|
| 109 |
return $bytes . ' B';
|
| 110 |
}
|
| 111 |
$fileContent = file_get_contents($databaseFile, true);
|
| 112 |
$pos = strpos($fileContent, 'siteurl') + 8;
|
| 113 |
$urlStartPos = strpos($fileContent, '"', $pos) + 1;
|
| 114 |
$urlEndPos = strpos($fileContent, '"', $urlStartPos);
|
| 115 |
$backupSiteUrl = substr($fileContent, $urlStartPos, $urlEndPos - $urlStartPos);
|
| 116 |
return $backupSiteUrl;
|
| 117 |
|
| 118 |
$dbFileContent = file_get_contents($databaseFileInZip);
|
| 119 |
/* we don't want to nuke the curret database if if something went wrong with the above operation */
|
| 120 |
if ( false === $dbFileContent ) {
|
| 121 |
wpa_backup_error( 'dbrest', sprintf ( __( 'Cannot read <code>%s</code>' ), $databaseFileInZip ) , true );
|
| 122 |
}
|
| 123 |
|
| 124 |
|
| 125 |
$conn = mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
| 126 |
/* and we cannot nuke the db if the connection failed now can we */
|
| 127 |
if ( false === $conn ) {
|
| 128 |
wpa_backup_error('dbrest', __( 'database connection failed' ), true );
|
| 129 |
}
|
| 130 |
|
| 131 |
mysql_select_db( DB_NAME, $conn);
|
| 132 |
|
| 133 |
$query = mysql_query("SHOW TABLES", $conn);
|
| 134 |
/* point of no return,if it fails after this you're royally boned ;) */
|
| 135 |
while (($fetch = mysql_fetch_array($query))) {
|
| 136 |
mysql_query("Drop table `{$fetch[0]}`");
|
| 137 |
}
|
| 138 |
flush();
|
| 139 |
|
| 140 |
$res = explode(";\n", $dbFileContent);
|
| 141 |
foreach ($res AS $query) {
|
| 142 |
mysql_query($query, $conn);
|
| 143 |
}
|
| 144 |
mysql_close($conn);
|
| 145 |
$backupSiteUrl = replaceSiteUrlFromDatabaseFile($databaseFileInZip); /* don't let the name fool you,it just returns the old site's url */
|
| 146 |
$currentSiteUrl = site_url();
|
| 147 |
$backupSiteUrl = untrailingslashit($backupSiteUrl);
|
| 148 |
$currentSiteUrl = untrailingslashit($currentSiteUrl);
|
| 149 |
wpa_safe_replace_wrapper ( $backupSiteUrl, $currentSiteUrl );
|
| 150 |
|
| 151 |
return $currentSiteUrl;
|
| 152 |
* @param type $search URL of the previous site.
|
| 153 |
* @param type $replace URL of the current site.
|
| 154 |
* @return type total time it took for the operation.
|
| 155 |
*/
|
| 156 |
if ( !function_exists( 'icit_srdb_replacer' ) && !function_exists( 'recursive_unserialize_replace' ) ) {
|
| 157 |
require_once 'icit_srdb_replacer.php';
|
| 158 |
}
|
| 159 |
$connection = @mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
| 160 |
$all_tables = array( );
|
| 161 |
@mysql_select_db( DB_NAME, $connection );
|
| 162 |
$all_tables_mysql = @mysql_query( 'SHOW TABLES', $connection );
|
| 163 |
if ( ! $all_tables_mysql ) {
|
| 164 |
wpa_backup_error( 'dbrest', mysql_error(), true );
|
| 165 |
} else {
|
| 166 |
while ( $table = mysql_fetch_array( $all_tables_mysql ) ) {
|
| 167 |
$all_tables[] = $table[ 0 ];
|
| 168 |
}
|
| 169 |
}
|
| 170 |
$report = icit_srdb_replacer( $connection, $search, $replace, $all_tables );
|
| 171 |
return $report;
|
| 172 |
wpa_cleanup( true );
|
| 173 |
if (!is_string($url) || '' == $url) {
|
| 174 |
wpa_backup_error( 'restore', sprintf( __( 'The provided URL (<code>%s<code>) is either not valid or empty' ), $url ), true );
|
| 175 |
}
|
| 176 |
|
| 177 |
$pathParts = pathinfo($url);
|
| 178 |
$zipFilename = wpa_fetch_file($url);
|
| 179 |
$result = wpa_unzip($zipFilename, WPCLONE_WP_CONTENT, $zipmode);
|
| 180 |
if ($result) {
|
| 181 |
$unzippedFolderPath = wpCloneSafePathMode( trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone_backup' );
|
| 182 |
if ( !file_exists( $unzippedFolderPath ) ) {
|
| 183 |
$unzippedFolderPath = wpCloneSafePathMode( trailingslashit( WPCLONE_WP_CONTENT ) . $pathParts['filename'] );
|
| 184 |
}
|
| 185 |
|
| 186 |
/* if we're here then the file extraction worked,but let's make doubly sure */
|
| 187 |
if( !is_dir( $unzippedFolderPath ) ) {
|
| 188 |
wpa_backup_error( 'restore', sprintf( __( 'Cannot find <code>%s<code>' ), $unzippedFolderPath ), true );
|
| 189 |
}
|
| 190 |
/* check the table prefixes */
|
| 191 |
$old_db_prefix = $unzippedFolderPath . '/prefix.txt';
|
| 192 |
$prefix = wpa_check_prefix($old_db_prefix);
|
| 193 |
if ($prefix) {
|
| 194 |
wpa_replace_prefix( $prefix );
|
| 195 |
}
|
| 196 |
/* import db */
|
| 197 |
$databaseFile = $unzippedFolderPath . '/database.sql';
|
| 198 |
$currentSiteUrl = processConfigAndDatabaseFile($databaseFile);
|
| 199 |
/* */
|
| 200 |
wpa_copy( $unzippedFolderPath, WPCLONE_ROOT );
|
| 201 |
global $wp_filesystem;
|
| 202 |
$wp_filesystem->delete( $unzippedFolderPath, true );
|
| 203 |
/* remove the zip file only if it was downloaded from an external location. */
|
| 204 |
$wptmp = explode('.', $zipFilename);
|
| 205 |
if ( in_array( 'tmp', $wptmp ) ) {
|
| 206 |
$wp_filesystem->delete( $zipFilename );
|
| 207 |
}
|
| 208 |
echo "<h1>Restore Successful!</h1>";
|
| 209 |
echo "Visit your restored site [ <a href='{$currentSiteUrl}' target=blank>here</a> ]<br><br>";
|
| 210 |
echo "<strong>You may need to re-save your permalink structure <a href='{$currentSiteUrl}/wp-admin/options-permalink.php' target=blank>Here</a></strong>";
|
| 211 |
} else {
|
| 212 |
echo "<h1>Restore unsuccessful!!!</h1>";
|
| 213 |
echo "Please try again.";
|
| 214 |
}
|
| 215 |
global $wpdb;
|
| 216 |
$prefix = $wpdb->prefix;
|
| 217 |
$file = $path . '/prefix.txt';
|
| 218 |
if ( is_dir($path) && is_writable($path) ) {
|
| 219 |
file_put_contents($file, $prefix);
|
| 220 |
}
|
| 221 |
* Checks to see whether the destination site's table prefix matches that of the origin site.old prefix is returned in case of a mismatch.
|
| 222 |
*
|
| 223 |
* @param type $file path to the prefix.txt file.
|
| 224 |
* @return type bool string
|
| 225 |
*/
|
| 226 |
global $wpdb;
|
| 227 |
$prefix = $wpdb->prefix;
|
| 228 |
if (file_exists($file) && is_readable($file)) {
|
| 229 |
$old_prefix = file_get_contents($file);
|
| 230 |
if ( $prefix !== $old_prefix ) {
|
| 231 |
return $old_prefix;
|
| 232 |
}
|
| 233 |
else {
|
| 234 |
return false;
|
| 235 |
}
|
| 236 |
}
|
| 237 |
return false;
|
| 238 |
* @since 2.0.6
|
| 239 |
*
|
| 240 |
* @param type $zipfile path to the zip file that needs to be extracted.
|
| 241 |
* @param type $path the place to where the file needs to be extracted.
|
| 242 |
* @return as false in the event of failure.
|
| 243 |
*/
|
| 244 |
if ( $zipmode ) {
|
| 245 |
if ( ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding') ) {
|
| 246 |
$previous_encoding = mb_internal_encoding();
|
| 247 |
mb_internal_encoding('ISO-8859-1');
|
| 248 |
}
|
| 249 |
define('PCLZIP_TEMPORARY_DIR', WPCLONE_DIR_BACKUP);
|
| 250 |
require_once ( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
| 251 |
$z = new PclZip($zipfile);
|
| 252 |
$files = $z->extract(PCLZIP_OPT_PATH, $path);
|
| 253 |
if ( isset($previous_encoding) ) mb_internal_encoding($previous_encoding);
|
| 254 |
if ( $files == 0 ) {
|
| 255 |
wpa_backup_error( 'pclunzip', $z->errorInfo(true), true );
|
| 256 |
}
|
| 257 |
return true;
|
| 258 |
}
|
| 259 |
else {
|
| 260 |
$z= unzip_file($zipfile, $path);
|
| 261 |
if (is_wp_error($z)) {
|
| 262 |
wpa_backup_error( 'unzip', $z->get_error_message(), true );
|
| 263 |
}
|
| 264 |
return true;
|
| 265 |
}
|
| 266 |
* @since 2.0.6
|
| 267 |
*
|
| 268 |
* @param type $name name of the zip file.
|
| 269 |
* @param type $file_list an array of files that needs to be archived.
|
| 270 |
*/
|
| 271 |
if ( $zipmode || (!in_array('ZipArchive', get_declared_classes()) || !class_exists('ZipArchive')) ) {
|
| 272 |
define('PCLZIP_TEMPORARY_DIR', WPCLONE_DIR_BACKUP);
|
| 273 |
require_once ( ABSPATH . 'wp-admin/includes/class-pclzip.php');
|
| 274 |
$z = new PclZip($zip_name);
|
| 275 |
$v_list = $z->create($folder, PCLZIP_OPT_REMOVE_PATH, WPCLONE_DIR_BACKUP);
|
| 276 |
if ($v_list == 0) {
|
| 277 |
wpa_backup_error( 'pclzip', $z->errorInfo(true) );
|
| 278 |
}
|
| 279 |
} else {
|
| 280 |
$z = new ZipArchive();
|
| 281 |
if ( true !== $z->open( $zip_name, ZIPARCHIVE::CREATE ) ) {
|
| 282 |
wpa_backup_error( 'zip', $z );
|
| 283 |
}
|
| 284 |
wpa_ziparc($z, $folder, WPCLONE_DIR_BACKUP);
|
| 285 |
$z->close();
|
| 286 |
}
|
| 287 |
$new_folder = str_replace($base, '', $dir);
|
| 288 |
$zip->addEmptyDir($new_folder);
|
| 289 |
foreach( glob( $dir . '/*' ) as $file ){
|
| 290 |
if( is_dir($file) ) {
|
| 291 |
wpa_ziparc($zip, $file, $base);
|
| 292 |
} else {
|
| 293 |
$new_file = str_replace( $base, '', $file );
|
| 294 |
$zip->addFile($file, $new_file);
|
| 295 |
}
|
| 296 |
}
|
| 297 |
* just a simple function to increase PHP limits.
|
| 298 |
* @since 2.0.6
|
| 299 |
*/
|
| 300 |
$time = isset( $_POST['maxexec'] ) && '' != $_POST['maxexec'] ? $_POST['maxexec'] : 900;
|
| 301 |
$mem = isset ( $_POST['maxmem'] ) && '' != $_POST['maxmem'] ? $_POST['maxmem'] . 'M' : '512M';
|
| 302 |
@ini_set('memory_limit', $mem);
|
| 303 |
@ini_set('max_execution_time', $time); //900 seconds = 15 minutes
|
| 304 |
* @since 2.0.6
|
| 305 |
*/
|
| 306 |
if (!empty($_REQUEST['del'])) {
|
| 307 |
wpa_remove_backup();
|
| 308 |
return true;
|
| 309 |
}
|
| 310 |
if (empty($_POST)) return false;
|
| 311 |
check_admin_referer('wpclone-submit');
|
| 312 |
$form_post = wp_nonce_url('admin.php?page=wp-clone', 'wpclone-submit');
|
| 313 |
$extra_fields = array('restore_from_url', 'maxmem', 'maxexec', 'zipmode', 'restoreBackup');
|
| 314 |
$type = '';
|
| 315 |
if ( false === ($creds = request_filesystem_credentials($form_post, $type, false, false, $extra_fields)) ){
|
| 316 |
return true;
|
| 317 |
}
|
| 318 |
if (!WP_Filesystem($creds)) {
|
| 319 |
request_filesystem_credentials($form_post, $type, true, false, $extra_fields);
|
| 320 |
return true;
|
| 321 |
}
|
| 322 |
wpa_bump_limits();
|
| 323 |
|
| 324 |
if (isset($_POST['createBackup'])) {
|
| 325 |
wpa_create_backup();
|
| 326 |
return true;
|
| 327 |
}
|
| 328 |
|
| 329 |
$zipmode = isset($_POST['zipmode']) ? true : false;
|
| 330 |
$url = isset($_POST['restoreBackup']) ? $_POST['restoreBackup'] : $_POST['restore_from_url'];
|
| 331 |
processRestoringBackup($url, $zipmode);
|
| 332 |
return true;
|
| 333 |
* @since 2.0.6
|
| 334 |
*/
|
| 335 |
global $wp_filesystem;
|
| 336 |
if (is_readable($source)) {
|
| 337 |
if (is_dir($source)) {
|
| 338 |
if (!strstr(wpCloneSafePathMode($source), rtrim(WPCLONE_DIR_BACKUP, "/\\"))) {
|
| 339 |
if (!file_exists($target)) {
|
| 340 |
$wp_filesystem->mkdir($target);
|
| 341 |
}
|
| 342 |
$d = dir($source);
|
| 343 |
while (FALSE !== ($entry = $d->read())) {
|
| 344 |
if ($entry == '.' || $entry == '..') {
|
| 345 |
continue;
|
| 346 |
}
|
| 347 |
$Entry = "{$source}/{$entry}";
|
| 348 |
if (is_dir($Entry)) {
|
| 349 |
wpa_copy($Entry, $target . '/' . $entry);
|
| 350 |
} else {
|
| 351 |
$wp_filesystem->copy($Entry, $target . '/' . $entry, true, FS_CHMOD_FILE);
|
| 352 |
}
|
| 353 |
}
|
| 354 |
$d->close();
|
| 355 |
}
|
| 356 |
}
|
| 357 |
else {
|
| 358 |
$wp_filesystem->copy($source, $target, true);
|
| 359 |
}
|
| 360 |
}
|
| 361 |
* @since 2.0.6
|
| 362 |
*/
|
| 363 |
$wpconfig = wpa_wpconfig_path();
|
| 364 |
if ( ! is_writable($wpconfig) ) {
|
| 365 |
wpa_backup_error('wpconfig', sprintf( __( "<code>%s</code> is not writable." ), $wpconfig ), true );
|
| 366 |
}
|
| 367 |
|
| 368 |
global $wp_filesystem;
|
| 369 |
$fileContent = file_get_contents($wpconfig);
|
| 370 |
$pos = strpos($fileContent, '$table_prefix');
|
| 371 |
$str = substr($fileContent, $pos, strpos($fileContent, PHP_EOL, $pos) - $pos);
|
| 372 |
$fileContent = str_replace($str, '$table_prefix = "' . $newPrefix . '";', $fileContent);
|
| 373 |
$wp_filesystem->put_contents($wpconfig, $fileContent, 0600);
|
| 374 |
* @since 2.0.6
|
| 375 |
*/
|
| 376 |
wpa_cleanup();
|
| 377 |
$use_wpdb = isset( $_POST['use_wpdb'] ) && 'true' == $_POST['use_wpdb'] ? true : false;
|
| 378 |
$backupName = wpa_backup_name();
|
| 379 |
$zipmode = isset($_POST['zipmode']) ? true : false;
|
| 380 |
list($zipFileName, $zipSize) = CreateWPFullBackupZip($backupName, $zipmode, $use_wpdb);
|
| 381 |
wpa_insert_data($zipFileName, $zipSize);
|
| 382 |
$backZipPath = convertPathIntoUrl(WPCLONE_DIR_BACKUP . $zipFileName);
|
| 383 |
$zipSize = bytesToSize($zipSize);
|
| 384 |
echo <<<EOF
|
| 385 |
<a href='{$backZipPath}'><span>{$backZipPath}</span></a> ( {$zipSize} ) |
|
| 386 |
<input type='hidden' name='backupUrl' class='backupUrl' value="{$backZipPath}" />
|
| 387 |
<a class='copy-button' href='#' data-clipboard-text='{$backZipPath}'>Copy URL</a> <br /><br />
|
| 388 |
(Copy that link and paste it into the "Restore URL" of your new WordPress installation to clone this site)
|
| 389 |
* @since 2.0.6
|
| 390 |
*/
|
| 391 |
$deleteRow = DeleteWPBackupZip($_REQUEST['del']);
|
| 392 |
echo <<<EOT
|
| 393 |
<h1>Deleted Successful!</h1> <br />
|
| 394 |
{$deleteRow->backup_name} <br />
|
| 395 |
File deleted from backup folder and database...
|
| 396 |
* @since 2.1.2
|
| 397 |
* copypasta from wp-load.php
|
| 398 |
* @return the path to wp-config.php
|
| 399 |
*/
|
| 400 |
$z = pathinfo($path);
|
| 401 |
if (file_exists(WPCLONE_DIR_BACKUP . $z['basename'])) {
|
| 402 |
return WPCLONE_DIR_BACKUP . $z['basename'];
|
| 403 |
}
|
| 404 |
else {
|
| 405 |
$url = download_url($path, 750);
|
| 406 |
if ( is_wp_error($url) ) wpa_backup_error( 'url', $url->get_error_message(), true );
|
| 407 |
return $url;
|
| 408 |
}
|
| 409 |
$backup_name = 'wpclone_backup_' . date( 'dS_M_Y_h-iA' ) . '_' . get_option( 'blogname' );
|
| 410 |
$backup_name = substr( str_replace( ' ', '', $backup_name ), 0, 40 );
|
| 411 |
$rand_str = substr( str_shuffle( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ), 0, 10 );
|
| 412 |
$backup_name = sanitize_file_name( $backup_name ) . '_' . $rand_str;
|
| 413 |
return $backup_name;
|
| 414 |
|
| 415 |
$backup_dir = $restore ? trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone_backup' : trailingslashit( WPCLONE_DIR_BACKUP ) . 'wpclone_backup';
|
| 416 |
if( $restore ) {
|
| 417 |
$url = isset($_POST['restoreBackup']) ? $_POST['restoreBackup'] : $_POST['restore_from_url'];
|
| 418 |
if ( !file_exists( $backup_dir ) ) {
|
| 419 |
$path = pathinfo( $url );
|
| 420 |
$backup_dir = trailingslashit( WPCLONE_WP_CONTENT ) . $path['filename'];
|
| 421 |
}
|
| 422 |
if( !file_exists( $backup_dir ) ) {
|
| 423 |
unset( $backup_dir );
|
| 424 |
}
|
| 425 |
}
|
| 426 |
switch ( $error ) :
|
| 427 |
/* during backup */
|
| 428 |
case 'file' :
|
| 429 |
$error = __( 'while copying files into the temp directory' );
|
| 430 |
break;
|
| 431 |
case 'db' :
|
| 432 |
$error = __( 'during the database backup' );
|
| 433 |
break;
|
| 434 |
case 'zip' :
|
| 435 |
$error = __( 'while creating the zip file using PHP\'s ZipArchive library' );
|
| 436 |
break;
|
| 437 |
case 'pclzip' :
|
| 438 |
$error = __( 'while creating the zip file using the PclZip library' );
|
| 439 |
break;
|
| 440 |
/* during restore */
|
| 441 |
case 'filerest' :
|
| 442 |
$error = __( 'while copying files from the temp directory into the wp-content directory' );
|
| 443 |
break;
|
| 444 |
case 'dbrest' :
|
| 445 |
$error = __( 'while cloning the database' );
|
| 446 |
break;
|
| 447 |
case 'unzip' :
|
| 448 |
$error = __( 'while extracting the zip file using WP\'s zip file extractor' );
|
| 449 |
break;
|
| 450 |
case 'pclunzip' :
|
| 451 |
$error = __( 'while extracting the zip file using the PclZip library' );
|
| 452 |
break;
|
| 453 |
case 'url' :
|
| 454 |
$error = __( 'while downloading the zip file' );
|
| 455 |
break;
|
| 456 |
case 'wpconfig' :
|
| 457 |
$error = __( 'while trying to modify the table prefix in the wp-config.php file' );
|
| 458 |
break;
|
| 459 |
/* and a catch all for the things that aren't covered above */
|
| 460 |
default :
|
| 461 |
$error = sprintf( __( 'during the %s process' ), $error );
|
| 462 |
endswitch;
|
| 463 |
|
| 464 |
echo '<div class="wpclone_notice updated">';
|
| 465 |
printf( __( 'The plugin encountered an error %s,the following error message was returned:</br>' ), $error );
|
| 466 |
echo '<div class="error">' . __( 'Error Message : ' ) . $data . '</div></br>';
|
| 467 |
if( isset( $backup_dir) ) {
|
| 468 |
printf( __( 'Temporary files created in <code>%s</code> will be deleted.' ), $backup_dir );
|
| 469 |
echo '</div>';
|
| 470 |
global $wp_filesystem;
|
| 471 |
$wp_filesystem->delete($backup_dir, true);
|
| 472 |
} else {
|
| 473 |
echo '</div>';
|
| 474 |
}
|
| 475 |
die;
|
| 476 |
$backup_dir = $restore ? trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone_backup' : trailingslashit( WPCLONE_DIR_BACKUP ) . 'wpclone_backup';
|
| 477 |
if ( file_exists( $backup_dir ) && is_dir( $backup_dir ) ) {
|
| 478 |
global $wp_filesystem;
|
| 479 |
$wp_filesystem->delete($backup_dir, true);
|
| 480 |
}
|
| 481 |
+
<?php
|
| 482 |
return str_replace("\\", "/", $path);
|
| 483 |
return rtrim(str_replace("//", "/", wpCloneSafePathMode($path)), '/') . '/';
|
| 484 |
return str_replace(rtrim(WPCLONE_ROOT, "/\\"), site_url(), $path);
|
| 485 |
return str_replace(site_url(), rtrim(WPCLONE_ROOT, "/\\"), $url);
|
| 486 |
global $wpdb;
|
| 487 |
$WPCLONE_DB_ICONV_IN = "UTF-8";
|
| 488 |
$WPCLONE_DB_ICONV_OUT = "ISO-8859-1//TRANSLIT";
|
| 489 |
$return = '';
|
| 490 |
// Get all of the tables
|
| 491 |
$tables = $wpdb->get_col('SHOW TABLES');
|
| 492 |
// Cycle through each provided table
|
| 493 |
foreach ($tables as $table) {
|
| 494 |
// First part of the output � remove the table
|
| 495 |
$result = $wpdb->get_results("SELECT * FROM {$table}", ARRAY_N);
|
| 496 |
$numberOfFields = count($result[0]);
|
| 497 |
$numberOfItems = count($result);
|
| 498 |
// Second part of the output � create table
|
| 499 |
$row2 = $wpdb->get_row("SHOW CREATE TABLE {$table}", ARRAY_N);
|
| 500 |
$return .= "\n\n" . $row2[1] . ";\n\n";
|
| 501 |
// Third part of the output � insert values into new table
|
| 502 |
for ($currentRowNumber = 0; $currentRowNumber < $numberOfItems; $currentRowNumber++) {
|
| 503 |
$row = $result[$currentRowNumber];
|
| 504 |
$query = "INSERT INTO {$table} VALUES(";
|
| 505 |
for ($j = 0; $j < $numberOfFields; $j++) {
|
| 506 |
$row[$j] = iconv($WPCLONE_DB_ICONV_IN, $WPCLONE_DB_ICONV_OUT, $row[$j]);
|
| 507 |
$query .= (empty($row[$j])) ? '"", ' : '"' . mysql_real_escape_string($row[$j]) . '", ';
|
| 508 |
}
|
| 509 |
$return .= substr($query, 0, -2) . ");\n";
|
| 510 |
}
|
| 511 |
$return .= "\n";
|
| 512 |
}
|
| 513 |
// Generate the filename for the sql file
|
| 514 |
$File_open = fopen($destination . '/database.sql', 'w+');
|
| 515 |
// Save the sql file
|
| 516 |
fwrite($File_open, $return);
|
| 517 |
//file close
|
| 518 |
fclose($File_open);
|
| 519 |
$wpdb->flush();
|
| 520 |
* @link http://davidwalsh.name/backup-mysql-database-php
|
| 521 |
*/
|
| 522 |
if ( false === $link ) {
|
| 523 |
wpa_backup_error('db', mysql_error() );
|
| 524 |
}
|
| 525 |
if ( false === $result ) {
|
| 526 |
wpa_backup_error('db', mysql_error() );
|
| 527 |
}
|
| 528 |
|
| 529 |
if ( false === $result ) {
|
| 530 |
wpa_backup_error('db', mysql_error() );
|
| 531 |
}
|
| 532 |
|
| 533 |
global $wpdb;
|
| 534 |
global $current_user;
|
| 535 |
$wpdb->insert($wpdb->prefix . "wpclone", array(
|
| 536 |
'backup_name' => $name,
|
| 537 |
'data_time' => current_time('mysql', get_option('gmt_offset')),
|
| 538 |
'creator' => $current_user->user_login,
|
| 539 |
'backup_size' => $size)
|
| 540 |
);
|
| 541 |
$wpdb->flush();
|
| 542 |
$folderToBeZipped = WPCLONE_DIR_BACKUP . 'wpclone_backup';
|
| 543 |
$destinationPath = $folderToBeZipped . '/' . basename(WPCLONE_WP_CONTENT);
|
| 544 |
$zipFileName = WPCLONE_DIR_BACKUP . $backupName . '.zip';
|
| 545 |
global $wp_filesystem;
|
| 546 |
|
| 547 |
/* create the backup directory and call the cleanup function if it failed to do so */
|
| 548 |
$dir = $wp_filesystem->mkdir( $folderToBeZipped );
|
| 549 |
if( is_wp_error($dir) ) {
|
| 550 |
wpa_backup_error ( 'file', $dir->get_error_message() . $folderToBeZipped );
|
| 551 |
}
|
| 552 |
/* copy wp-content directory into the newly created backup directory. call the cleanup function if it fails.
|
| 553 |
* (wpa_copy doesn't return anything at the moment)*/
|
| 554 |
$files = wpa_copy(WPCLONE_WP_CONTENT, $destinationPath);
|
| 555 |
if( is_wp_error($files) ) {
|
| 556 |
wpa_backup_error ( 'file', $files->get_error_message() );
|
| 557 |
}
|
| 558 |
wpa_save_prefix($folderToBeZipped);
|
| 559 |
/* error handler is called from within the db backup functions */
|
| 560 |
if ( $use_wpdb ) {
|
| 561 |
wpa_db_backup_wpdb( $folderToBeZipped );
|
| 562 |
} else {
|
| 563 |
wpa_db_backup_direct( $folderToBeZipped );
|
| 564 |
}
|
| 565 |
|
| 566 |
/* error haldler is called from within the wpa_zip function */
|
| 567 |
wpa_zip($zipFileName, $folderToBeZipped, $zipmode);
|
| 568 |
$zipSize = filesize($zipFileName);
|
| 569 |
$wp_filesystem->delete( $folderToBeZipped, true );
|
| 570 |
return array($backupName . '.zip', $zipSize);
|
| 571 |
global $wpdb;
|
| 572 |
$wp_backup = "{$wpdb->prefix}wpclone";
|
| 573 |
$deleteRow = $wpdb->get_row("SELECT * FROM {$wp_backup} WHERE id = '{$nm}'");
|
| 574 |
$wpdb->query("DELETE FROM {$wp_backup} WHERE id = '{$nm}' ");
|
| 575 |
if (file_exists(WPCLONE_DIR_BACKUP . $deleteRow->backup_name)) unlink(WPCLONE_DIR_BACKUP . $deleteRow->backup_name) or die ('unable to delete backup file.');
|
| 576 |
return $deleteRow;
|
| 577 |
$kilobyte = 1024;
|
| 578 |
$megabyte = $kilobyte * 1024;
|
| 579 |
$gigabyte = $megabyte * 1024;
|
| 580 |
$terabyte = $gigabyte * 1024;
|
| 581 |
if (($bytes >= 0) && ($bytes < $kilobyte)) {
|
| 582 |
return $bytes . ' B';
|
| 583 |
} elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) {
|
| 584 |
return round($bytes / $kilobyte, $precision) . ' KB';
|
| 585 |
} elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) {
|
| 586 |
return round($bytes / $megabyte, $precision) . ' MB';
|
| 587 |
} elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) {
|
| 588 |
return round($bytes / $gigabyte, $precision) . ' GB';
|
| 589 |
} elseif ($bytes >= $terabyte) {
|
| 590 |
return round($bytes / $terabyte, $precision) . ' TB';
|
| 591 |
} else {
|
| 592 |
return $bytes . ' B';
|
| 593 |
}
|
| 594 |
$fileContent = file_get_contents($databaseFile, true);
|
| 595 |
$pos = strpos($fileContent, 'siteurl') + 8;
|
| 596 |
$urlStartPos = strpos($fileContent, '"', $pos) + 1;
|
| 597 |
$urlEndPos = strpos($fileContent, '"', $urlStartPos);
|
| 598 |
$backupSiteUrl = substr($fileContent, $urlStartPos, $urlEndPos - $urlStartPos);
|
| 599 |
return $backupSiteUrl;
|
| 600 |
|
| 601 |
$dbFileContent = file_get_contents($databaseFileInZip);
|
| 602 |
/* we don't want to nuke the curret database if if something went wrong with the above operation */
|
| 603 |
if ( false === $dbFileContent ) {
|
| 604 |
wpa_backup_error( 'dbrest', sprintf ( __( 'Cannot read <code>%s</code>' ), $databaseFileInZip ) , true );
|
| 605 |
}
|
| 606 |
|
| 607 |
|
| 608 |
$conn = mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
| 609 |
/* and we cannot nuke the db if the connection failed now can we */
|
| 610 |
if ( false === $conn ) {
|
| 611 |
wpa_backup_error('dbrest', __( 'database connection failed' ), true );
|
| 612 |
}
|
| 613 |
|
| 614 |
mysql_select_db( DB_NAME, $conn);
|
| 615 |
|
| 616 |
$query = mysql_query("SHOW TABLES", $conn);
|
| 617 |
/* point of no return,if it fails after this you're royally boned ;) */
|
| 618 |
while (($fetch = mysql_fetch_array($query))) {
|
| 619 |
mysql_query("Drop table `{$fetch[0]}`");
|
| 620 |
}
|
| 621 |
flush();
|
| 622 |
|
| 623 |
$res = explode(";\n", $dbFileContent);
|
| 624 |
foreach ($res AS $query) {
|
| 625 |
mysql_query($query, $conn);
|
| 626 |
}
|
| 627 |
mysql_close($conn);
|
| 628 |
$backupSiteUrl = replaceSiteUrlFromDatabaseFile($databaseFileInZip); /* don't let the name fool you,it just returns the old site's url */
|
| 629 |
$currentSiteUrl = site_url();
|
| 630 |
$backupSiteUrl = untrailingslashit($backupSiteUrl);
|
| 631 |
$currentSiteUrl = untrailingslashit($currentSiteUrl);
|
| 632 |
wpa_safe_replace_wrapper ( $backupSiteUrl, $currentSiteUrl );
|
| 633 |
|
| 634 |
return $currentSiteUrl;
|
| 635 |
* @param type $search URL of the previous site.
|
| 636 |
* @param type $replace URL of the current site.
|
| 637 |
* @return type total time it took for the operation.
|
| 638 |
*/
|
| 639 |
if ( !function_exists( 'icit_srdb_replacer' ) && !function_exists( 'recursive_unserialize_replace' ) ) {
|
| 640 |
require_once 'icit_srdb_replacer.php';
|
| 641 |
}
|
| 642 |
$connection = @mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
| 643 |
$all_tables = array( );
|
| 644 |
@mysql_select_db( DB_NAME, $connection );
|
| 645 |
$all_tables_mysql = @mysql_query( 'SHOW TABLES', $connection );
|
| 646 |
if ( ! $all_tables_mysql ) {
|
| 647 |
wpa_backup_error( 'dbrest', mysql_error(), true );
|
| 648 |
} else {
|
| 649 |
while ( $table = mysql_fetch_array( $all_tables_mysql ) ) {
|
| 650 |
$all_tables[] = $table[ 0 ];
|
| 651 |
}
|
| 652 |
}
|
| 653 |
$report = icit_srdb_replacer( $connection, $search, $replace, $all_tables );
|
| 654 |
return $report;
|
| 655 |
wpa_cleanup( true );
|
| 656 |
if (!is_string($url) || '' == $url) {
|
| 657 |
wpa_backup_error( 'restore', sprintf( __( 'The provided URL "<code>%s</code>" is either not valid or empty' ), $url ), true );
|
| 658 |
}
|
| 659 |
|
| 660 |
global $wp_filesystem;
|
| 661 |
$temp_dir = trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone-temp';
|
| 662 |
$temp_dir_err = $wp_filesystem->mkdir( $temp_dir );
|
| 663 |
if ( is_wp_error($temp_dir_err) ) {
|
| 664 |
wpa_backup_error('dirrest', $temp_dir_err->get_error_message(), true );
|
| 665 |
}
|
| 666 |
$pathParts = pathinfo($url);
|
| 667 |
$zipFilename = wpa_fetch_file($url);
|
| 668 |
$result = wpa_unzip($zipFilename, $temp_dir, $zipmode);
|
| 669 |
if ($result) {
|
| 670 |
$unzippedFolderPath = wpCloneSafePathMode( trailingslashit( $temp_dir ) . 'wpclone_backup' );
|
| 671 |
if ( !file_exists( $unzippedFolderPath ) ) {
|
| 672 |
$unzippedFolderPath = wpCloneSafePathMode( trailingslashit( $temp_dir ) . $pathParts['filename'] );
|
| 673 |
}
|
| 674 |
|
| 675 |
/* if we're here then the file extraction worked,but let's make doubly sure */
|
| 676 |
if( !is_dir( $unzippedFolderPath ) ) {
|
| 677 |
wpa_backup_error( 'restore', sprintf( __( 'Cannot find <code>%s<code>' ), $unzippedFolderPath ), true );
|
| 678 |
}
|
| 679 |
/* check the table prefixes */
|
| 680 |
$old_db_prefix = $unzippedFolderPath . '/prefix.txt';
|
| 681 |
$prefix = wpa_check_prefix($old_db_prefix);
|
| 682 |
if ($prefix) {
|
| 683 |
wpa_replace_prefix( $prefix );
|
| 684 |
}
|
| 685 |
/* import db */
|
| 686 |
$databaseFile = $unzippedFolderPath . '/database.sql';
|
| 687 |
$currentSiteUrl = processConfigAndDatabaseFile($databaseFile);
|
| 688 |
/* */
|
| 689 |
wpa_copy( $unzippedFolderPath, WPCLONE_ROOT );
|
| 690 |
|
| 691 |
$wp_filesystem->delete( $temp_dir, true );
|
| 692 |
/* remove the zip file only if it was downloaded from an external location. */
|
| 693 |
$wptmp = explode('.', $zipFilename);
|
| 694 |
if ( in_array( 'tmp', $wptmp ) ) {
|
| 695 |
$wp_filesystem->delete( $zipFilename );
|
| 696 |
}
|
| 697 |
echo "<h1>Restore Successful!</h1>";
|
| 698 |
echo "Visit your restored site [ <a href='{$currentSiteUrl}' target=blank>here</a> ]<br><br>";
|
| 699 |
echo "<strong>You may need to re-save your permalink structure <a href='{$currentSiteUrl}/wp-admin/options-permalink.php' target=blank>Here</a></strong>";
|
| 700 |
} else {
|
| 701 |
echo "<h1>Restore unsuccessful!!!</h1>";
|
| 702 |
echo "Please try again.";
|
| 703 |
}
|
| 704 |
global $wpdb;
|
| 705 |
$prefix = $wpdb->prefix;
|
| 706 |
$file = $path . '/prefix.txt';
|
| 707 |
if ( is_dir($path) && is_writable($path) ) {
|
| 708 |
file_put_contents($file, $prefix);
|
| 709 |
}
|
| 710 |
* Checks to see whether the destination site's table prefix matches that of the origin site.old prefix is returned in case of a mismatch.
|
| 711 |
*
|
| 712 |
* @param type $file path to the prefix.txt file.
|
| 713 |
* @return type bool string
|
| 714 |
*/
|
| 715 |
global $wpdb;
|
| 716 |
$prefix = $wpdb->prefix;
|
| 717 |
if (file_exists($file) && is_readable($file)) {
|
| 718 |
$old_prefix = file_get_contents($file);
|
| 719 |
if ( $prefix !== $old_prefix ) {
|
| 720 |
return $old_prefix;
|
| 721 |
}
|
| 722 |
else {
|
| 723 |
return false;
|
| 724 |
}
|
| 725 |
}
|
| 726 |
return false;
|
| 727 |
* @since 2.0.6
|
| 728 |
*
|
| 729 |
* @param type $zipfile path to the zip file that needs to be extracted.
|
| 730 |
* @param type $path the place to where the file needs to be extracted.
|
| 731 |
* @return as false in the event of failure.
|
| 732 |
*/
|
| 733 |
if ( $zipmode ) {
|
| 734 |
if ( ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding') ) {
|
| 735 |
$previous_encoding = mb_internal_encoding();
|
| 736 |
mb_internal_encoding('ISO-8859-1');
|
| 737 |
}
|
| 738 |
define('PCLZIP_TEMPORARY_DIR', WPCLONE_DIR_BACKUP);
|
| 739 |
require_once ( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
| 740 |
$z = new PclZip($zipfile);
|
| 741 |
$files = $z->extract(PCLZIP_OPT_PATH, $path);
|
| 742 |
if ( isset($previous_encoding) ) mb_internal_encoding($previous_encoding);
|
| 743 |
if ( $files == 0 ) {
|
| 744 |
wpa_backup_error( 'pclunzip', $z->errorInfo(true), true );
|
| 745 |
}
|
| 746 |
return true;
|
| 747 |
}
|
| 748 |
else {
|
| 749 |
$z= unzip_file($zipfile, $path);
|
| 750 |
if (is_wp_error($z)) {
|
| 751 |
wpa_backup_error( 'unzip', $z->get_error_message(), true );
|
| 752 |
}
|
| 753 |
return true;
|
| 754 |
}
|
| 755 |
* @since 2.0.6
|
| 756 |
*
|
| 757 |
* @param type $name name of the zip file.
|
| 758 |
* @param type $file_list an array of files that needs to be archived.
|
| 759 |
*/
|
| 760 |
if ( $zipmode || (!in_array('ZipArchive', get_declared_classes()) || !class_exists('ZipArchive')) ) {
|
| 761 |
define('PCLZIP_TEMPORARY_DIR', WPCLONE_DIR_BACKUP);
|
| 762 |
require_once ( ABSPATH . 'wp-admin/includes/class-pclzip.php');
|
| 763 |
$z = new PclZip($zip_name);
|
| 764 |
$v_list = $z->create($folder, PCLZIP_OPT_REMOVE_PATH, WPCLONE_DIR_BACKUP);
|
| 765 |
if ($v_list == 0) {
|
| 766 |
wpa_backup_error( 'pclzip', $z->errorInfo(true) );
|
| 767 |
}
|
| 768 |
} else {
|
| 769 |
$z = new ZipArchive();
|
| 770 |
if ( true !== $z->open( $zip_name, ZIPARCHIVE::CREATE ) ) {
|
| 771 |
wpa_backup_error( 'zip', $z );
|
| 772 |
}
|
| 773 |
wpa_ziparc($z, $folder, WPCLONE_DIR_BACKUP);
|
| 774 |
$z->close();
|
| 775 |
}
|
| 776 |
$new_folder = str_replace($base, '', $dir);
|
| 777 |
$zip->addEmptyDir($new_folder);
|
| 778 |
foreach( glob( $dir . '/*' ) as $file ){
|
| 779 |
if( is_dir($file) ) {
|
| 780 |
wpa_ziparc($zip, $file, $base);
|
| 781 |
} else {
|
| 782 |
$new_file = str_replace( $base, '', $file );
|
| 783 |
$zip->addFile($file, $new_file);
|
| 784 |
}
|
| 785 |
}
|
| 786 |
* just a simple function to increase PHP limits.
|
| 787 |
* @since 2.0.6
|
| 788 |
*/
|
| 789 |
$time = isset( $_POST['maxexec'] ) && '' != $_POST['maxexec'] ? $_POST['maxexec'] : 900;
|
| 790 |
$mem = isset ( $_POST['maxmem'] ) && '' != $_POST['maxmem'] ? $_POST['maxmem'] . 'M' : '512M';
|
| 791 |
@ini_set('memory_limit', $mem);
|
| 792 |
@ini_set('max_execution_time', $time); //900 seconds = 15 minutes
|
| 793 |
* @since 2.0.6
|
| 794 |
*/
|
| 795 |
if (!empty($_REQUEST['del'])) {
|
| 796 |
wpa_remove_backup();
|
| 797 |
return true;
|
| 798 |
}
|
| 799 |
if (empty($_POST)) return false;
|
| 800 |
check_admin_referer('wpclone-submit');
|
| 801 |
$form_post = wp_nonce_url('admin.php?page=wp-clone', 'wpclone-submit');
|
| 802 |
$extra_fields = array('restore_from_url', 'maxmem', 'maxexec', 'zipmode', 'restoreBackup');
|
| 803 |
$type = '';
|
| 804 |
if ( false === ($creds = request_filesystem_credentials($form_post, $type, false, false, $extra_fields)) ){
|
| 805 |
return true;
|
| 806 |
}
|
| 807 |
if (!WP_Filesystem($creds)) {
|
| 808 |
request_filesystem_credentials($form_post, $type, true, false, $extra_fields);
|
| 809 |
return true;
|
| 810 |
}
|
| 811 |
wpa_bump_limits();
|
| 812 |
|
| 813 |
if (isset($_POST['createBackup'])) {
|
| 814 |
wpa_create_backup();
|
| 815 |
return true;
|
| 816 |
}
|
| 817 |
|
| 818 |
$zipmode = isset($_POST['zipmode']) ? true : false;
|
| 819 |
$url = isset($_POST['restoreBackup']) ? $_POST['restoreBackup'] : $_POST['restore_from_url'];
|
| 820 |
processRestoringBackup($url, $zipmode);
|
| 821 |
return true;
|
| 822 |
* @since 2.0.6
|
| 823 |
*/
|
| 824 |
global $wp_filesystem;
|
| 825 |
if (is_readable($source)) {
|
| 826 |
if (is_dir($source)) {
|
| 827 |
if (!strstr(wpCloneSafePathMode($source), rtrim(WPCLONE_DIR_BACKUP, "/\\"))) {
|
| 828 |
if (!file_exists($target)) {
|
| 829 |
$wp_filesystem->mkdir($target);
|
| 830 |
}
|
| 831 |
$d = dir($source);
|
| 832 |
while (FALSE !== ($entry = $d->read())) {
|
| 833 |
if ($entry == '.' || $entry == '..') {
|
| 834 |
continue;
|
| 835 |
}
|
| 836 |
$Entry = "{$source}/{$entry}";
|
| 837 |
if (is_dir($Entry)) {
|
| 838 |
wpa_copy($Entry, $target . '/' . $entry);
|
| 839 |
} else {
|
| 840 |
$wp_filesystem->copy($Entry, $target . '/' . $entry, true, FS_CHMOD_FILE);
|
| 841 |
}
|
| 842 |
}
|
| 843 |
$d->close();
|
| 844 |
}
|
| 845 |
}
|
| 846 |
else {
|
| 847 |
$wp_filesystem->copy($source, $target, true);
|
| 848 |
}
|
| 849 |
}
|
| 850 |
* @since 2.0.6
|
| 851 |
*/
|
| 852 |
$wpconfig = wpa_wpconfig_path();
|
| 853 |
if ( ! is_writable($wpconfig) ) {
|
| 854 |
wpa_backup_error('wpconfig', sprintf( __( "<code>%s</code> is not writable." ), $wpconfig ), true );
|
| 855 |
}
|
| 856 |
|
| 857 |
global $wp_filesystem;
|
| 858 |
$fileContent = file_get_contents($wpconfig);
|
| 859 |
$pos = strpos($fileContent, '$table_prefix');
|
| 860 |
$str = substr($fileContent, $pos, strpos($fileContent, PHP_EOL, $pos) - $pos);
|
| 861 |
$fileContent = str_replace($str, '$table_prefix = "' . $newPrefix . '";', $fileContent);
|
| 862 |
$wp_filesystem->put_contents($wpconfig, $fileContent, 0600);
|
| 863 |
* @since 2.0.6
|
| 864 |
*/
|
| 865 |
if ( !file_exists(WPCLONE_DIR_BACKUP) ) {
|
| 866 |
wpa_create_directory();
|
| 867 |
}
|
| 868 |
wpa_cleanup();
|
| 869 |
$use_wpdb = isset( $_POST['use_wpdb'] ) && 'true' == $_POST['use_wpdb'] ? true : false;
|
| 870 |
$backupName = wpa_backup_name();
|
| 871 |
$zipmode = isset($_POST['zipmode']) ? true : false;
|
| 872 |
list($zipFileName, $zipSize) = CreateWPFullBackupZip($backupName, $zipmode, $use_wpdb);
|
| 873 |
wpa_insert_data($zipFileName, $zipSize);
|
| 874 |
$backZipPath = convertPathIntoUrl(WPCLONE_DIR_BACKUP . $zipFileName);
|
| 875 |
$zipSize = bytesToSize($zipSize);
|
| 876 |
echo <<<EOF
|
| 877 |
<a href='{$backZipPath}'><span>{$backZipPath}</span></a> ( {$zipSize} ) |
|
| 878 |
<input type='hidden' name='backupUrl' class='backupUrl' value="{$backZipPath}" />
|
| 879 |
<a class='copy-button' href='#' data-clipboard-text='{$backZipPath}'>Copy URL</a> <br /><br />
|
| 880 |
(Copy that link and paste it into the "Restore URL" of your new WordPress installation to clone this site)
|
| 881 |
* @since 2.0.6
|
| 882 |
*/
|
| 883 |
$deleteRow = DeleteWPBackupZip($_REQUEST['del']);
|
| 884 |
echo <<<EOT
|
| 885 |
<h1>Deleted Successful!</h1> <br />
|
| 886 |
{$deleteRow->backup_name} <br />
|
| 887 |
File deleted from backup folder and database...
|
| 888 |
* @since 2.1.2
|
| 889 |
* copypasta from wp-load.php
|
| 890 |
* @return the path to wp-config.php
|
| 891 |
*/
|
| 892 |
$z = pathinfo($path);
|
| 893 |
if (file_exists(WPCLONE_DIR_BACKUP . $z['basename'])) {
|
| 894 |
return WPCLONE_DIR_BACKUP . $z['basename'];
|
| 895 |
}
|
| 896 |
else {
|
| 897 |
$url = download_url($path, 750);
|
| 898 |
if ( is_wp_error($url) ) wpa_backup_error( 'url', $url->get_error_message(), true );
|
| 899 |
return $url;
|
| 900 |
}
|
| 901 |
$backup_name = 'wpclone_backup_' . date( 'dS_M_Y_h-iA' ) . '_' . get_option( 'blogname' );
|
| 902 |
$backup_name = substr( str_replace( ' ', '', $backup_name ), 0, 40 );
|
| 903 |
$rand_str = substr( str_shuffle( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ), 0, 10 );
|
| 904 |
$backup_name = sanitize_file_name( $backup_name ) . '_' . $rand_str;
|
| 905 |
return $backup_name;
|
| 906 |
|
| 907 |
$temp_dir = $restore ? trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone-temp' : trailingslashit( WPCLONE_DIR_BACKUP ) . 'wpclone_backup';
|
| 908 |
|
| 909 |
if( !file_exists( $temp_dir ) ) {
|
| 910 |
unset($temp_dir);
|
| 911 |
}
|
| 912 |
switch ( $error ) :
|
| 913 |
/* during backup */
|
| 914 |
case 'file' :
|
| 915 |
$error = __( 'while copying files into the temp directory' );
|
| 916 |
break;
|
| 917 |
case 'db' :
|
| 918 |
$error = __( 'during the database backup' );
|
| 919 |
break;
|
| 920 |
case 'zip' :
|
| 921 |
$error = __( 'while creating the zip file using PHP\'s ZipArchive library' );
|
| 922 |
break;
|
| 923 |
case 'pclzip' :
|
| 924 |
$error = __( 'while creating the zip file using the PclZip library' );
|
| 925 |
break;
|
| 926 |
/* during restore */
|
| 927 |
case 'dirrest' :
|
| 928 |
$error = __( 'while creating the temp directory' );
|
| 929 |
break;
|
| 930 |
case 'filerest' :
|
| 931 |
$error = __( 'while copying files from the temp directory into the wp-content directory' );
|
| 932 |
break;
|
| 933 |
case 'dbrest' :
|
| 934 |
$error = __( 'while cloning the database' );
|
| 935 |
break;
|
| 936 |
case 'unzip' :
|
| 937 |
$error = __( 'while extracting the zip file using WP\'s zip file extractor' );
|
| 938 |
break;
|
| 939 |
case 'pclunzip' :
|
| 940 |
$error = __( 'while extracting the zip file using the PclZip library' );
|
| 941 |
break;
|
| 942 |
case 'url' :
|
| 943 |
$error = __( 'while downloading the zip file' );
|
| 944 |
break;
|
| 945 |
case 'wpconfig' :
|
| 946 |
$error = __( 'while trying to modify the table prefix in the wp-config.php file' );
|
| 947 |
break;
|
| 948 |
/* and a catch all for the things that aren't covered above */
|
| 949 |
default :
|
| 950 |
$error = sprintf( __( 'during the %s process' ), $error );
|
| 951 |
endswitch;
|
| 952 |
|
| 953 |
echo '<div class="wpclone_notice updated">';
|
| 954 |
printf( __( 'The plugin encountered an error %s,the following error message was returned:</br>' ), $error );
|
| 955 |
echo '<div class="error">' . __( 'Error Message : ' ) . $data . '</div></br>';
|
| 956 |
if( isset( $temp_dir ) ) {
|
| 957 |
printf( __( 'Temporary files created in <code>%s</code> will be deleted.' ), $temp_dir );
|
| 958 |
echo '</div>';
|
| 959 |
global $wp_filesystem;
|
| 960 |
$wp_filesystem->delete($temp_dir, true);
|
| 961 |
} else {
|
| 962 |
echo '</div>';
|
| 963 |
}
|
| 964 |
die;
|
| 965 |
$backup_dir = $restore ? trailingslashit( WPCLONE_WP_CONTENT ) . 'wpclone-temp' : trailingslashit( WPCLONE_DIR_BACKUP ) . 'wpclone_backup';
|
| 966 |
if ( file_exists( $backup_dir ) && is_dir( $backup_dir ) ) {
|
| 967 |
global $wp_filesystem;
|
| 968 |
$wp_filesystem->delete($backup_dir, true);
|
| 969 |
}
|
lib/view.php
CHANGED
|
@@ -38,7 +38,6 @@
|
|
| 38 |
<?php
|
| 39 |
if (wpa_wpfs_init()) return;
|
| 40 |
global $wpdb;
|
| 41 |
-
|
| 42 |
$result = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wpclone ORDER BY id DESC", ARRAY_A);
|
| 43 |
|
| 44 |
?>
|
|
@@ -75,7 +74,7 @@ $result = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wpclone ORDER BY id D
|
|
| 75 |
}
|
| 76 |
?>
|
| 77 |
<strong>Create Backup</strong>
|
| 78 |
-
<input id="createBackup" name="createBackup" type="radio" value="fullBackup"/><br/><br/>
|
| 79 |
|
| 80 |
<?php if (count($result) > 0) : ?>
|
| 81 |
|
| 38 |
<?php
|
| 39 |
if (wpa_wpfs_init()) return;
|
| 40 |
global $wpdb;
|
|
|
|
| 41 |
$result = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wpclone ORDER BY id DESC", ARRAY_A);
|
| 42 |
|
| 43 |
?>
|
| 74 |
}
|
| 75 |
?>
|
| 76 |
<strong>Create Backup</strong>
|
| 77 |
+
<input id="createBackup" name="createBackup" type="radio" value="fullBackup" checked="checked"/><br/><br/>
|
| 78 |
|
| 79 |
<?php if (count($result) > 0) : ?>
|
| 80 |
|
readme.txt
CHANGED
|
@@ -6,7 +6,7 @@ Author URI: http://wpacademy.com
|
|
| 6 |
Plugin URI: http://wpacademy.com/software
|
| 7 |
Requires at least: 3.0
|
| 8 |
Tested up to: 3.5.1
|
| 9 |
-
Stable tag: 2.1.
|
| 10 |
License: GPLv2 or later
|
| 11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 12 |
|
|
@@ -49,6 +49,10 @@ released under the WTFPL http://sam.zoy.org/wtfpl/. Partial script with full cha
|
|
| 49 |
Review FAQ's and Help Video at the [WP Clone FAQ Page](http://wpacademy.tv/wpclone-faq "WP Clone FAQ")
|
| 50 |
|
| 51 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
= 2.1.3 - 2013-03-17 =
|
| 53 |
* Fixed: The 'copy' link in the 'backup successful' screen which stopped working after the 2.1.2 update.
|
| 54 |
* Added: An option to backup the database using WordPress' WPDB class.
|
| 6 |
Plugin URI: http://wpacademy.com/software
|
| 7 |
Requires at least: 3.0
|
| 8 |
Tested up to: 3.5.1
|
| 9 |
+
Stable tag: 2.1.4
|
| 10 |
License: GPLv2 or later
|
| 11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 12 |
|
| 49 |
Review FAQ's and Help Video at the [WP Clone FAQ Page](http://wpacademy.tv/wpclone-faq "WP Clone FAQ")
|
| 50 |
|
| 51 |
== Changelog ==
|
| 52 |
+
= 2.1.4 - 2013-03-18 =
|
| 53 |
+
* Fixed: When javascript is disabled,submit button shows "Create Backup" but the plugin attempts to do a restore.
|
| 54 |
+
* Changed: The temporary directory location during the restore process from '/wp-content/' to '/wp-content/wpclone-temp/'.
|
| 55 |
+
|
| 56 |
= 2.1.3 - 2013-03-17 =
|
| 57 |
* Fixed: The 'copy' link in the 'backup successful' screen which stopped working after the 2.1.2 update.
|
| 58 |
* Added: An option to backup the database using WordPress' WPDB class.
|
wpclone.php
CHANGED
|
@@ -4,7 +4,7 @@ Plugin name: WP Clone by WP Academy
|
|
| 4 |
Plugin URI: http://wpacademy.com/software/
|
| 5 |
Description: Move or copy a WordPress site to another server or to another domain name, move to/from local server hosting, and backup sites.
|
| 6 |
Author: WP Academy
|
| 7 |
-
Version: 2.1.
|
| 8 |
Author URI: http://wpacademy.com/
|
| 9 |
*/
|
| 10 |
|
| 4 |
Plugin URI: http://wpacademy.com/software/
|
| 5 |
Description: Move or copy a WordPress site to another server or to another domain name, move to/from local server hosting, and backup sites.
|
| 6 |
Author: WP Academy
|
| 7 |
+
Version: 2.1.4
|
| 8 |
Author URI: http://wpacademy.com/
|
| 9 |
*/
|
| 10 |
|
