| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/thelittlebigshow/self-hosted/ |
Upload File : |
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once __DIR__ . '/self_hosted_activation_helpers.php';
require_once __DIR__ . '/scheduled_export_helpers.php';
if (!selfHostedModeEnabled()) {
echo "This scheduled export sender is intended for self-hosted installs.\n";
exit(1);
}
if (!selfHostedDbConfigured()) {
echo "Self-hosted database settings are not configured.\n";
exit(1);
}
try {
$conn = selfHostedConnectDb();
$settings = scheduledExportSettings($conn, '');
$due = scheduledExportDueMarker($settings);
if (!$due) {
echo "No scheduled export is due right now.\n";
$conn->close();
exit(0);
}
$month = date('Y-m');
$csv = exportCsvStringForMonth(
$conn,
$month,
!empty($settings['include_archived']),
!empty($settings['map_qbo_names'])
);
$storeName = SELF_HOSTED_STORE_NAME !== '' ? SELF_HOSTED_STORE_NAME : SELF_HOSTED_DB_NAME;
$safeStore = preg_replace('/[^A-Za-z0-9_-]+/', '_', $storeName);
$filename = $safeStore . '_transactions_' . $month . (!empty($settings['map_qbo_names']) ? '_qbo_mapped' : '') . '.csv';
if (!sendScheduledExportEmail((string) $settings['email'], $storeName, $month, $csv, $filename)) {
throw new RuntimeException('mail() returned false.');
}
scheduledExportMarkSent($conn, date('Y-m-d H:i:s'), (string) ($due['marker'] ?? ''));
$conn->close();
echo "Scheduled export sent successfully.\n";
exit(0);
} catch (Throwable $e) {
echo 'Scheduled export failed: ' . $e->getMessage() . "\n";
exit(1);
}