public/wordpress/wp-content/plugins/backupbuddy/lib/textreplacebuddy/textreplacebuddy.php
/*	_stringreplace_php()
	 *	
	 *	Performs actual command line string replacement. VIA PHP.
	 *	Case sensitive.
	 *	Resulting file stored in $file . 'tmp'.
	 *	
	 *	@param		string		$file				Full file path to file to replace in. a .tmp version is temporarily made.
	 *	@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		boolean							True on success; else false.
	 */


Performs actual command line string replacement. VIA PHP.
Case sensitive.
Resulting file stored in $file .

@param          string          $file                           Full file path to file to replace in. a .tmp version is temporarily made.
@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         boolean                                                 True on success; else false.
Performs actual command line string replacement . VIA PHP . Case sensitive . Resulting file stored in $file . @param string $file Full file path to file to replace in . a . tmp version is temporarily made . @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 boolean True on success ; else false .
private function _stringreplace_php( $file, $search, $replacement, $regex_condition = '', $regex_replace = '' ) {
		pb_backupbuddy::status( 'details', 'textreplacebuddy: Starting comptibility mode PHP text replacement.' );
		$file_o = fopen( $file, 'r' );
		$temp = $file . '.tmp';
		if ( !is_writable( $temp ) ) {
			pb_backupbuddy::status( 'error', 'textreplacebuddy: Permission denied writing temporary file `' . $temp . '`.' );
			return false;
		}
		if ( is_resource( $file_o ) === true ) {
			while ( feof( $file_o ) === false ) {
				if ( $regex_condition != '' ) { 
					$content = preg_replace( "/^{$regex_condition}/i", $regex_replace, fgets( $file_o ) );
				} else { 
					$content = str_replace( $search, $replacement, fgets( $file_o ) );
				}
				file_put_contents( $temp, $content, FILE_APPEND );
			}
			fclose( $file_o );
		}
		return $result;
	}
private function _stringreplace_php ( $ file , $ search , $ replacement , $ regex_condition = '' , $ regex_replace = '' ) { pb_backupbuddy :: status ( 'details' , 'textreplacebuddy: Starting comptibility mode PHP text replacement.' ) ; $ file_o = fopen ( $ file , 'r' ) ; $ temp = $ file . '.tmp' ; if ( ! is_writable ( $ temp ) ) { pb_backupbuddy :: status ( 'error' , 'textreplacebuddy: Permission denied writing temporary file `' . $ temp . '`.' ) ; return false ; } if ( is_resource ( $ file_o ) === true ) { while ( feof ( $ file_o ) === false ) { if ( $ regex_condition != '' ) { $ content = preg_replace ( " /^ { $ regex_condition } /i " , $ regex_replace , fgets ( $ file_o ) ) ; } else { $ content = str_replace ( $ search , $ replacement , fgets ( $ file_o ) ) ; } file_put_contents ( $ temp , $ content , FILE_APPEND ) ; } fclose ( $ file_o ) ; } return $ result ; }
_stringreplace_php()
_stringreplace_php ()
// regex // standard string //unlink($file); /*
		$result = rename( $temp, $file );
		if ( $result === false ) {
			pb_backupbuddy::status( 'error', 'textreplacebuddy: Unable to move temporary file back to original file. Failure.' );
		} else {
			pb_backupbuddy::status( 'details', 'textreplacebuddy: Moved temporary file back to original file. Success.' );
		}
		*/