aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/indexController.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-07-04 09:53:26 +0200
committerGravatar GitHub <noreply@github.com> 2022-07-04 09:53:26 +0200
commit509c8cae6381ec46af7c8303eb92fda6ce496a4a (patch)
tree653f7f44df842f9d7135decd89467879a0098c50 /app/Controllers/indexController.php
parent57d571230eeb2d3ede57e640b640f17c7a2298a2 (diff)
Dynamic OPML (#4407)
* Dynamic OPML draft #fix https://github.com/FreshRSS/FreshRSS/issues/4191 * Export dynamic OPML http://opml.org/spec2.opml#1629043127000 * Restart with simpler approach * Minor revert * Export dynamic OPML also for single feeds * Special category type for importing dynamic OPML * Parameter for excludeMutedFeeds * Details * More draft * i18n * Fix update * Draft manual import working * Working manual refresh * Draft automatic update * Working Web refresh + fixes * Import/export dynamic OPML settings * Annoying numerous lines in SQL logs * Fix minor JavaScript error * Fix auto adding new columns * Add require * Add missing 🗲 * Missing space * Disable adding new feeds to dynamic categories * Link from import * i18n typo * Improve theme icon function * Fix pink-dark
Diffstat (limited to 'app/Controllers/indexController.php')
-rwxr-xr-xapp/Controllers/indexController.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index 34770fffb..70b8824c3 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -174,6 +174,76 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
header('Content-Type: application/rss+xml; charset=utf-8');
}
+ public function opmlAction() {
+ $allow_anonymous = FreshRSS_Context::$system_conf->allow_anonymous;
+ $token = FreshRSS_Context::$user_conf->token;
+ $token_param = Minz_Request::param('token', '');
+ $token_is_ok = ($token != '' && $token === $token_param);
+
+ // Check if user has access.
+ if (!FreshRSS_Auth::hasAccess() && !$allow_anonymous && !$token_is_ok) {
+ Minz_Error::error(403);
+ }
+
+ try {
+ $this->updateContext();
+ } catch (FreshRSS_Context_Exception $e) {
+ Minz_Error::error(404);
+ }
+
+ $get = FreshRSS_Context::currentGet(true);
+ if (is_array($get)) {
+ $type = $get[0];
+ $id = $get[1];
+ } else {
+ $type = $get;
+ $id = '';
+ }
+
+ $catDAO = FreshRSS_Factory::createCategoryDao();
+ $categories = $catDAO->listCategories(true, true);
+ $this->view->excludeMutedFeeds = true;
+
+ switch ($type) {
+ case 'a':
+ $this->view->categories = $categories;
+ break;
+ case 'c':
+ $cat = $categories[$id] ?? null;
+ if ($cat == null) {
+ Minz_Error::error(404);
+ return;
+ }
+ $this->view->categories = [ $cat ];
+ break;
+ case 'f':
+ // We most likely already have the feed object in cache
+ $feed = FreshRSS_CategoryDAO::findFeed($categories, $id);
+ if ($feed == null) {
+ $feedDAO = FreshRSS_Factory::createFeedDao();
+ $feed = $feedDAO->searchById($id);
+ if ($feed == null) {
+ Minz_Error::error(404);
+ return;
+ }
+ }
+ $this->view->feeds = [ $feed ];
+ break;
+ case 's':
+ case 't':
+ case 'T':
+ default:
+ Minz_Error::error(404);
+ return;
+ }
+
+ require_once(LIB_PATH . '/lib_opml.php');
+
+ // No layout for OPML output.
+ $this->view->_layout(false);
+ header('Content-Type: application/xml; charset=utf-8');
+ }
+
/**
* This action updates the Context object by using request parameters.
*