public/wordpress/wp-content/plugins/backupbuddy/lib/zipbuddy/zbzipexec.php
/**
		 *	extract_generic_full()
		 *
		 *	Extracts the contents of a zip file to the specified directory using the best unzip methods possible.
		 *
		 *	@param	string		$zip_file					Full path & filename of ZIP file to extract from.
		 *	@param	string		$destination_directory		Full directory path to extract into.
		 *	@return	bool									true on success, false otherwise
		 */
extract_generic_full()
Extracts the contents of a zip file to the specified directory using the best unzip methods possible.

@param  string          $zip_file                                       Full path & filename of ZIP file to extract from.
@param  string          $destination_directory          Full directory path to extract into.
@return bool                                                                    true on success, false otherwise
extract_generic_full () Extracts the contents of a zip file to the specified directory using the best unzip methods possible . @param string $zip_file Full path & filename of ZIP file to extract from . @param string $destination_directory Full directory path to extract into . @return bool true on success false otherwise
protected function extract_generic_full( $zip_file, $destination_directory = '' ) {
			$summary = '';
			$output = array();
			$exit_code = 127;
			$matches = array();
			$result = false;
			$zippath = '';
			$command = '';
			if ( function_exists( 'exec' ) ) {
				$zippath = $this->get_command_path( self::COMMAND_UNZIP_PATH );
				if ( !empty ( $zippath ) ) {
					pb_backupbuddy::status( 'details', __( 'Using absolute unzip path: ','it-l10n-backupbuddy' ) . $zippath );
				}
				$command = $this->slashify( $zippath ) . 'unzip';	
				$unzip_command = $command . " -qqo '{$zip_file}' -d '{$destination_directory}' -x 'importbuddy.php'";
				$unzip_command = ( self::OS_TYPE_WIN === $this->get_os_type() ) ? str_replace( '\'', '"', $unzip_command ) : $unzip_command;
				@exec( $unzip_command, $output, $exit_code);
				switch ( (int) $exit_code ) {
					case 0:
						$list_command = $command . " -ql '{$zip_file}'";
						$list_command = ( self::OS_TYPE_WIN === $this->get_os_type() ) ? str_replace( '\'', '"', $list_command ) : $list_command;
						$summary = @exec( $list_command );
						if ( preg_match("|[[:^digit:]]+(?P<byte_count>[[:digit:]]+)[[:^digit:]]+(?P<file_count>[[:digit:]]+)[[:space:]]+(files)|", $summary, $matches ) ) {
							$file_count = $matches[ 'file_count' ];
						} else {
							$file_count = 0;
						}
						pb_backupbuddy::status( 'details', sprintf( __('exec (unzip) extracted file contents (%1$s to %2$s)','it-l10n-backupbuddy' ), $zip_file, $destination_directory ) );
						$this->log_archive_file_stats( $zip_file );
						$result = true;
						break;
					default:
						$error_string = $exit_code;
						pb_backupbuddy::status( 'details', sprintf( __('exec (unzip) failed to open/process file to extract contents (%1$s to %2$s) - Error Info: %3$s.','it-l10n-backupbuddy' ), $zip_file, $destination_directory, $error_string ) );
						$result = false;
				}
			} else {
				pb_backupbuddy::status( 'details', __('exec indicated as available method but exec function non-existent','it-l10n-backupbuddy' ) );
				$result = false;
			}
			return $result;
		}
protected function extract_generic_full ( $ zip_file , $ destination_directory = '' ) { $ summary = '' ; $ output = array ( ) ; $ exit_code = 127 ; $ matches = array ( ) ; $ result = false ; $ zippath = '' ; $ command = '' ; if ( function_exists ( 'exec' ) ) { $ zippath = $ this -> get_command_path ( self :: COMMAND_UNZIP_PATH ) ; if ( ! empty ( $ zippath ) ) { pb_backupbuddy :: status ( 'details' , __ ( 'Using absolute unzip path: ' , 'it-l10n-backupbuddy' ) . $ zippath ) ; } $ command = $ this -> slashify ( $ zippath ) . 'unzip' ; $ unzip_command = $ command . "  -qqo ' { $ zip_file } ' -d ' { $ destination_directory } ' -x 'importbuddy.php' " ; $ unzip_command = ( self :: OS_TYPE_WIN === $ this -> get_os_type ( ) ) ? str_replace ( '\'' , '"' , $ unzip_command ) : $ unzip_command ; @ exec ( $ unzip_command , $ output , $ exit_code ) ; switch ( ( int ) $ exit_code ) { case 0 : $ list_command = $ command . "  -ql ' { $ zip_file } ' " ; $ list_command = ( self :: OS_TYPE_WIN === $ this -> get_os_type ( ) ) ? str_replace ( '\'' , '"' , $ list_command ) : $ list_command ; $ summary = @ exec ( $ list_command ) ; if ( preg_match ( " |[[:^digit:]]+(?P<byte_count>[[:digit:]]+)[[:^digit:]]+(?P<file_count>[[:digit:]]+)[[:space:]]+(files)| " , $ summary , $ matches ) ) { $ file_count = $ matches [ 'file_count' ] ; } else { $ file_count = 0 ; } pb_backupbuddy :: status ( 'details' , sprintf ( __ ( 'exec (unzip) extracted file contents (%1$s to %2$s)' , 'it-l10n-backupbuddy' ) , $ zip_file , $ destination_directory ) ) ; $ this -> log_archive_file_stats ( $ zip_file ) ; $ result = true ; break ; default : $ error_string = $ exit_code ; pb_backupbuddy :: status ( 'details' , sprintf ( __ ( 'exec (unzip) failed to open/process file to extract contents (%1$s to %2$s) - Error Info: %3$s.' , 'it-l10n-backupbuddy' ) , $ zip_file , $ destination_directory , $ error_string ) ) ; $ result = false ; } } else { pb_backupbuddy :: status ( 'details' , __ ( 'exec indicated as available method but exec function non-existent' , 'it-l10n-backupbuddy' ) ) ; $ result = false ; } return $ result ; }
extract_generic_full()
      Extracts the contents of a zip file to the specified directory using the best unzip methods possible.
extract_generic_full () Extracts the contents of a zip file to the specified directory using the best unzip methods possible .
// Get the command path for the unzip command - should return a trimmed string // Determine if we are using an absolute path // Add the trailing slash if required // We'll try and extract from the backup file to the given directory, very quietly with overwrite // If we just did -o we could try and get file count from processing $output but it would be a bit time-consuming // Note: we don't open the file and then do stuff but it's all done in one action // so we need to interpret the return code to dedide what to do // Handled archive and apparently no extraction problems // Now we have to do a second run to find out the file count (crazy) //$summary = @exec( $list_command, $output, $exit_code); // Currently don't bother to check exit code, if we failed then whatever we got back in // Last output line _should_ have the information we need (and that is returned by exec) // $summary is unlikely to match the pattern so file count will just default to 0 // Should be able to pull this straight out provided the unzip version stuck to the rules // Some reason we didn't get good output or the format is odd // For now let's just print the error code and drop through // Return an error code and a description - this needs to be handled more generically //$result = array( 1, "Unable to get archive contents" ); // Currently as we are returning an array as a valid result we just return false on failure // Something fishy - the methods indicated exec but we couldn't find the function // Return an error code and a description - this needs to be handled more generically //$result = array( 1, "Class not available to match method" ); // Currently as we are returning an array as a valid result we just return false on failure