public/wordpress/wp-content/plugins/backupbuddy/classes/core.php
/* truncate_file_beginning()
	 *
	 * Truncates a file from the BEGINNING. Eg for trimming logs while leaving the most recent (at the bottom) content.
	 *
	 */
truncate_file_beginning()
Truncates a file from the BEGINNING. Eg for trimming logs while leaving the most recent (at the bottom) content.
truncate_file_beginning () Truncates a file from the BEGINNING . Eg for trimming logs while leaving the most recent ( at the bottom ) content .
public static function truncate_file_beginning_slow($filename,$maxfilesize,$keepPercent = 50 ){
		$size=filesize($filename);
		if ($size<$maxfilesize) return;
		pb_backupbuddy::status( 'details', 'Truncating LARGE file `' . $filename . '` of size `' . pb_backupbuddy::$format->file_size( $size ) . '` exceeding threshold, only keeping newest ' . $keepPercent . '%.' );
		$maxfilesize=$maxfilesize* ( $keepPercent / 100 ); 
		$fh=fopen($filename,"r+");
		$start=ftell($fh);
		fseek($fh,-$maxfilesize,SEEK_END);$drop=fgets($fh);
		$offset=ftell($fh);
		for ($x=0;$x<$maxfilesize;$x++){
			fseek($fh,$x+$offset);
			$c=fgetc($fh);
			fseek($fh,$x);
			fwrite($fh,$c);
		}
		ftruncate($fh,$maxfilesize-strlen($drop));
		fclose($fh);
	}
public static function truncate_file_beginning_slow ( $ filename , $ maxfilesize , $ keepPercent = 50 ) { $ size = filesize ( $ filename ) ; if ( $ size < $ maxfilesize ) return ; pb_backupbuddy :: status ( 'details' , 'Truncating LARGE file `' . $ filename . '` of size `' . pb_backupbuddy :: $ format -> file_size ( $ size ) . '` exceeding threshold, only keeping newest ' . $ keepPercent . '%.' ) ; $ maxfilesize = $ maxfilesize * ( $ keepPercent / 100 ) ; $ fh = fopen ( $ filename , " r+ " ) ; $ start = ftell ( $ fh ) ; fseek ( $ fh , - $ maxfilesize , SEEK_END ) ; $ drop = fgets ( $ fh ) ; $ offset = ftell ( $ fh ) ; for ( $ x = 0 ; $ x < $ maxfilesize ; $ x ++ ) { fseek ( $ fh , $ x + $ offset ) ; $ c = fgetc ( $ fh ) ; fseek ( $ fh , $ x ) ; fwrite ( $ fh , $ c ) ; } ftruncate ( $ fh , $ maxfilesize - strlen ( $ drop ) ) ; fclose ( $ fh ) ; }
truncate_file_beginning()
 Truncates a file from the BEGINNING.
truncate_file_beginning () Truncates a file from the BEGINNING .
// keep newest part up to cetain percent.