public/wordpress/wp-content/plugins/backupbuddy/classes/core.php
/* deploymentImportBuddy()
	 *
	 * Renders importbuddy on this server.
	 *
	 * @param	string			$backupFile				Full filename with path to backup file to import.
	 * @param	string			$additionalStateInfo	Array of additional state information to merge into state array, such as session tokens.
	 * @return	string|array 							If string then importbuddy serial.  If array then an error has been encountered. Array format: array( false, 'Error message.' ).
	 *
	 */
deploymentImportBuddy()
Renders importbuddy on this server.

@param       string                  $backupFile                             Full filename with path to backup file to import.
@param       string                  $additionalStateInfo    Array of additional state information to merge into state array, such as session tokens.
@return      string|array                                                    If string then importbuddy serial.  If array then an error has been encountered. Array format: array( false, 'Error message.' ).
deploymentImportBuddy () Renders importbuddy on this server . @param string $backupFile Full filename with path to backup file to import . @param string $additionalStateInfo Array of additional state information to merge into state array such as session tokens . @return string|array If string then importbuddy serial . If array then an error has been encountered . Array format : array ( false ' Error message . ' ) .
public static function deploymentImportBuddy( $password, $backupFile, $additionalStateInfo = '', $doCleanup = true ) {
		if ( ! file_exists( $backupFile ) ) {
			$error = 'Error #43848378: Backup file `' . $backupFile . '` not found uploaded.';
			pb_backupbuddy::status( 'error', $error);
			return array( false, $error );
		}
		if ( true === $doCleanup ) {
			pb_backupbuddy::status( 'details', 'NOT skipping cleanup procedures at end of importbuddy Deployment based on advanced Deployment settings.' );
		} else {
			pb_backupbuddy::status( 'details', 'SKIPPING CLEANUP procedures at end of importbuddy Deployment based on advanced Deployment settings.' );
		}
		$backupSerial = backupbuddy_core::get_serial_from_file( $backupFile );
		$importFileSerial = pb_backupbuddy::random_string( 15 );
		$importFilename = 'importbuddy-' . $importFileSerial . '.php';
		backupbuddy_core::importbuddy( ABSPATH . $importFilename, $password );
		$state = array();
		global $wpdb;
		$state['type'] = 'deploy';
		$state['archive'] = $backupFile;
		$state['siteurl'] = preg_replace( '|/*$|', '', site_url() ); 
		$state['homeurl'] = preg_replace( '|/*$|', '', home_url() ); 
		$state['restoreFiles'] = false;
		$state['migrateHtaccess'] = false;
		$state['remote_api'] = pb_backupbuddy::$options['remote_api']; 
		$state['databaseSettings']['server'] = DB_HOST;
		$state['databaseSettings']['database'] = DB_NAME;
		$state['databaseSettings']['username'] = DB_USER;
		$state['databaseSettings']['password'] = DB_PASSWORD;
		$state['databaseSettings']['prefix'] = $wpdb->prefix;
		$state['databaseSettings']['renamePrefix'] = true;
		$state['cleanup']['deleteImportBuddy'] = $doCleanup;
		$state['cleanup']['deleteImportBuddyDirectory'] = $doCleanup;
		$state['cleanup']['deleteImportLog'] = $doCleanup;
		if ( is_array( $additionalStateInfo ) ) {
			$state = array_merge_recursive( $state, $additionalStateInfo );
		}
		$state_file = ABSPATH . 'importbuddy-' . $importFileSerial . '-state.php';
		if ( false === ( $file_handle = @fopen( $state_file, 'w' ) ) ) {
			$error = 'Error #8384784: Temp state file is not creatable/writable. Check your permissions. (' . $state_file . ')' ;
			pb_backupbuddy::status( 'error', $error);
			return array( false, $error );
		}
		fwrite( $file_handle, "<?php die('Access Denied.'); // <!-- ?>\n" . base64_encode( json_encode( $state ) ) );
		fclose( $file_handle );
		$undoFile = 'backupbuddy_deploy_undo-' . $backupSerial . '.php';
		if ( false === copy( pb_backupbuddy::plugin_path() . '/classes/_rollback_undo.php', ABSPATH . $undoFile ) ) {
			$error = 'Error #3289447: Unable to write undo file `' . ABSPATH . $undoFile . '`. Check permissions on directory.' ;
			pb_backupbuddy::status( 'error', $error);
			return array( false, $error );
		}
		return $importFileSerial;
	}
public static function deploymentImportBuddy ( $ password , $ backupFile , $ additionalStateInfo = '' , $ doCleanup = true ) { if ( ! file_exists ( $ backupFile ) ) { $ error = 'Error #43848378: Backup file `' . $ backupFile . '` not found uploaded.' ; pb_backupbuddy :: status ( 'error' , $ error ) ; return array ( false , $ error ) ; } if ( true === $ doCleanup ) { pb_backupbuddy :: status ( 'details' , 'NOT skipping cleanup procedures at end of importbuddy Deployment based on advanced Deployment settings.' ) ; } else { pb_backupbuddy :: status ( 'details' , 'SKIPPING CLEANUP procedures at end of importbuddy Deployment based on advanced Deployment settings.' ) ; } $ backupSerial = backupbuddy_core :: get_serial_from_file ( $ backupFile ) ; $ importFileSerial = pb_backupbuddy :: random_string ( 15 ) ; $ importFilename = 'importbuddy-' . $ importFileSerial . '.php' ; backupbuddy_core :: importbuddy ( ABSPATH . $ importFilename , $ password ) ; $ state = array ( ) ; global $ wpdb ; $ state [ 'type' ] = 'deploy' ; $ state [ 'archive' ] = $ backupFile ; $ state [ 'siteurl' ] = preg_replace ( '|/*$|' , '' , site_url ( ) ) ; $ state [ 'homeurl' ] = preg_replace ( '|/*$|' , '' , home_url ( ) ) ; $ state [ 'restoreFiles' ] = false ; $ state [ 'migrateHtaccess' ] = false ; $ state [ 'remote_api' ] = pb_backupbuddy :: $ options [ 'remote_api' ] ; $ state [ 'databaseSettings' ] [ 'server' ] = DB_HOST ; $ state [ 'databaseSettings' ] [ 'database' ] = DB_NAME ; $ state [ 'databaseSettings' ] [ 'username' ] = DB_USER ; $ state [ 'databaseSettings' ] [ 'password' ] = DB_PASSWORD ; $ state [ 'databaseSettings' ] [ 'prefix' ] = $ wpdb -> prefix ; $ state [ 'databaseSettings' ] [ 'renamePrefix' ] = true ; $ state [ 'cleanup' ] [ 'deleteImportBuddy' ] = $ doCleanup ; $ state [ 'cleanup' ] [ 'deleteImportBuddyDirectory' ] = $ doCleanup ; $ state [ 'cleanup' ] [ 'deleteImportLog' ] = $ doCleanup ; if ( is_array ( $ additionalStateInfo ) ) { $ state = array_merge_recursive ( $ state , $ additionalStateInfo ) ; } $ state_file = ABSPATH . 'importbuddy-' . $ importFileSerial . '-state.php' ; if ( false === ( $ file_handle = @ fopen ( $ state_file , 'w' ) ) ) { $ error = 'Error #8384784: Temp state file is not creatable/writable. Check your permissions. (' . $ state_file . ')' ; pb_backupbuddy :: status ( 'error' , $ error ) ; return array ( false , $ error ) ; } fwrite ( $ file_handle , " <?php die('Access Denied.'); // <!-- ?> \n " . base64_encode ( json_encode ( $ state ) ) ) ; fclose ( $ file_handle ) ; $ undoFile = 'backupbuddy_deploy_undo-' . $ backupSerial . '.php' ; if ( false === copy ( pb_backupbuddy :: plugin_path ( ) . '/classes/_rollback_undo.php' , ABSPATH . $ undoFile ) ) { $ error = 'Error #3289447: Unable to write undo file `' . ABSPATH . $ undoFile . '`. Check permissions on directory.' ; pb_backupbuddy :: status ( 'error' , $ error ) ; return array ( false , $ error ) ; } return $ importFileSerial ; }
deploymentImportBuddy()
 Renders importbuddy on this server.
deploymentImportBuddy () Renders importbuddy on this server .
// Render default config file overrides. Overrrides default restore.php state data. // Strip trailing slashes. // Strip trailing slashes. // For use by importbuddy api auth. Enables remote api in this importbuddy. //error_log( print_r( $state, true ) ); // Write default state overrides. //$undoURL = rtrim( site_url(), '/\\' ) . '/' . $undoFile;