mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-17 17:57:54 -05:00
Even if the issue #3035 seemed pretty simple at a first glance, it was more complicated than I expected. Because we send CSP headers AFTER running the controller actions, it means we can't "echo" any content from the controller. It's in fact a good practice, but it was easier at the time we developed the feature. To fix that, the only thing I had to do was to move the `print()` and `readfile()` function into the view. The problem was that we needed to output the content from the CLI too. Then, things became more complicated. I decided to extract the export-related methods in a `FreshRSS_Export_Service` class, in order to use it from both the controller and the CLI. It was an opportunity to refactor the whole feature in order to make it a bit more linear and easy to read. Reference: https://github.com/FreshRSS/FreshRSS/issues/3035
26 lines
579 B
PHP
Executable File
26 lines
579 B
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
require(__DIR__ . '/_cli.php');
|
|
|
|
$params = array(
|
|
'user:',
|
|
);
|
|
|
|
$options = getopt('', $params);
|
|
|
|
if (!validateOptions($argv, $params) || empty($options['user'])) {
|
|
fail('Usage: ' . basename(__FILE__) . " --user username > /path/to/file.opml.xml");
|
|
}
|
|
|
|
$username = cliInitUser($options['user']);
|
|
|
|
fwrite(STDERR, 'FreshRSS exporting OPML for user “' . $username . "”…\n");
|
|
|
|
$export_service = new FreshRSS_Export_Service($username);
|
|
list($filename, $content) = $export_service->generateOpml();
|
|
echo $content;
|
|
|
|
invalidateHttpCache($username);
|
|
|
|
done();
|