public/wordpress/wp-content/plugins/backupbuddy/classes/housekeeping.php
/* cleanup_temp_dir()
	 *
	 * Cleans out any old temp files. Called by periodic cleanup function and post_backup in backup.php.
	 *
	 */
cleanup_temp_dir()
Cleans out any old temp files. Called by periodic cleanup function and post_backup in backup.php.
cleanup_temp_dir () Cleans out any old temp files . Called by periodic cleanup function and post_backup in backup . php .
public static function cleanup_temp_dir( $backup_age_limit = 172800 ) {
		$temp_directory = backupbuddy_core::getTempDirectory();
		pb_backupbuddy::status( 'details', 'Cleaning up any old temporary zip directories in: `' . $temp_directory . '`. If no recent backups then the temp directory will also be purged.' );
		$recentBackupFound = false;
		$files = glob( $temp_directory . '*' );
		if ( is_array( $files ) && !empty( $files ) ) { 
			foreach( $files as $file ) {
				if ( ( strpos( $file, 'index.' ) !== false ) || ( strpos( $file, '.htaccess' ) !== false ) ) { 
					continue;
				}
				$file_stats = stat( $file );
				if ( ( 0 == $backup_age_limit ) || ( ( time() - $file_stats['mtime'] ) > $backup_age_limit ) ) { 
					if ( @pb_backupbuddy::$filesystem->unlink_recursive( $file ) === false ) {
						pb_backupbuddy::status( 'error', 'Unable to clean up (delete) temporary directory/file: `' . $file . '`. You should manually delete it or check permissions.' );
					}
				} else { 
					$recentBackupFound = true;
				}
			}
			if ( false === $recentBackupFound ) {
				pb_backupbuddy::$filesystem->unlink_recursive( $temp_directory ); 
			}
		}
		unset( $recentBackupFound );
	}
public static function cleanup_temp_dir ( $ backup_age_limit = 172800 ) { $ temp_directory = backupbuddy_core :: getTempDirectory ( ) ; pb_backupbuddy :: status ( 'details' , 'Cleaning up any old temporary zip directories in: `' . $ temp_directory . '`. If no recent backups then the temp directory will also be purged.' ) ; $ recentBackupFound = false ; $ files = glob ( $ temp_directory . '*' ) ; if ( is_array ( $ files ) && ! empty ( $ files ) ) { foreach ( $ files as $ file ) { if ( ( strpos ( $ file , 'index.' ) !== false ) || ( strpos ( $ file , '.htaccess' ) !== false ) ) { continue ; } $ file_stats = stat ( $ file ) ; if ( ( 0 == $ backup_age_limit ) || ( ( time ( ) - $ file_stats [ 'mtime' ] ) > $ backup_age_limit ) ) { if ( @ pb_backupbuddy :: $ filesystem -> unlink_recursive ( $ file ) === false ) { pb_backupbuddy :: status ( 'error' , 'Unable to clean up (delete) temporary directory/file: `' . $ file . '`. You should manually delete it or check permissions.' ) ; } } else { $ recentBackupFound = true ; } } if ( false === $ recentBackupFound ) { pb_backupbuddy :: $ filesystem -> unlink_recursive ( $ temp_directory ) ; } } unset ( $ recentBackupFound ) ; }
cleanup_temp_dir()
 Cleans out any old temp files.
cleanup_temp_dir () Cleans out any old temp files .
// Remove any old temporary directories in wp-content/uploads/backupbuddy_temp/. Logs any directories it cannot delete. // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match. // Index file or htaccess dont get deleted so go to next file. // If older than 12 hours, delete the log. // Not very old. // Delete temp directory (as of BB v5.0). This is not critical but nice. The backup cleanup step should purge these so if all is going well this probably will not find anything.