function migrate_wp_config() { $this->log('Beginning migrating wp-config'); echo 'Migrating wp-config.php ... '; flush(); if (file_exists(ABSPATH . '/wp-config.php')) { $wp_config = array(); $lines = file(ABSPATH . '/wp-config.php'); foreach ($lines as $line) { if (strstr($line, 'DB_NAME')) { $wp_config[] = "define('DB_NAME', '" . $this->_options['db_name'] . "');\r\n"; } elseif (strstr($line, 'DB_USER')) { $wp_config[] = "define('DB_USER', '" . $this->_options['db_user'] . "');\r\n"; } elseif (strstr($line, 'DB_PASSWORD')) { $wp_config[] = "define('DB_PASSWORD', '" . $this->_options['db_password'] . "');\r\n"; } elseif (strstr($line, 'DB_HOST')) { $wp_config[] = "define('DB_HOST', '" . $this->_options['db_server'] . "');\r\n"; } elseif (strstr($line, '$table_prefix')) { $wp_config[] = '$table_prefix = ' . "'" . $this->_options['db_prefix'] . "';\r\n"; } else { $wp_config[] = $line; } } unset($lines); unset($line); if (chmod(ABSPATH . '/wp-config.php', 0755)) { $this->log('Changed wp-config permissions to 755.'); } // Write changes to config file. if (false === ($fh = fopen(ABSPATH . '/wp-config.php', 'w'))) { $this->alert('ERROR: Unable to save changes to wp-config.php. Make sure this file has write permissions!', true); return false; } foreach ($wp_config as $key => $value) { fwrite($fh, $value); } unset($value); unset($key); fclose($fh); unset($fh); } else { echo '<br />' . ezimg::genImageTag('bullet_error.png') . 'wp-config.php not found. Perform Full Backup restore before DB only.<br />'; } echo 'Done.<br />'; $this->log('Finished migrating wp-config'); return true; }
/** * tip() * * Displays a message to the user when they hover over the question mark. Gracefully falls back to normal tooltip. * HTML is supposed within tooltips. * * $message string Actual message to show to user. * $title string Title of message to show to user. This is displayed at top of tip in bigger letters. Default is blank. (optional) * $echo_tip boolean Whether to echo the tip (default; true), or return the tip (false). (optional) */ function tip($message, $title = '', $echo_tip = true) { $tip = ' <a class="pluginbuddy_tip" title="' . $title . ' - ' . $message . '">' . ezimg::genImageTag('pluginbuddy_tip.png') . '</a>'; if ($echo_tip === true) { echo $tip; } else { return $tip; } }
function migrate_wp_config() { $this->log('Beginning migrating wp-config'); echo 'Migrating wp-config.php ... '; flush(); if (file_exists(ABSPATH . '/wp-config.php')) { $updated_home_url = false; $wp_config = array(); $lines = file(ABSPATH . '/wp-config.php'); foreach ($lines as $line) { if (strstr($line, 'DB_NAME')) { $wp_config[] = "define('DB_NAME', '" . $this->_options['db_name'] . "');\r\n"; } elseif (strstr($line, 'DB_USER')) { $wp_config[] = "define('DB_USER', '" . $this->_options['db_user'] . "');\r\n"; } elseif (strstr($line, 'DB_PASSWORD')) { $wp_config[] = "define('DB_PASSWORD', '" . $this->_options['db_password'] . "');\r\n"; } elseif (strstr($line, 'DB_HOST')) { $wp_config[] = "define('DB_HOST', '" . $this->_options['db_server'] . "');\r\n"; } elseif (strstr($line, '$table_prefix')) { $wp_config[] = '$table_prefix = ' . "'" . $this->_options['db_prefix'] . "';\r\n"; } elseif (strstr($line, 'WP_SITEURL')) { // Update site URL if defined. $wp_config[] = "define('WP_SITEURL', '" . trim($this->_options['siteurl'], '/') . "');\r\n"; } elseif (strstr($line, 'WP_HOME')) { // Update home URL if defined. $wp_config[] = "define('WP_HOME', '" . trim($this->_options['home'], '/') . "');\r\n"; $updated_home_url = true; } else { $wp_config[] = $line; } } unset($lines); unset($line); // If a custom home URL was defined but never written then append this line at the end of the wp-config.php. /* if ( ( $this->_options['siteurl'] != $this->_options['home'] ) && ( $updated_home_url === false ) ) { $wp_config[] = "define('WP_HOME', '" . $this->_options['home'] . "');\r\n"; } */ if (chmod(ABSPATH . '/wp-config.php', 0755)) { $this->log('Changed wp-config permissions to 755.'); } // Write changes to config file. if (false === ($fh = fopen(ABSPATH . '/wp-config.php', 'w'))) { $this->alert('ERROR: Unable to save changes to wp-config.php. Make sure this file has write permissions!', true); return false; } foreach ($wp_config as $key => $value) { fwrite($fh, $value); } unset($value); unset($key); fclose($fh); unset($fh); } else { echo '<br>' . ezimg::genImageTag('bullet_error.png') . 'Note: wp-config.php not found. This is only a database restoration.<br>'; } echo 'Done.<br>'; $this->log('Finished migrating wp-config'); return true; }
if (empty($backup_archives)) { // No backups found. $this->alert('ERROR: Unable to find any BackupBuddy backup files.', 'Upload the backup zip archive into the same directory as this file, keeping the original file name. Ex: backup-your_com-2011_07_19-g1d1jpvd4e.zip<br><br> If you manually extracted, upload the backup file, select it, then select <i>Advanced Troubleshooting Options</i> & click <i>Skip Zip Extraction</i>.'); } else { // Found one or more backups. ?> <form action="?step=2" method="post"> <input type="hidden" name="options" value="<?php echo htmlspecialchars(serialize($this->_options)); ?> '" /> <?php echo ezimg::genImageTag('bullet_go.png'); echo ' <select name="file" style="max-width: 590px;">'; foreach ($backup_archives as $backup_archive) { echo '<option value="' . $backup_archive . '">' . $backup_archive . '</option>'; } echo '</select>'; echo $this->tip('Select the backup file you would like to restore data from. This must be a valid BackupBuddy backup archive with its original filename. Remember to delete importbuddy.php and this backup file from your server after migration.', '', true); } ?> </div> </div> </div> </div> <div style="margin-left: 20px; margin-top: 12px;"> <span class="toggle button-secondary" id="serverinfo">Server Information</span> <span class="toggle button-secondary" id="advanced">Advanced Configuration Options</span>
<input type="checkbox" name="wipe_database" onclick=" if ( !confirm( 'WARNING! WARNING! WARNING! WARNING! WARNING! \n\nThis will clear any existing WordPress installation or other content in this database. This could result in loss of posts, comments, pages, settings, and other software data loss. Verify you are using the exact database settings you want to be using. PluginBuddy & all related persons hold no responsibility for any loss of data caused by using this option. \n\n Are you sure you want to do this and potentially wipe existing data? \n\n WARNING! WARNING! WARNING! WARNING! WARNING!' ) ) { return false; } " <?php if ( $this->_options['wipe_database'] == '1' ) echo 'checked'; ?>> Wipe database on import. Use with caution. <?php $this->tip( 'WARNING: Checking this box will have this script clear ALL existing data from your database prior to import, including non-WordPress data. This is useful if you are restoring over an existing site or for repaired a failed migration. Use caution when using this option.' ); ?><br> <input type="checkbox" name="skip_database_import" <?php if ( $this->_options['skip_database_import'] == '1' ) echo 'checked'; ?>> Skip import of database. <br> <input type="checkbox" name="skip_database_migration" <?php if ( $this->_options['skip_database_migration'] == '1' ) echo 'checked'; ?>> Skip migration of database. <br> <br> <b>After importing, skip data migration on these tables:</b><?php $this->tip( 'Database tables to exclude from migration. These tables will still be imported into the database but URLs and paths will not be modified. This is useful if the migration is timing out.' ); ?><br><textarea name="exclude_tables" style="width: 300px; height: 75px;"></textarea> </div> */ ?> <div style="display: none; background-color: #F1EDED; -moz-border-radius:4px 4px 4px 4px; border:1px solid #DFDFDF; margin:10px; padding:3px; margin-left: 135px;" id="ithemes_loading"> <?php echo ezimg::genImageTag('loading.gif') . ' Loading ...'; ?> </div> </div> <?php if ($this->_options['force_high_security'] != false || isset($this->_backupdata['high_security']) && $this->_backupdata['high_security'] === true) { ?> <label> </label><br> <h3>Create Administrator Account <?php $this->tip('Your backup was created either with High Security Mode enabled or from a WordPress Multisite installation. For security your must provide a WordPress username and password to grant administrator privileges to.', '', true); ?> </h3> <label> New admin username </label>