public/wordpress/wp-content/plugins/backupbuddy/classes/backup.php
/*	ms_create_wp_config()
	 *	
	 *	Used by Multisite Exporting.
	 *	Creates a standalone wp-config.php file for making a standalone backup from a subsite.
	 *	Authored by Ron H. Modified by Dustin B.
	 *	
	 *	@return		boolean			Currently only returns true.
	 */


Used by Multisite Exporting.
Creates a standalone wp-config.php file for making a standalone backup from a subsite.
Authored by Ron H. Modified by Dustin B.

@return         boolean                 Currently only returns true.
Used by Multisite Exporting . Creates a standalone wp - config . php file for making a standalone backup from a subsite . Authored by Ron H . Modified by Dustin B . @return boolean Currently only returns true .
public function ms_create_wp_config() {
		pb_backupbuddy::status( 'message', 'Creating new wp-config.php file for temporary WordPress installation.' );
		global $current_blog;
		$blog_id = absint( $current_blog->blog_id );
		$to_file = "<?php\n";
		$to_file .= sprintf( "define( 'DB_NAME', '%s' );\n", '' );
		$to_file .= sprintf( "define( 'DB_USER', '%s' );\n", '' );
		$to_file .= sprintf( "define( 'DB_PASSWORD', '%s' );\n", '' );
		$to_file .= sprintf( "define( 'DB_HOST', '%s' );\n", '' );
		$charset = defined( 'DB_CHARSET' ) ? DB_CHARSET : '';
		$collate = defined( 'DB_COLLATE' ) ? DB_COLLATE : '';
		$to_file .= sprintf( "define( 'DB_CHARSET', '%s' );\n", $charset );
		$to_file .= sprintf( "define( 'DB_COLLATE', '%s' );\n", $collate );
		$salts = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
		if ( !is_wp_error( $salts ) ) { 
			$to_file .= wp_remote_retrieve_body( $salts ) . "\n";
		} else { 
			pb_backupbuddy::status( 'warning', 'Error getting salts from WordPress.org for wp-config.php. You may need to manually edit your wp-config on restore. Error: `' . $salts->get_error_message() . '`.' );
		}
		$to_file .= sprintf( "define( 'WPLANG', '%s' );\n", WPLANG );
		$to_file .= sprintf( '$table_prefix = \'%s\';' . "\n", 'bbms' . $blog_id . '_' );
		$to_file .= "if ( !defined('ABSPATH') ) { \n\tdefine('ABSPATH', dirname(__FILE__) . '/'); }";
		$to_file .= "/** Sets up WordPress vars and included files. */\n
		require_once(ABSPATH . 'wp-settings.php');";
		$to_file .= "\n?>";
		$configFile = $this->_backup['backup_root'] . 'wp-config.php';
		$file_handle = fopen( $configFile, 'w' );
		fwrite( $file_handle, $to_file );
		fclose( $file_handle );
		pb_backupbuddy::status( 'message', 'Temporary WordPress wp-config.php file created at `' . $configFile . '`.' );
		return true;
	}
public function ms_create_wp_config ( ) { pb_backupbuddy :: status ( 'message' , 'Creating new wp-config.php file for temporary WordPress installation.' ) ; global $ current_blog ; $ blog_id = absint ( $ current_blog -> blog_id ) ; $ to_file = " <?php \n " ; $ to_file .= sprintf ( " define( 'DB_NAME', '%s' ); \n " , '' ) ; $ to_file .= sprintf ( " define( 'DB_USER', '%s' ); \n " , '' ) ; $ to_file .= sprintf ( " define( 'DB_PASSWORD', '%s' ); \n " , '' ) ; $ to_file .= sprintf ( " define( 'DB_HOST', '%s' ); \n " , '' ) ; $ charset = defined ( 'DB_CHARSET' ) ? DB_CHARSET : '' ; $ collate = defined ( 'DB_COLLATE' ) ? DB_COLLATE : '' ; $ to_file .= sprintf ( " define( 'DB_CHARSET', '%s' ); \n " , $ charset ) ; $ to_file .= sprintf ( " define( 'DB_COLLATE', '%s' ); \n " , $ collate ) ; $ salts = wp_remote_get ( 'https://api.wordpress.org/secret-key/1.1/salt/' ) ; if ( ! is_wp_error ( $ salts ) ) { $ to_file .= wp_remote_retrieve_body ( $ salts ) . " \n " ; } else { pb_backupbuddy :: status ( 'warning' , 'Error getting salts from WordPress.org for wp-config.php. You may need to manually edit your wp-config on restore. Error: `' . $ salts -> get_error_message ( ) . '`.' ) ; } $ to_file .= sprintf ( " define( 'WPLANG', '%s' ); \n " , WPLANG ) ; $ to_file .= sprintf ( '$table_prefix = \'%s\';' . " \n " , 'bbms' . $ blog_id . '_' ) ; $ to_file .= " if ( !defined('ABSPATH') ) {  \n \t define('ABSPATH', dirname(__FILE__) . '/'); } " ; $ to_file .= " /** Sets up WordPress vars and included files. */ \n 
		require_once(ABSPATH . 'wp-settings.php'); " ; $ to_file .= " \n ?> " ; $ configFile = $ this -> _backup [ 'backup_root' ] . 'wp-config.php' ; $ file_handle = fopen ( $ configFile , 'w' ) ; fwrite ( $ file_handle , $ to_file ) ; fclose ( $ file_handle ) ; pb_backupbuddy :: status ( 'message' , 'Temporary WordPress wp-config.php file created at `' . $ configFile . '`.' ) ; return true ; }
ms_create_wp_config()
ms_create_wp_config ()
//Step 3 - Create new WP-Config File //Attempt to remotely retrieve salts // Success. // Failed. //Create the file, save, and close