# wp-database-backup/6.1/includes/log_generate.php

WP Database Backup – Unlimited Database &amp; Files Backup by Backup for WP, version 6.1. 50 lines.

- Page: https://pluginprobe.com/plugins/wp-database-backup/6.1/code/includes/log_generate.php
- Raw: https://pluginprobe.com/plugins/wp-database-backup/6.1/raw/includes/log_generate.php
- Modified: 2023-01-21T12:55:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-database-backup/6.1/code/includes/log_generate.php#L10-L20`.

```php
<?php
add_action('wpdbbkp_backup_completed', array('WPDBFullBackupLog', 'wpdbbkp_backup_completed'), 11);

class WPDBFullBackupLog {

    public static function wpdbbkp_backup_completed(&$args) {
        
                        $options = get_option('wp_db_backup_backups');
                        $newoptions = array();
                        $count = 0;
                        foreach ($options as $option) {
                            if ($option['filename'] == $args[0]) {
                                   $newoptions[] = array(
                                    'date' => $option['date'],
                                    'filename' => $option['filename'],
                                    'url' =>$option['url'],
                                    'dir' => $option['dir'],
                                    'log' =>$option['log'],
                                    'destination' =>  $args[6],
                                    'type' => $option['type'],
                                    'size' => $option['size']
                                );
                               // error_log("set destination to $args[0]");
                            }else{
                                 $newoptions[] = $option;
                            }
                            $count++;
                        }                        
                        update_option('wp_db_backup_backups', $newoptions);

        if (get_option('wp_db_log') == 1) {
            if(isset($args[4]) && !empty($args[4]))
            {
                if (is_writable($args[4]) || !file_exists($args[4])) {

                    if (!$handle = @fopen($args[4], 'a'))
                        return;

                    if (!fwrite($handle,  str_replace("<br>", "\n", $args[2])))
                        return;

                    fclose($handle);

                    return true;
                }
            }
        }
    }

}
```
