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