public/wordpress/wp-content/plugins/backupbuddy/lib/zipbuddy/zbzipexec.php
/**
		 *	file_exists_generic()
		 *	
		 *	Tests whether a file (with path) exists in the given zip file
		 *	
		 *	@param		string	$zip_file		The zip file to check
		 *	@param		string	$locate_file	The file to test for
		 *	@return		bool/array				True if the file is found in the zip and false if not, array for other problem
		 *
		 */


Tests whether a file (with path) exists in the given zip file

@param          string  $zip_file               The zip file to check
@param          string  $locate_file    The file to test for
@return         bool/array                              True if the file is found in the zip and false if not, array for other problem
Tests whether a file ( with path ) exists in the given zip file @param string $zip_file The zip file to check @param string $locate_file The file to test for @return bool / array True if the file is found in the zip and false if not array for other problem
public function file_exists_generic( $zip_file, $locate_file ) {
			$result = array( 1, "Generic failure indication" );
			$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';	
				$command .= " -qt '{$zip_file}' '{$locate_file}'";
				$command = ( self::OS_TYPE_WIN === $this->get_os_type() ) ? str_replace( '\'', '"', $command ) : $command;
				@exec( $command, $output, $exit_code);
				switch ( (int) $exit_code ) {
					case 0:
						pb_backupbuddy::status( 'details', __('File found (exec)','it-l10n-backupbuddy' ) . ': ' . $locate_file );
						$result = true;
						break;
					case 11:
						pb_backupbuddy::status( 'details', __('File not found (exec)','it-l10n-backupbuddy' ) . ': ' . $locate_file );
						$result = false;
						break;
					default:
						$error_string = $exit_code;
						pb_backupbuddy::status( 'details', sprintf( __('exec (unzip) failed to open/process file to check if file exists (looking for %1$s in %2$s) - Error Info: %3$s.','it-l10n-backupbuddy' ), $locate_file , $zip_file, $error_string ) );
						$result = array( 1, "Failed to open/process file" );
				}
			} else {
				pb_backupbuddy::status( 'details', __('exec indicated as available method but exec function non-existent','it-l10n-backupbuddy' ) );
				$result = array( 1, "Function not available to match method" );
			}
			return $result;
		}
public function file_exists_generic ( $ zip_file , $ locate_file ) { $ result = array ( 1 , " Generic failure indication " ) ; $ 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' ; $ command .= "  -qt ' { $ zip_file } ' ' { $ locate_file } ' " ; $ command = ( self :: OS_TYPE_WIN === $ this -> get_os_type ( ) ) ? str_replace ( '\'' , '"' , $ command ) : $ command ; @ exec ( $ command , $ output , $ exit_code ) ; switch ( ( int ) $ exit_code ) { case 0 : pb_backupbuddy :: status ( 'details' , __ ( 'File found (exec)' , 'it-l10n-backupbuddy' ) . ': ' . $ locate_file ) ; $ result = true ; break ; case 11 : pb_backupbuddy :: status ( 'details' , __ ( 'File not found (exec)' , 'it-l10n-backupbuddy' ) . ': ' . $ locate_file ) ; $ result = false ; break ; default : $ error_string = $ exit_code ; pb_backupbuddy :: status ( 'details' , sprintf ( __ ( 'exec (unzip) failed to open/process file to check if file exists (looking for %1$s in %2$s) - Error Info: %3$s.' , 'it-l10n-backupbuddy' ) , $ locate_file , $ zip_file , $ error_string ) ) ; $ result = array ( 1 , " Failed to open/process file " ) ; } } else { pb_backupbuddy :: status ( 'details' , __ ( 'exec indicated as available method but exec function non-existent' , 'it-l10n-backupbuddy' ) ) ; $ result = array ( 1 , " Function not available to match method " ) ; } return $ result ; }
file_exists_generic()
file_exists_generic ()
// 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 // Try an archive test on the file and we'll just look at the return code // 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 indicate // Handled archive and file found and checked out ok so return success // No problem handling archive but file simply not found so return failure // 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 // 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