summaryrefslogtreecommitdiff
path: root/cli/import-for-user.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-12-16 15:24:13 +0100
committerGravatar GitHub <noreply@github.com> 2017-12-16 15:24:13 +0100
commitfdc9e0d75a786101a14f64bc418b48fdd1cb4890 (patch)
tree9a7a1d523ab1279e2efce84d2d0c73dd0ad47c70 /cli/import-for-user.php
parentf7560c585f211be41b093906e3a8fb5a6071c660 (diff)
parentccb829418d25af49d129ac227b0cbd09c085b8a3 (diff)
Merge branch 'dev' into hebrew-i18n
Diffstat (limited to 'cli/import-for-user.php')
-rwxr-xr-xcli/import-for-user.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/cli/import-for-user.php b/cli/import-for-user.php
new file mode 100755
index 000000000..95ff18c8c
--- /dev/null
+++ b/cli/import-for-user.php
@@ -0,0 +1,35 @@
+#!/usr/bin/php
+<?php
+require(__DIR__ . '/_cli.php');
+
+$options = getopt('', array(
+ 'user:',
+ 'filename:',
+ ));
+
+if (empty($options['user']) || empty($options['filename'])) {
+ fail('Usage: ' . basename(__FILE__) . " --user username --filename /path/to/file.ext");
+}
+
+$username = cliInitUser($options['user']);
+
+$filename = $options['filename'];
+if (!is_readable($filename)) {
+ fail('FreshRSS error: file is not readable “' . $filename . '”');
+}
+
+echo 'FreshRSS importing ZIP/OPML/JSON for user “', $username, "”…\n";
+
+$importController = new FreshRSS_importExport_Controller();
+
+$ok = false;
+try {
+ $ok = $importController->importFile($filename, $filename, $username);
+} catch (FreshRSS_ZipMissing_Exception $zme) {
+ fail('FreshRSS error: Lacking php-zip extension!');
+} catch (FreshRSS_Zip_Exception $ze) {
+ fail('FreshRSS error: ZIP archive cannot be imported! Error code: ' . $ze->zipErrorCode());
+}
+invalidateHttpCache($username);
+
+done($ok);