public/wordpress/wp-content/plugins/backupbuddy/classes/core.php
/*	mail_notify_scheduled()
	 *	
	 *	Sends a message email to the defined email address(es) on settings page.
	 *	
	 *	@param		string		$start_or_complete	Whether this is the notifcation for starting or completing. Valid values: start, complete, destinationComplete
	 *	@param		string		$message			Message to be included in the body of the email.
	 *	@return		null
	 */


Sends a message email to the defined email address(es) on settings page.

@param          string          $start_or_complete      Whether this is the notifcation for starting or completing. Valid values: start, complete, destinationComplete
@param          string          $message                        Message to be included in the body of the email.
@return         null
Sends a message email to the defined email address ( es ) on settings page . @param string $start_or_complete Whether this is the notifcation for starting or completing . Valid values : start complete destinationComplete @param string $message Message to be included in the body of the email . @return null
public static function mail_notify_scheduled( $serial, $start_or_complete, $message, $extraReplacements = array() ) {
		if ( !isset( pb_backupbuddy::$options ) ) {
			pb_backupbuddy::load();
		}
		if ( $start_or_complete == 'start' ) {
			$email = pb_backupbuddy::$options['email_notify_scheduled_start'];
			$subject = pb_backupbuddy::$options['email_notify_scheduled_start_subject'];
			$body = pb_backupbuddy::$options['email_notify_scheduled_start_body'];
			$replacements = array(
				'{site_url}' => site_url(),
				'{home_url}' => home_url(),
				'{backupbuddy_version}' => pb_backupbuddy::settings( 'version' ),
				'{current_datetime}' => date(DATE_RFC822),
				'{heading}' => 'Backup Started',
				'{message}' => $message
			);
		} elseif ( $start_or_complete == 'complete' ) {
			$email = pb_backupbuddy::$options['email_notify_scheduled_complete'];
			$subject = pb_backupbuddy::$options['email_notify_scheduled_complete_subject'];
			$body = pb_backupbuddy::$options['email_notify_scheduled_complete_body'];
			$archive_file = '';
			require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
			pb_backupbuddy::status( 'details', 'Fileoptions instance #37.' );
			$backup_options = new pb_backupbuddy_fileoptions( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = true, $ignore_lock = true );
			if ( true !== ( $result = $backup_options->is_ok() ) ) {
				pb_backupbuddy::status( 'error', 'Error retrieving fileoptions file `' . backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' . '`. Err 35564332.' );
				$archive_file = '[file_unknown]';
				$backup_size = '[size_unknown]';
				$backup_type = '[type_unknown]';
			} else {
				$archive_file = $backup_options->options['archive_file'];
				$backup_size = $backup_options->options['archive_size'];
				$backup_type = $backup_options->options['type'];
			}
			$replacements = array(
				'{site_url}' => site_url(),
				'{home_url}' => home_url(),
				'{backupbuddy_version}' => pb_backupbuddy::settings( 'version' ),
				'{current_datetime}' => date(DATE_RFC822),
				'{heading}' => 'Backup Completed',
				'{message}' => $message,
				'{backup_serial}' => $serial,
				'{download_link}' => pb_backupbuddy::ajax_url( 'download_archive' ) . '&backupbuddy_backup=' . basename( $archive_file ),
				'{backup_file}' => basename( $archive_file ),
				'{backup_size}' => $backup_size,
				'{backup_type}' => $backup_type,
			);
		} elseif ( $start_or_complete == 'destinationComplete' ) {
			$email = pb_backupbuddy::$options['email_notify_send_finish'];
			$subject = pb_backupbuddy::$options['email_notify_send_finish_subject'];
			$body = pb_backupbuddy::$options['email_notify_send_finish_body'];
			$replacements = array(
				'{site_url}' => site_url(),
				'{home_url}' => home_url(),
				'{backupbuddy_version}' => pb_backupbuddy::settings( 'version' ),
				'{current_datetime}' => date(DATE_RFC822),
				'{heading}' => 'Backup successfully sent to destination',
				'{message}' => $message,
			);
		} else {
			pb_backupbuddy::status( 'error', 'ERROR #54857845785: Fatally halted. Invalid schedule type. Expected `start` or `complete`. Got `' . $start_or_complete . '`.' );
		}
		$replacements = array_merge( $replacements, $extraReplacements );
		$replacements['{support_display}'] = 'none';
		foreach( $replacements as $replace_key => $replacement ) {
			$subject = str_replace( $replace_key, $replacement, $subject );
			$body = str_replace( $replace_key, $replacement, $body );
		}
		$replacements['{body}'] = $body;
		if ( @file_exists( get_theme_root() . '/backupbuddy-email-template.php' ) ) {
			$body = file_get_contents( get_theme_root() . '/backupbuddy-email-template.php' );
		} else {
			$body = file_get_contents( dirname( dirname( __FILE__ ) ) . '/views/backupbuddy-email-template.php' );
		}
		foreach( $replacements as $replace_key => $replacement ) {
			$body = str_replace( $replace_key,$replacement, $body );
		}
		if ( pb_backupbuddy::$options['email_return'] != '' ) {
			$email_return = pb_backupbuddy::$options['email_return'];
		} else {
			$email_return = get_option('admin_email');
		}
		pb_backupbuddy::status( 'details', 'Sending email schedule notification. Subject: `' . $subject . '`; recipient(s): `' . $email . '`.' );
		if ( !empty( $email ) ) {
			if ( function_exists( 'wp_mail' ) ) {
				wp_mail( $email, $subject, $body, 'From: BackupBuddy <' . $email_return . ">\r\n".'Reply-To: '.get_option('admin_email')."\r\n".'Content-type: text/html;' . "\r\n");
			} else {
				pb_backupbuddy::status( 'error', 'Error #32892393: wp_mail() does not exist. Inside WordPress?' );
			}
		}
	}
public static function mail_notify_scheduled ( $ serial , $ start_or_complete , $ message , $ extraReplacements = array ( ) ) { if ( ! isset ( pb_backupbuddy :: $ options ) ) { pb_backupbuddy :: load ( ) ; } if ( $ start_or_complete == 'start' ) { $ email = pb_backupbuddy :: $ options [ 'email_notify_scheduled_start' ] ; $ subject = pb_backupbuddy :: $ options [ 'email_notify_scheduled_start_subject' ] ; $ body = pb_backupbuddy :: $ options [ 'email_notify_scheduled_start_body' ] ; $ replacements = array ( '{site_url}' => site_url ( ) , '{home_url}' => home_url ( ) , '{backupbuddy_version}' => pb_backupbuddy :: settings ( 'version' ) , '{current_datetime}' => date ( DATE_RFC822 ) , '{heading}' => 'Backup Started' , '{message}' => $ message ) ; } elseif ( $ start_or_complete == 'complete' ) { $ email = pb_backupbuddy :: $ options [ 'email_notify_scheduled_complete' ] ; $ subject = pb_backupbuddy :: $ options [ 'email_notify_scheduled_complete_subject' ] ; $ body = pb_backupbuddy :: $ options [ 'email_notify_scheduled_complete_body' ] ; $ archive_file = '' ; require_once ( pb_backupbuddy :: plugin_path ( ) . '/classes/fileoptions.php' ) ; pb_backupbuddy :: status ( 'details' , 'Fileoptions instance #37.' ) ; $ backup_options = new pb_backupbuddy_fileoptions ( backupbuddy_core :: getLogDirectory ( ) . 'fileoptions/' . $ serial . '.txt' , $ read_only = true , $ ignore_lock = true ) ; if ( true !== ( $ result = $ backup_options -> is_ok ( ) ) ) { pb_backupbuddy :: status ( 'error' , 'Error retrieving fileoptions file `' . backupbuddy_core :: getLogDirectory ( ) . 'fileoptions/' . $ serial . '.txt' . '`. Err 35564332.' ) ; $ archive_file = '[file_unknown]' ; $ backup_size = '[size_unknown]' ; $ backup_type = '[type_unknown]' ; } else { $ archive_file = $ backup_options -> options [ 'archive_file' ] ; $ backup_size = $ backup_options -> options [ 'archive_size' ] ; $ backup_type = $ backup_options -> options [ 'type' ] ; } $ replacements = array ( '{site_url}' => site_url ( ) , '{home_url}' => home_url ( ) , '{backupbuddy_version}' => pb_backupbuddy :: settings ( 'version' ) , '{current_datetime}' => date ( DATE_RFC822 ) , '{heading}' => 'Backup Completed' , '{message}' => $ message , '{backup_serial}' => $ serial , '{download_link}' => pb_backupbuddy :: ajax_url ( 'download_archive' ) . '&backupbuddy_backup=' . basename ( $ archive_file ) , '{backup_file}' => basename ( $ archive_file ) , '{backup_size}' => $ backup_size , '{backup_type}' => $ backup_type , ) ; } elseif ( $ start_or_complete == 'destinationComplete' ) { $ email = pb_backupbuddy :: $ options [ 'email_notify_send_finish' ] ; $ subject = pb_backupbuddy :: $ options [ 'email_notify_send_finish_subject' ] ; $ body = pb_backupbuddy :: $ options [ 'email_notify_send_finish_body' ] ; $ replacements = array ( '{site_url}' => site_url ( ) , '{home_url}' => home_url ( ) , '{backupbuddy_version}' => pb_backupbuddy :: settings ( 'version' ) , '{current_datetime}' => date ( DATE_RFC822 ) , '{heading}' => 'Backup successfully sent to destination' , '{message}' => $ message , ) ; } else { pb_backupbuddy :: status ( 'error' , 'ERROR #54857845785: Fatally halted. Invalid schedule type. Expected `start` or `complete`. Got `' . $ start_or_complete . '`.' ) ; } $ replacements = array_merge ( $ replacements , $ extraReplacements ) ; $ replacements [ '{support_display}' ] = 'none' ; foreach ( $ replacements as $ replace_key => $ replacement ) { $ subject = str_replace ( $ replace_key , $ replacement , $ subject ) ; $ body = str_replace ( $ replace_key , $ replacement , $ body ) ; } $ replacements [ '{body}' ] = $ body ; if ( @ file_exists ( get_theme_root ( ) . '/backupbuddy-email-template.php' ) ) { $ body = file_get_contents ( get_theme_root ( ) . '/backupbuddy-email-template.php' ) ; } else { $ body = file_get_contents ( dirname ( dirname ( __FILE__ ) ) . '/views/backupbuddy-email-template.php' ) ; } foreach ( $ replacements as $ replace_key => $ replacement ) { $ body = str_replace ( $ replace_key , $ replacement , $ body ) ; } if ( pb_backupbuddy :: $ options [ 'email_return' ] != '' ) { $ email_return = pb_backupbuddy :: $ options [ 'email_return' ] ; } else { $ email_return = get_option ( 'admin_email' ) ; } pb_backupbuddy :: status ( 'details' , 'Sending email schedule notification. Subject: `' . $ subject . '`; recipient(s): `' . $ email . '`.' ) ; if ( ! empty ( $ email ) ) { if ( function_exists ( 'wp_mail' ) ) { wp_mail ( $ email , $ subject , $ body , 'From: BackupBuddy <' . $ email_return . " > \r \n " . 'Reply-To: ' . get_option ( 'admin_email' ) . " \r \n " . 'Content-type: text/html;' . " \r \n " ) ; } else { pb_backupbuddy :: status ( 'error' , 'Error #32892393: wp_mail() does not exist. Inside WordPress?' ) ; } } }
mail_notify_scheduled()
mail_notify_scheduled ()
// Customize Subject and user customizable message // Customize the final body based on our HTML template