| 1 |
<?php |
| 2 |
add_action('wpdbbkp_backup_completed', array('WPDBFullBackupLog', 'wpdbbkp_backup_completed'), 11); |
| 3 |
|
| 4 |
class WPDBFullBackupLog { |
| 5 |
|
| 6 |
public static function wpdbbkp_backup_completed(&$args) { |
| 7 |
|
| 8 |
$options = get_option('wp_db_backup_backups'); |
| 9 |
$newoptions = array(); |
| 10 |
$count = 0; |
| 11 |
foreach ($options as $option) { |
| 12 |
if ($option['filename'] == $args[0]) { |
| 13 |
$newoptions[] = array( |
| 14 |
'date' => $option['date'], |
| 15 |
'filename' => $option['filename'], |
| 16 |
'url' =>$option['url'], |
| 17 |
'dir' => $option['dir'], |
| 18 |
'log' =>$option['log'], |
| 19 |
'destination' => $args[6], |
| 20 |
'type' => $option['type'], |
| 21 |
'size' => $option['size'] |
| 22 |
); |
| 23 |
// error_log("set destination to $args[0]"); |
| 24 |
}else{ |
| 25 |
$newoptions[] = $option; |
| 26 |
} |
| 27 |
$count++; |
| 28 |
} |
| 29 |
update_option('wp_db_backup_backups', $newoptions); |
| 30 |
|
| 31 |
if (get_option('wp_db_log') == 1) { |
| 32 |
if(isset($args[4]) && !empty($args[4])) |
| 33 |
{ |
| 34 |
if (is_writable($args[4]) || !file_exists($args[4])) { |
| 35 |
|
| 36 |
if (!$handle = @fopen($args[4], 'a')) |
| 37 |
return; |
| 38 |
|
| 39 |
if (!fwrite($handle, str_replace("<br>", "\n", $args[2]))) |
| 40 |
return; |
| 41 |
|
| 42 |
fclose($handle); |
| 43 |
|
| 44 |
return true; |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
} |