public/wordpress/wp-content/plugins/backupbuddy/destinations/local/init.php
/*	test()
	 *	
	 *	Tests ability to write to this remote destination.
	 *	TODO: Should this delete the temporary test directory to clean up after itself?
	 *	
	 *	@param		array			$settings	Destination settings.
	 *	@return		bool|string					True on success, string error message on failure.
	 */
test()

Tests ability to write to this remote destination.

@param          array                   $settings       Destination settings.
@return         bool|string                                     True on success, string error message on failure.
test () Tests ability to write to this remote destination . @param array $settings Destination settings . @return bool|string True on success string error message on failure .
public static function test( $settings, $files = array() ) {
		$path = rtrim( $settings['path'], '/\\' );
		$url = rtrim( $settings['url'], '/\\' );
		if ( !file_exists( $path ) ) {
			pb_backupbuddy::$filesystem->mkdir( $path );
		}
		if ( is_writable( $path ) !== true ) {
			return __('Failure', 'it-l10n-backupbuddy' ) . '; The path does not allow writing. Please verify write file permissions.';
		}
		if ( $url != '' ) {
			$test_filename = 'migrate_test_' . pb_backupbuddy::random_string( 10 ) . '.php';
			$test_file_path = $path . '/' . $test_filename;
			$test_file_url = $url . '/' . $test_filename;
			file_put_contents( $test_file_path, "<?php die( '1' ); ?>" );
			pb_backupbuddy::status( 'details', 'Local test: Veryifing `' . $test_file_url . '` points to `' . $test_file_path . '`.' );
			$response = wp_remote_get( $test_file_url, array(
					'method' => 'GET',
					'timeout' => 45,
					'redirection' => 5,
					'httpversion' => '1.0',
					'blocking' => true,
					'headers' => array(),
					'body' => null,
					'cookies' => array()
				)
			);
			unlink( $test_file_path );
			if ( is_wp_error( $response ) ) {
				return __( 'Failure. Unable to connect to the provided URL.', 'it-l10n-backupbuddy' );
			}
			if ( trim( $response['body'] ) != '1' ) {
				return __('Failure. The path appears valid but the URL does not correspond to it. Leave the URL blank if not using this destination for migrations.', 'it-l10n-backupbuddy' );
			}
		}
		return true;
	}
public static function test ( $ settings , $ files = array ( ) ) { $ path = rtrim ( $ settings [ 'path' ] , '/\\' ) ; $ url = rtrim ( $ settings [ 'url' ] , '/\\' ) ; if ( ! file_exists ( $ path ) ) { pb_backupbuddy :: $ filesystem -> mkdir ( $ path ) ; } if ( is_writable ( $ path ) !== true ) { return __ ( 'Failure' , 'it-l10n-backupbuddy' ) . '; The path does not allow writing. Please verify write file permissions.' ; } if ( $ url != '' ) { $ test_filename = 'migrate_test_' . pb_backupbuddy :: random_string ( 10 ) . '.php' ; $ test_file_path = $ path . '/' . $ test_filename ; $ test_file_url = $ url . '/' . $ test_filename ; file_put_contents ( $ test_file_path , " <?php die( '1' ); ?> " ) ; pb_backupbuddy :: status ( 'details' , 'Local test: Veryifing `' . $ test_file_url . '` points to `' . $ test_file_path . '`.' ) ; $ response = wp_remote_get ( $ test_file_url , array ( 'method' => 'GET' , 'timeout' => 45 , 'redirection' => 5 , 'httpversion' => '1.0' , 'blocking' => true , 'headers' => array ( ) , 'body' => null , 'cookies' => array ( ) ) ) ; unlink ( $ test_file_path ) ; if ( is_wp_error ( $ response ) ) { return __ ( 'Failure. Unable to connect to the provided URL.' , 'it-l10n-backupbuddy' ) ; } if ( trim ( $ response [ 'body' ] ) != '1' ) { return __ ( 'Failure. The path appears valid but the URL does not correspond to it. Leave the URL blank if not using this destination for migrations.' , 'it-l10n-backupbuddy' ) ; } } return true ; }
test()
test ()
// Make file. // Test URL points to file. // Made it this far so success.