public/wordpress/wp-content/plugins/backupbuddy/lib/xzipbuddy/zipbuddy.php
/**
		 *	create_empty_zip()
		 *	
		 *	A function that creates an empty archive file with optional comment
		 *	
		 *	Create an empty zip archive (just the end of central dir) with an optional
		 *	comment as well. This has a well known basic structure and content so we can
		 *	write it directly as binary data.
		 *	
		 *	@param		string	$zip			Full path & filename of ZIP Archive file to create
		 *	@param		string	$tempdir		Full path of directory for temporary usage
		 *	@param		string	$comment		Comment to apply to archive. (optional)
		 *	@return		bool					True if the creation was successful, false otherwise
		 *
		 */


A function that creates an empty archive file with optional comment

Create an empty zip archive (just the end of central dir) with an optional
comment as well. This has a well known basic structure and content so we can
write it directly as binary data.

@param          string  $zip                    Full path & filename of ZIP Archive file to create
@param          string  $tempdir                Full path of directory for temporary usage
@param          string  $comment                Comment to apply to archive. (optional)
@return         bool                                    True if the creation was successful, false otherwise
A function that creates an empty archive file with optional comment Create an empty zip archive ( just the end of central dir ) with an optional comment as well . This has a well known basic structure and content so we can write it directly as binary data . @param string $zip Full path & filename of ZIP Archive file to create @param string $tempdir Full path of directory for temporary usage @param string $comment Comment to apply to archive . ( optional ) @return bool True if the creation was successful false otherwise
public function create_empty_zip( $zip, $tempdir, $comment = '' ) {
			$result = false;
			$zip_file_name = $tempdir . basename( $zip );
			$this->log( 'details', sprintf( __( 'Zip process reported: Initializing zip archive file: %1$s', 'it-l10n-backupbuddy' ), $zip_file_name ) );
			try {
				$zip_file = new SplFileObject( $zip_file_name, "wb" );
				if ( is_array( $comment ) ) {
					$comment = json_encode( $comment );
				}
				if ( 0 != strlen( $comment ) ) {
					$comment = 'MetaData:' . $comment . 'MetaData-End:';
				}
				$binary_data = pack( "VvvvvVVv", 0x06054b50, 0, 0, 0, 0, 0, 0, strlen( $comment ) );
				$zip_file->fwrite( $binary_data, 22 );
				if ( 0 != strlen( $comment ) ) {
				  $zip_file->fwrite( $comment, strlen( $comment ) );
				}
				unset( $zip_file );
				$this->log( 'details', sprintf( __( 'Zip process reported: Initialized zip archive file', 'it-l10n-backupbuddy' ) ) );
				$result = true;
			} catch ( Exception $e ) {
				$error_string = $e->getMessage();
				$this->log( 'details', sprintf( __('Zip process reported: Failure to initialize zip archive file - error reported: %1$s','it-l10n-backupbuddy' ), $error_string ) );
			}
			return $result;
		}
public function create_empty_zip ( $ zip , $ tempdir , $ comment = '' ) { $ result = false ; $ zip_file_name = $ tempdir . basename ( $ zip ) ; $ this -> log ( 'details' , sprintf ( __ ( 'Zip process reported: Initializing zip archive file: %1$s' , 'it-l10n-backupbuddy' ) , $ zip_file_name ) ) ; try { $ zip_file = new SplFileObject ( $ zip_file_name , " wb " ) ; if ( is_array ( $ comment ) ) { $ comment = json_encode ( $ comment ) ; } if ( 0 != strlen ( $ comment ) ) { $ comment = 'MetaData:' . $ comment . 'MetaData-End:' ; } $ binary_data = pack ( " VvvvvVVv " , 0x06054b50 , 0 , 0 , 0 , 0 , 0 , 0 , strlen ( $ comment ) ) ; $ zip_file -> fwrite ( $ binary_data , 22 ) ; if ( 0 != strlen ( $ comment ) ) { $ zip_file -> fwrite ( $ comment , strlen ( $ comment ) ) ; } unset ( $ zip_file ) ; $ this -> log ( 'details' , sprintf ( __ ( 'Zip process reported: Initialized zip archive file' , 'it-l10n-backupbuddy' ) ) ) ; $ result = true ; } catch ( Exception $ e ) { $ error_string = $ e -> getMessage ( ) ; $ this -> log ( 'details' , sprintf ( __ ( 'Zip process reported: Failure to initialize zip archive file - error reported: %1$s' , 'it-l10n-backupbuddy' ) , $ error_string ) ) ; } return $ result ; }
create_empty_zip()
create_empty_zip ()
// Encode $comment if an array. // Don't add an empty comment - so if the encoded string is empty or an empty // string was passed in originally don't do anything. // ----- Packed data // ----- Write the 22 bytes of the header in the zip file // ----- Write the variable fields