26 lines
822 B
PHP
26 lines
822 B
PHP
<?php
|
|
require_once __DIR__ . '/../includes/db.php';
|
|
require_once __DIR__ . '/../includes/utils.php';
|
|
require_once __DIR__ . '/../config/config.php';
|
|
|
|
// Export all data types
|
|
$types = ['chores', 'groceries', 'meals'];
|
|
$results = [];
|
|
|
|
foreach ($types as $type) {
|
|
$data = readJsonFile($type . '.json');
|
|
$filename = generateExportFilename($type);
|
|
$exportPath = EXPORT_DESTINATION . '/' . $filename;
|
|
|
|
if (file_put_contents($exportPath, json_encode($data, JSON_PRETTY_PRINT))) {
|
|
$results[$type] = 'success';
|
|
} else {
|
|
$results[$type] = 'failed';
|
|
}
|
|
}
|
|
|
|
// Log results
|
|
$logFile = EXPORT_DESTINATION . '/export_log.txt';
|
|
$timestamp = date('Y-m-d H:i:s');
|
|
$logMessage = "[$timestamp] Export results: " . json_encode($results) . "\n";
|
|
file_put_contents($logFile, $logMessage, FILE_APPEND);
|