public/wordpress/wp-content/plugins/backupbuddy/lib/textreplacebuddy/textreplacebuddy.php
/*	replace()
	 *	
	 *	Replace all instances of a string within a file. Automatically falls back.
	 *	Resulting file stored in $file . 'tmp'. Original file is NOT replaced.
	 *
	 *	@param		string		$file				Full file path to file to search. A .tmp version is made with the final results. Original file is NOT replaced.
	 *	@param		string		$search				String to search for.
	 *	@param		string		$replacement		String to replace with.
	 *	@param		string		$regex_condition	Condition when replacements may happen. Optional.
	 *	@param		string		$regex_replace		If fallen back into PHP mode then this is needed IF $regex_condition is passed. Optional.
	 *	@return
	 */
replace()

Replace all instances of a string within a file. Automatically falls back.
Resulting file stored in $file . 'tmp'. Original file is NOT replaced.

@param          string          $file                           Full file path to file to search. A .tmp version is made with the final results. Original file is NOT replaced.
@param          string          $search                         String to search for.
@param          string          $replacement            String to replace with.
@param          string          $regex_condition        Condition when replacements may happen. Optional.
@param          string          $regex_replace          If fallen back into PHP mode then this is needed IF $regex_condition is passed. Optional.
@return
replace () Replace all instances of a string within a file . Automatically falls back . Resulting file stored in $file . ' tmp ' . Original file is NOT replaced . @param string $file Full file path to file to search . A . tmp version is made with the final results . Original file is NOT replaced . @param string $search String to search for . @param string $replacement String to replace with . @param string $regex_condition Condition when replacements may happen . Optional . @param string $regex_replace If fallen back into PHP mode then this is needed IF $regex_condition is passed . Optional . @return
public function string_replace( $file, $search, $replacement, $regex_condition = '', $regex_replace = '' ) {
		$return = false;
		pb_backupbuddy::status( 'message', 'Starting text replacement procedure.' );
		pb_backupbuddy::status( 'details', "textreplace being performed on file `{$file}` replacing `{$search}` with `{$replacement}`." );
		pb_backupbuddy::status( 'details', 'Preparing to textreplace using available method(s) by priority. Methods: `' . implode( ',', $this->_methods ) . '`' );
		foreach( $this->_methods as $method ) {
			if ( method_exists( $this, "_stringreplace_{$method}" ) ) {
				pb_backupbuddy::status( 'details', 'textreplacebuddy: Attempting replace method `' . $method . '`.' );
				$result = call_user_func( array( $this, "_stringreplace_{$method}" ), $file, $search, $replacement, $regex_condition, $regex_replace );
				if ( $result === true ) { 
					pb_backupbuddy::status( 'details', 'textreplacebuddy: Replace method `' . $method . '` completed successfully.' );
					$return = true;
					break;
				} elseif ( $result === false ) { 
					pb_backupbuddy::status( 'details', 'textreplacebuddy: Replace method `' . $method . '` failed. Trying another compatibility mode next if able.' );
				} else {
					pb_backupbuddy::status( 'details', 'textreplacebuddy: Unexepected response: `' . implode( ',', $result ) . '`' );
				}
			}
		}
		if ( $return === true ) { 
			pb_backupbuddy::status( 'message', 'Text replace procedure succeeded.' );
			return true;
		} else { 
			pb_backupbuddy::status( 'error', 'Text replace procedure failed.' );
			return false;
		}
	}
public function string_replace ( $ file , $ search , $ replacement , $ regex_condition = '' , $ regex_replace = '' ) { $ return = false ; pb_backupbuddy :: status ( 'message' , 'Starting text replacement procedure.' ) ; pb_backupbuddy :: status ( 'details' , " textreplace being performed on file ` { $ file } ` replacing ` { $ search } ` with ` { $ replacement } `. " ) ; pb_backupbuddy :: status ( 'details' , 'Preparing to textreplace using available method(s) by priority. Methods: `' . implode ( ',' , $ this -> _methods ) . '`' ) ; foreach ( $ this -> _methods as $ method ) { if ( method_exists ( $ this , " _stringreplace_ { $ method } " ) ) { pb_backupbuddy :: status ( 'details' , 'textreplacebuddy: Attempting replace method `' . $ method . '`.' ) ; $ result = call_user_func ( array ( $ this , " _stringreplace_ { $ method } " ) , $ file , $ search , $ replacement , $ regex_condition , $ regex_replace ) ; if ( $ result === true ) { pb_backupbuddy :: status ( 'details' , 'textreplacebuddy: Replace method `' . $ method . '` completed successfully.' ) ; $ return = true ; break ; } elseif ( $ result === false ) { pb_backupbuddy :: status ( 'details' , 'textreplacebuddy: Replace method `' . $ method . '` failed. Trying another compatibility mode next if able.' ) ; } else { pb_backupbuddy :: status ( 'details' , 'textreplacebuddy: Unexepected response: `' . implode ( ',' , $ result ) . '`' ) ; } } } if ( $ return === true ) { pb_backupbuddy :: status ( 'message' , 'Text replace procedure succeeded.' ) ; return true ; } else { pb_backupbuddy :: status ( 'error' , 'Text replace procedure failed.' ) ; return false ; } }
replace()
replace ()
// Attempt each method in order. // Dump completed succesfully with this method. // Dump failed this method. Will try compatibility fallback to next mode if able. // Do nothing. Will try next mode next loop. // Success. // Overall failure.