public/wordpress/wp-content/plugins/backupbuddy/lib/dbreplace/dbreplace.php
/**
		 *	replace_maybe_serialized()
		 *	
		 *	Replaces possibly serialized (or non-serialized) text if a change is needed. Returns false if there was no change.
		 *  Note: As of BB v3.2.x supports double serialized data.
		 *	
		 *	@param		string		$table		Text (possibly serialized) to update.
		 *	@param		mixed		$olds		Text to search for to replace. May be an array of strings to search for.
		 *	@param		mixed		$news		New value(s) to be replaced with. May be a string or array. If array there must be the same number of values as $olds.
		 *	@return		mixed					Returns modified string data if serialized data was replaced. False if no change was made.
		 *
		 */


Replaces possibly serialized (or non-serialized) text if a change is needed. Returns false if there was no change.
Note: As of BB v3.2.x supports double serialized data.

@param          string          $table          Text (possibly serialized) to update.
@param          mixed           $olds           Text to search for to replace. May be an array of strings to search for.
@param          mixed           $news           New value(s) to be replaced with. May be a string or array. If array there must be the same number of values as $olds.
@return         mixed                                   Returns modified string data if serialized data was replaced. False if no change was made.
Replaces possibly serialized ( or non - serialized ) text if a change is needed . Returns false if there was no change . Note : As of BB v3 . 2 . x supports double serialized data . @param string $table Text ( possibly serialized ) to update . @param mixed $olds Text to search for to replace . May be an array of strings to search for . @param mixed $news New value ( s ) to be replaced with . May be a string or array . If array there must be the same number of values as $olds . @return mixed Returns modified string data if serialized data was replaced . False if no change was made .
function replace_maybe_serialized( $data, $olds, $news ) {
			if ( !is_array( $olds ) ) {
				$olds = array( $olds );
			}
			if ( !is_array( $news ) ) {
				$news = array( $news );
			}
			$type = '';
			$unserialized = false; 
			if ( is_serialized( $data ) ) { 
				$unserialized = @unserialize( $data ); 
			}
			if ( $unserialized !== false ) { 
				$type = 'serialized';
				$double_serialized = false;
				if ( is_serialized( $unserialized ) ) { 
					$unserialized = @unserialize( $unserialized ); 
					$double_serialized = true;
				}
				$i = 0;
				foreach ( $olds as $old ) {
					$this->recursive_array_replace( $old, $news[$i], $unserialized );
					$i++;
				}
				$edited_data = serialize( $unserialized );
				if ( true === $double_serialized ) {
					$edited_data = serialize( $edited_data );
				}
			}	else { 
				$type = 'text';
				$edited_data = $data;
				$i = 0;
				foreach ( $olds as $old ) {
					$edited_data =str_ireplace( $old, $news[$i], $edited_data );
					$i++;
				}
			}
			if ( $data != $edited_data ) {
				return $edited_data;
			} else {
				return false;
			}
		}
function replace_maybe_serialized ( $ data , $ olds , $ news ) { if ( ! is_array ( $ olds ) ) { $ olds = array ( $ olds ) ; } if ( ! is_array ( $ news ) ) { $ news = array ( $ news ) ; } $ type = '' ; $ unserialized = false ; if ( is_serialized ( $ data ) ) { $ unserialized = @ unserialize ( $ data ) ; } if ( $ unserialized !== false ) { $ type = 'serialized' ; $ double_serialized = false ; if ( is_serialized ( $ unserialized ) ) { $ unserialized = @ unserialize ( $ unserialized ) ; $ double_serialized = true ; } $ i = 0 ; foreach ( $ olds as $ old ) { $ this -> recursive_array_replace ( $ old , $ news [ $ i ] , $ unserialized ) ; $ i ++ ; } $ edited_data = serialize ( $ unserialized ) ; if ( true === $ double_serialized ) { $ edited_data = serialize ( $ edited_data ) ; } } else { $ type = 'text' ; $ edited_data = $ data ; $ i = 0 ; foreach ( $ olds as $ old ) { $ edited_data = str_ireplace ( $ old , $ news [ $ i ] , $ edited_data ) ; $ i ++ ; } } if ( $ data != $ edited_data ) { return $ edited_data ; } else { return false ; } }
replace_maybe_serialized()
replace_maybe_serialized ()
// first assume not serialized data // check if this is serialized data // unserialise - if false is returned we won't try to process it as serialised. // Serialized data. // double-serialized data (opposite of a double rainbow). Some plugins seem to double-serialize for some unknown wacky reason... // unserialise - if false is returned we won't try to process it as serialised. // Non-serialized data. // Return the results.