public/wordpress/wp-content/plugins/backupbuddy/classes/fileoptions.php
/* save()
	 *
	 * Save the options into file now without removing lock.
	 *
	 * @param		bool	$remove_lock	When true the lock will be removed as well. default: false
	 * @return		bool					true on save success, else false.
	 *
	 */
save()
Save the options into file now without removing lock.

@param               bool    $remove_lock    When true the lock will be removed as well. default: false
@return              bool                                    true on save success, else false.
save () Save the options into file now without removing lock . @param bool $remove_lock When true the lock will be removed as well . default : false @return bool true on save success else false .
public function save( $remove_lock = false, $only_save_my_lock_id = true ) {
		if ( '' == $this->_file ) { 
			return true;
		}
		if ( true === $this->_read_only ) {
			pb_backupbuddy::status( 'error', 'Attempted to write to fileoptions while in readonly mode; denied.' );
			return false;
		}
		if ( false === $this->_loaded ) { 
			return false;
		}
		if ( ( true === $this->is_locked() ) && ( false !== $only_save_my_lock_id ) ) {
			if ( ( $this->_last_seen_lock_id != $this->_my_lock_id ) || ( '' == $this->_my_lock_id ) ) {
				pb_backupbuddy::status( 'error', 'Error #43894384: Unable to write to fileoptions as file `' . $this->_file . '` is currently locked by another fileoptions instance/process. Last seen lock ID: `' . $this->_last_seen_lock_id . '`. My lock ID: `' . $this->_my_lock_id . '`.' );
				return false;
			}
		}
		if ( true === $this->_live ) {
			if ( false === ( $fso = @fopen( $this->_file, 'w' ) ) ) {
				pb_backupbuddy::status( 'error', 'Error #83494757: Unable to open fileoptions file `' . $this->_file . '` for writing. Verify permissions.' );
				if ( true === $remove_lock ) {
					$this->unlock();
				}
				@fclose( $fso );
				return false;
			}
			$bytesWritten = 0;
			if ( false === ( $written = @fwrite( $fso, "FILEOPTIONS_START\n" ) ) ) {
				pb_backupbuddy::status( 'error', 'Error #329823955: Unable to write to fileoptions file `' . $this->_file . '`. Verify permissions.' );
				if ( true === $remove_lock ) {
					$this->unlock();
				}
				@fclose( $fso );
				return false;
			} else { 
				$bytesWritten += $written;
			}
			foreach( $this->options as $optionKey => $optionItem ) {
				$optionItem = json_encode( $optionItem, JSON_FORCE_OBJECT );
				if ( false === ( $written = @fwrite( $fso, $optionKey . '|' . $optionItem . "\n" ) ) ) {
					pb_backupbuddy::status( 'error', 'Error #839494455: Unable to write to fileoptions file `' . $this->_file . '`. Verify permissions.' );
					if ( true === $remove_lock ) {
						$this->unlock();
					}
					@fclose( $fso );
					return false;
				} else { 
					$bytesWritten += $written;
				}
			}
			if ( false === ( $written = @fwrite( $fso, 'FILEOPTIONS_END') ) ) {
				pb_backupbuddy::status( 'error', 'Error #32893355: Unable to write to fileoptions file `' . $this->_file . '`. Verify permissions.' );
				if ( true === $remove_lock ) {
					$this->unlock();
				}
				@fclose( $fso );
				return false;
			} else { 
				$bytesWritten += $written;
			}
			pb_backupbuddy::status( 'details', 'Fileoptions `' . basename( $this->_file ) . '` saved (Live mode). ' . $bytesWritten . ' bytes written.' );
			if ( true === $remove_lock ) {
				$this->unlock();
			}
			@fclose( $fso );
			return true;
		}
		$serialized = serialize( $this->options );
		$options_hash = md5( $serialized );
		if ( $options_hash == $this->_options_hash ) { 
			if ( true === $remove_lock ) {
				$this->unlock();
			}
			return true;
		}
		$options = base64_encode( $serialized );
		if ( false === ( $bytesWritten = file_put_contents( $this->_file, $options ) ) ) { 
			pb_backupbuddy::status( 'error', 'Error #478374745: Unable to write fileoptions file `' . $this->_file . '`. Verify permissions.' );
			if ( true === $remove_lock ) {
				$this->unlock();
			}
			return false;
		} else { 
			pb_backupbuddy::status( 'details', 'Fileoptions `' . basename( $this->_file ) . '` saved. ' . $bytesWritten . ' bytes written.' );
			$this->_options_hash = $options_hash;
			if ( true === $remove_lock ) {
				$this->unlock();
			}
			return true;
		}
	}
public function save ( $ remove_lock = false , $ only_save_my_lock_id = true ) { if ( '' == $ this -> _file ) { return true ; } if ( true === $ this -> _read_only ) { pb_backupbuddy :: status ( 'error' , 'Attempted to write to fileoptions while in readonly mode; denied.' ) ; return false ; } if ( false === $ this -> _loaded ) { return false ; } if ( ( true === $ this -> is_locked ( ) ) && ( false !== $ only_save_my_lock_id ) ) { if ( ( $ this -> _last_seen_lock_id != $ this -> _my_lock_id ) || ( '' == $ this -> _my_lock_id ) ) { pb_backupbuddy :: status ( 'error' , 'Error #43894384: Unable to write to fileoptions as file `' . $ this -> _file . '` is currently locked by another fileoptions instance/process. Last seen lock ID: `' . $ this -> _last_seen_lock_id . '`. My lock ID: `' . $ this -> _my_lock_id . '`.' ) ; return false ; } } if ( true === $ this -> _live ) { if ( false === ( $ fso = @ fopen ( $ this -> _file , 'w' ) ) ) { pb_backupbuddy :: status ( 'error' , 'Error #83494757: Unable to open fileoptions file `' . $ this -> _file . '` for writing. Verify permissions.' ) ; if ( true === $ remove_lock ) { $ this -> unlock ( ) ; } @ fclose ( $ fso ) ; return false ; } $ bytesWritten = 0 ; if ( false === ( $ written = @ fwrite ( $ fso , " FILEOPTIONS_START \n " ) ) ) { pb_backupbuddy :: status ( 'error' , 'Error #329823955: Unable to write to fileoptions file `' . $ this -> _file . '`. Verify permissions.' ) ; if ( true === $ remove_lock ) { $ this -> unlock ( ) ; } @ fclose ( $ fso ) ; return false ; } else { $ bytesWritten += $ written ; } foreach ( $ this -> options as $ optionKey => $ optionItem ) { $ optionItem = json_encode ( $ optionItem , JSON_FORCE_OBJECT ) ; if ( false === ( $ written = @ fwrite ( $ fso , $ optionKey . '|' . $ optionItem . " \n " ) ) ) { pb_backupbuddy :: status ( 'error' , 'Error #839494455: Unable to write to fileoptions file `' . $ this -> _file . '`. Verify permissions.' ) ; if ( true === $ remove_lock ) { $ this -> unlock ( ) ; } @ fclose ( $ fso ) ; return false ; } else { $ bytesWritten += $ written ; } } if ( false === ( $ written = @ fwrite ( $ fso , 'FILEOPTIONS_END' ) ) ) { pb_backupbuddy :: status ( 'error' , 'Error #32893355: Unable to write to fileoptions file `' . $ this -> _file . '`. Verify permissions.' ) ; if ( true === $ remove_lock ) { $ this -> unlock ( ) ; } @ fclose ( $ fso ) ; return false ; } else { $ bytesWritten += $ written ; } pb_backupbuddy :: status ( 'details' , 'Fileoptions `' . basename ( $ this -> _file ) . '` saved (Live mode). ' . $ bytesWritten . ' bytes written.' ) ; if ( true === $ remove_lock ) { $ this -> unlock ( ) ; } @ fclose ( $ fso ) ; return true ; } $ serialized = serialize ( $ this -> options ) ; $ options_hash = md5 ( $ serialized ) ; if ( $ options_hash == $ this -> _options_hash ) { if ( true === $ remove_lock ) { $ this -> unlock ( ) ; } return true ; } $ options = base64_encode ( $ serialized ) ; if ( false === ( $ bytesWritten = file_put_contents ( $ this -> _file , $ options ) ) ) { pb_backupbuddy :: status ( 'error' , 'Error #478374745: Unable to write fileoptions file `' . $ this -> _file . '`. Verify permissions.' ) ; if ( true === $ remove_lock ) { $ this -> unlock ( ) ; } return false ; } else { pb_backupbuddy :: status ( 'details' , 'Fileoptions `' . basename ( $ this -> _file ) . '` saved. ' . $ bytesWritten . ' bytes written.' ) ; $ this -> _options_hash = $ options_hash ; if ( true === $ remove_lock ) { $ this -> unlock ( ) ; } return true ; } }
save()
 Save the options into file now without removing lock.
save () Save the options into file now without removing lock .
// No file set yet. Just return. // Skip saving if we have not successfully loaded yet to prevent overwriting data. // If file is locked and we ae only saving when it's our own lock ID then make sure IDs match. // BackupBuddy Stash Live mode. (one array entry per line for performance/memory usage). // Open for writing. // Write file start marker (new in data version 2 (BB v7.2.2.2) // Wrote. // Wrote. // Write file end marker (new in data version 2 (BB v7.2.2.2) // Wrote. // Success. //$this->_options_hash = $options_hash; // Only update if options has changed so if equal then no change so return. // unable to write. // wrote to file.