diff options
author | Romain d'Alverny <rdalverny@gmail.com> | 2022-01-14 19:10:00 +0100 |
---|---|---|
committer | Romain d'Alverny <rdalverny@gmail.com> | 2022-01-14 19:10:00 +0100 |
commit | b9b9f483f54365ecb88572690f308a29d26da31c (patch) | |
tree | 8ac955d3690fd4ec66e4a7e85ab96af54c15048e | |
parent | 79961b6bae9256cb7686a94a46e1b8eb3f2721c6 (diff) | |
download | planet-b9b9f483f54365ecb88572690f308a29d26da31c.tar planet-b9b9f483f54365ecb88572690f308a29d26da31c.tar.gz planet-b9b9f483f54365ecb88572690f308a29d26da31c.tar.bz2 planet-b9b9f483f54365ecb88572690f308a29d26da31c.tar.xz planet-b9b9f483f54365ecb88572690f308a29d26da31c.zip |
Import OPML file directly in admin
Allows to backup/restore a full opml list.
Maybe related to moonmoon/moonmoon#67.
-rwxr-xr-x | admin/index.php | 14 | ||||
-rwxr-xr-x | admin/subscriptions.php | 10 |
2 files changed, 23 insertions, 1 deletions
diff --git a/admin/index.php b/admin/index.php index 153c2ad..76ebb25 100755 --- a/admin/index.php +++ b/admin/index.php @@ -127,6 +127,20 @@ ob_start(); </table> </form> </div> + + <div class="widget"> + <h3><?=_g('Upload OPML file')?></h3> + <form action="subscriptions.php" method="post" id="opmlimport" enctype="multipart/form-data"> + <p>Beware! This will totally erase and replace the list of your feeds just above.</p> + <fieldset> + <label for="url"><?=_g('File:')?></label> + <input type="file" class="text" name="opml" id="opml" class="text" size="50" /> + <input type="submit" class="submit add" name="upload" value="<?=_g('Upload OPML file and replace existing feeds')?>" /> + </fieldset> + <input type="hidden" value="<?php echo $csrf->generate('feedmanage'); ?>" name="_csrf"> + </form> + </div> + <?php $page_content = ob_get_contents(); ob_end_clean(); diff --git a/admin/subscriptions.php b/admin/subscriptions.php index 76980f4..2e07f17 100755 --- a/admin/subscriptions.php +++ b/admin/subscriptions.php @@ -14,7 +14,15 @@ if (!$csrf->verify($_POST['_csrf'], 'feedmanage')) { $opmlFile = $PlanetConfig->getOpmlFile(); -if (isset($_POST['opml']) || isset($_POST['add'])) { +if (isset($_POST['upload']) && + isset($_FILES['opml']) && + is_uploaded_file($_FILES['opml']['tmp_name']) && + $_FILES['opml']['size'] > 0) { + OpmlManager::backup($opmlFile); + $newOpml = new Opml(); + $newOpml->parse(file_get_contents($_FILES['opml']['tmp_name'])); + OpmlManager::save($newOpml, $opmlFile); +} elseif (isset($_POST['opml']) || isset($_POST['add'])) { // Load old OPML $oldOpml = OpmlManager::load($opmlFile); if ($PlanetConfig->getName() === '') { |