From 04c55fa1b84b75445642de9ec0e2532d10e72dc0 Mon Sep 17 00:00:00 2001 From: scollovati <20740642+scollovati@users.noreply.github.com> Date: Sun, 2 Nov 2025 20:39:41 +0100 Subject: [sqlite export] add username and timestamp (#8169) * [sqlite export] add username and timestamp add username and timestamp to sqlite user export, similar to the ZIP export. Useful for archiving purposes. * Fix case of backups and other DB types https://github.com/FreshRSS/FreshRSS/pull/8169#issuecomment-3476079108 --------- Co-authored-by: Alexandre Alapetite --- app/Controllers/importExportController.php | 7 +++++++ app/Models/View.php | 1 + app/views/importExport/sqlite.phtml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 294f4de2c..7dc825b9e 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -751,7 +751,14 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController { Minz_Error::error(404); return; } + $this->view->sqlitePath = $path; + $this->view->sqliteName = basename($path); + if ($this->view->sqliteName === 'db.sqlite') { + $username = Minz_User::name() ?? '_'; + $date = date('Y-m-d_H-i-s', filemtime($path) ?: time()); + $this->view->sqliteName = 'freshrss_' . $username . '_' . $date . '_db.sqlite'; + } $this->view->_layout(null); } } diff --git a/app/Models/View.php b/app/Models/View.php index b251e95ed..b7970b57e 100644 --- a/app/Models/View.php +++ b/app/Models/View.php @@ -92,6 +92,7 @@ class FreshRSS_View extends Minz_View { /** @var null|array */ public ?array $sqliteArchives = null; public string $sqlitePath; + public string $sqliteName; // Form login public int $cookie_days; diff --git a/app/views/importExport/sqlite.phtml b/app/views/importExport/sqlite.phtml index f1d181a61..7b0a244a3 100644 --- a/app/views/importExport/sqlite.phtml +++ b/app/views/importExport/sqlite.phtml @@ -3,7 +3,7 @@ declare(strict_types=1); /** @var FreshRSS_View $this */ @ob_end_clean(); // Ensure no buffer header('Content-Type: application/vnd.sqlite3'); -header('Content-Disposition: attachment; filename="' . basename($this->sqlitePath) . '"'); +header('Content-Disposition: attachment; filename="' . $this->sqliteName . '"'); header('Cache-Control: private, no-store, max-age=0'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', @filemtime($this->sqlitePath) ?: 0)); header('Content-Length: ' . (@filesize($this->sqlitePath) ?: 0)); -- cgit v1.2.3