configureController.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Controller to handle every configuration options.
  5. */
  6. class FreshRSS_configure_Controller extends FreshRSS_ActionController {
  7. /**
  8. * This action is called before every other action in that class. It is
  9. * the common boilerplate for every action. It is triggered by the
  10. * underlying framework.
  11. */
  12. public function firstAction(): void {
  13. if (!FreshRSS_Auth::hasAccess()) {
  14. Minz_Error::error(403);
  15. }
  16. }
  17. /**
  18. * This action handles the display configuration page.
  19. *
  20. * It displays the display configuration page.
  21. * If this action is reached through a POST request, it stores all new
  22. * configuration values then sends a notification to the user.
  23. *
  24. * The options available on the page are:
  25. * - language (default: en)
  26. * - theme (default: Origin)
  27. * - darkMode (default: no)
  28. * - content width (default: thin)
  29. * - display of read action in header
  30. * - display of favorite action in header
  31. * - display of date in header
  32. * - display of open action in header
  33. * - display of read action in footer
  34. * - display of favorite action in footer
  35. * - display of sharing action in footer
  36. * - display of article tags in footer
  37. * - display of my Labels in footer
  38. * - display of date in footer
  39. * - display of open action in footer
  40. * - html5 notification timeout (default: 0)
  41. * Default values are false unless specified.
  42. */
  43. public function displayAction(): void {
  44. if (Minz_Request::isPost()) {
  45. FreshRSS_Context::$user_conf->language = Minz_Request::paramString('language') ?: 'en';
  46. FreshRSS_Context::$user_conf->timezone = Minz_Request::paramString('timezone');
  47. FreshRSS_Context::$user_conf->theme = Minz_Request::paramString('theme') ?: FreshRSS_Themes::$defaultTheme;
  48. FreshRSS_Context::$user_conf->darkMode = Minz_Request::paramString('darkMode') ?: 'no';
  49. FreshRSS_Context::$user_conf->content_width = Minz_Request::paramString('content_width') ?: 'thin';
  50. FreshRSS_Context::$user_conf->topline_read = Minz_Request::paramBoolean('topline_read');
  51. FreshRSS_Context::$user_conf->topline_favorite = Minz_Request::paramBoolean('topline_favorite');
  52. FreshRSS_Context::$user_conf->topline_date = Minz_Request::paramBoolean('topline_date');
  53. FreshRSS_Context::$user_conf->topline_link = Minz_Request::paramBoolean('topline_link');
  54. FreshRSS_Context::$user_conf->topline_website = Minz_Request::paramString('topline_website');
  55. FreshRSS_Context::$user_conf->topline_thumbnail = Minz_Request::paramString('topline_thumbnail');
  56. FreshRSS_Context::$user_conf->topline_summary = Minz_Request::paramBoolean('topline_summary');
  57. FreshRSS_Context::$user_conf->topline_display_authors = Minz_Request::paramBoolean('topline_display_authors');
  58. FreshRSS_Context::$user_conf->bottomline_read = Minz_Request::paramBoolean('bottomline_read');
  59. FreshRSS_Context::$user_conf->bottomline_favorite = Minz_Request::paramBoolean('bottomline_favorite');
  60. FreshRSS_Context::$user_conf->bottomline_sharing = Minz_Request::paramBoolean('bottomline_sharing');
  61. FreshRSS_Context::$user_conf->bottomline_tags = Minz_Request::paramBoolean('bottomline_tags');
  62. FreshRSS_Context::$user_conf->bottomline_myLabels = Minz_Request::paramBoolean('bottomline_myLabels');
  63. FreshRSS_Context::$user_conf->bottomline_date = Minz_Request::paramBoolean('bottomline_date');
  64. FreshRSS_Context::$user_conf->bottomline_link = Minz_Request::paramBoolean('bottomline_link');
  65. FreshRSS_Context::$user_conf->show_nav_buttons = Minz_Request::paramBoolean('show_nav_buttons');
  66. FreshRSS_Context::$user_conf->html5_notif_timeout = Minz_Request::paramInt('html5_notif_timeout');
  67. FreshRSS_Context::$user_conf->save();
  68. Minz_Session::_param('language', FreshRSS_Context::$user_conf->language);
  69. Minz_Translate::reset(FreshRSS_Context::$user_conf->language);
  70. invalidateHttpCache();
  71. Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'display' ]);
  72. }
  73. $this->view->themes = FreshRSS_Themes::get();
  74. FreshRSS_View::prependTitle(_t('conf.display.title') . ' · ');
  75. }
  76. /**
  77. * This action handles the reading configuration page.
  78. *
  79. * It displays the reading configuration page.
  80. * If this action is reached through a POST request, it stores all new
  81. * configuration values then sends a notification to the user.
  82. *
  83. * The options available on the page are:
  84. * - number of posts per page (default: 10)
  85. * - view mode (default: normal)
  86. * - default article view (default: all)
  87. * - load automatically articles
  88. * - display expanded articles
  89. * - display expanded categories
  90. * - hide categories and feeds without unread articles
  91. * - jump on next category or feed when marked as read
  92. * - image lazy loading
  93. * - stick open articles to the top
  94. * - display a confirmation when reading all articles
  95. * - auto remove article after reading
  96. * - article order (default: DESC)
  97. * - mark articles as read when:
  98. * - displayed
  99. * - opened on site
  100. * - scrolled
  101. * - received
  102. * - focus
  103. * Default values are false unless specified.
  104. */
  105. public function readingAction(): void {
  106. if (Minz_Request::isPost()) {
  107. FreshRSS_Context::$user_conf->posts_per_page = Minz_Request::paramInt('posts_per_page') ?: 10;
  108. FreshRSS_Context::$user_conf->view_mode = Minz_Request::paramString('view_mode', true) ?: 'normal';
  109. FreshRSS_Context::$user_conf->default_view = Minz_Request::paramString('default_view') ?: 'adaptive';
  110. FreshRSS_Context::$user_conf->show_fav_unread = Minz_Request::paramBoolean('show_fav_unread');
  111. FreshRSS_Context::$user_conf->auto_load_more = Minz_Request::paramBoolean('auto_load_more');
  112. FreshRSS_Context::$user_conf->display_posts = Minz_Request::paramBoolean('display_posts');
  113. FreshRSS_Context::$user_conf->display_categories = Minz_Request::paramString('display_categories') ?: 'active';
  114. FreshRSS_Context::$user_conf->show_tags = Minz_Request::paramString('show_tags') ?: '0';
  115. FreshRSS_Context::$user_conf->show_tags_max = Minz_Request::paramInt('show_tags_max');
  116. FreshRSS_Context::$user_conf->show_author_date = Minz_Request::paramString('show_author_date') ?: '0';
  117. FreshRSS_Context::$user_conf->show_feed_name = Minz_Request::paramString('show_feed_name') ?: 't';
  118. FreshRSS_Context::$user_conf->hide_read_feeds = Minz_Request::paramBoolean('hide_read_feeds');
  119. FreshRSS_Context::$user_conf->onread_jump_next = Minz_Request::paramBoolean('onread_jump_next');
  120. FreshRSS_Context::$user_conf->lazyload = Minz_Request::paramBoolean('lazyload');
  121. FreshRSS_Context::$user_conf->sides_close_article = Minz_Request::paramBoolean('sides_close_article');
  122. FreshRSS_Context::$user_conf->sticky_post = Minz_Request::paramBoolean('sticky_post');
  123. FreshRSS_Context::$user_conf->reading_confirm = Minz_Request::paramBoolean('reading_confirm');
  124. FreshRSS_Context::$user_conf->auto_remove_article = Minz_Request::paramBoolean('auto_remove_article');
  125. FreshRSS_Context::$user_conf->mark_updated_article_unread = Minz_Request::paramBoolean('mark_updated_article_unread');
  126. FreshRSS_Context::$user_conf->sort_order = Minz_Request::paramString('sort_order') ?: 'DESC';
  127. FreshRSS_Context::$user_conf->mark_when = [
  128. 'article' => Minz_Request::paramBoolean('mark_open_article'),
  129. 'gone' => Minz_Request::paramBoolean('read_upon_gone'),
  130. 'max_n_unread' => Minz_Request::paramBoolean('enable_keep_max_n_unread') ? Minz_Request::paramInt('keep_max_n_unread') : false,
  131. 'reception' => Minz_Request::paramBoolean('mark_upon_reception'),
  132. 'same_title_in_feed' =>
  133. Minz_Request::paramBoolean('enable_read_when_same_title_in_feed') && Minz_Request::paramBoolean('read_when_same_title_in_feed'),
  134. 'scroll' => Minz_Request::paramBoolean('mark_scroll'),
  135. 'site' => Minz_Request::paramBoolean('mark_open_site'),
  136. 'focus' => Minz_Request::paramBoolean('mark_focus'),
  137. ];
  138. FreshRSS_Context::$user_conf->save();
  139. invalidateHttpCache();
  140. Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'reading' ]);
  141. }
  142. FreshRSS_View::prependTitle(_t('conf.reading.title') . ' · ');
  143. }
  144. /**
  145. * This action handles the integration configuration page.
  146. *
  147. * It displays the integration configuration page.
  148. * If this action is reached through a POST request, it stores all
  149. * configuration values then sends a notification to the user.
  150. *
  151. * Before v1.16, we used sharing instead of integration. This has
  152. * some unwanted behavior when the end-user was using an ad-blocker.
  153. */
  154. public function integrationAction(): void {
  155. FreshRSS_View::appendScript(Minz_Url::display('/scripts/integration.js?' . @filemtime(PUBLIC_PATH . '/scripts/integration.js')));
  156. FreshRSS_View::appendScript(Minz_Url::display('/scripts/draggable.js?' . @filemtime(PUBLIC_PATH . '/scripts/draggable.js')));
  157. if (Minz_Request::isPost()) {
  158. $params = $_POST;
  159. FreshRSS_Context::$user_conf->sharing = $params['share'];
  160. FreshRSS_Context::$user_conf->save();
  161. invalidateHttpCache();
  162. Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'integration' ]);
  163. }
  164. FreshRSS_View::prependTitle(_t('conf.sharing.title') . ' · ');
  165. }
  166. /**
  167. * This action handles the shortcut configuration page.
  168. *
  169. * It displays the shortcut configuration page.
  170. * If this action is reached through a POST request, it stores all new
  171. * configuration values then sends a notification to the user.
  172. *
  173. * The authorized values for shortcuts are letters (a to z), numbers (0
  174. * to 9), function keys (f1 to f12), backspace, delete, down, end, enter,
  175. * escape, home, insert, left, page down, page up, return, right, space,
  176. * tab and up.
  177. */
  178. public function shortcutAction(): void {
  179. $this->view->list_keys = SHORTCUT_KEYS;
  180. if (Minz_Request::isPost()) {
  181. $shortcuts = Minz_Request::paramArray('shortcuts');
  182. if (Minz_Request::paramBoolean('load_default_shortcuts')) {
  183. $default = Minz_Configuration::load(FRESHRSS_PATH . '/config-user.default.php');
  184. $shortcuts = $default['shortcuts'];
  185. }
  186. FreshRSS_Context::$user_conf->shortcuts = array_map('trim', $shortcuts);
  187. FreshRSS_Context::$user_conf->save();
  188. invalidateHttpCache();
  189. Minz_Request::good(_t('feedback.conf.shortcuts_updated'), ['c' => 'configure', 'a' => 'shortcut']);
  190. }
  191. FreshRSS_View::prependTitle(_t('conf.shortcut.title') . ' · ');
  192. }
  193. /**
  194. * This action handles the archive configuration page.
  195. *
  196. * It displays the archive configuration page.
  197. * If this action is reached through a POST request, it stores all new
  198. * configuration values then sends a notification to the user.
  199. *
  200. * The options available on that page are:
  201. * - duration to retain old article (default: 3)
  202. * - number of article to retain per feed (default: 0)
  203. * - refresh frequency (default: 0)
  204. */
  205. public function archivingAction(): void {
  206. if (Minz_Request::isPost()) {
  207. if (Minz_Request::paramBoolean('enable_keep_max')) {
  208. $keepMax = Minz_Request::paramInt('keep_max') ?: FreshRSS_Feed::ARCHIVING_RETENTION_COUNT_LIMIT;
  209. } else {
  210. $keepMax = false;
  211. }
  212. if (Minz_Request::paramBoolean('enable_keep_period')) {
  213. $keepPeriod = FreshRSS_Feed::ARCHIVING_RETENTION_PERIOD;
  214. if (is_numeric(Minz_Request::paramString('keep_period_count')) && preg_match('/^PT?1[YMWDH]$/', Minz_Request::paramString('keep_period_unit'))) {
  215. $keepPeriod = str_replace('1', Minz_Request::paramString('keep_period_count'), Minz_Request::paramString('keep_period_unit'));
  216. }
  217. } else {
  218. $keepPeriod = false;
  219. }
  220. FreshRSS_Context::$user_conf->ttl_default = Minz_Request::paramInt('ttl_default') ?: FreshRSS_Feed::TTL_DEFAULT;
  221. FreshRSS_Context::$user_conf->archiving = [
  222. 'keep_period' => $keepPeriod,
  223. 'keep_max' => $keepMax,
  224. 'keep_min' => Minz_Request::paramInt('keep_min_default'),
  225. 'keep_favourites' => Minz_Request::paramBoolean('keep_favourites'),
  226. 'keep_labels' => Minz_Request::paramBoolean('keep_labels'),
  227. 'keep_unreads' => Minz_Request::paramBoolean('keep_unreads'),
  228. ];
  229. FreshRSS_Context::$user_conf->keep_history_default = null; //Legacy < FreshRSS 1.15
  230. FreshRSS_Context::$user_conf->old_entries = null; //Legacy < FreshRSS 1.15
  231. FreshRSS_Context::$user_conf->save();
  232. invalidateHttpCache();
  233. Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'archiving' ]);
  234. }
  235. $volatile = [
  236. 'enable_keep_period' => false,
  237. 'keep_period_count' => '3',
  238. 'keep_period_unit' => 'P1M',
  239. ];
  240. $keepPeriod = FreshRSS_Context::$user_conf->archiving['keep_period'];
  241. if (preg_match('/^PT?(?P<count>\d+)[YMWDH]$/', $keepPeriod, $matches)) {
  242. $volatile = [
  243. 'enable_keep_period' => true,
  244. 'keep_period_count' => $matches['count'],
  245. 'keep_period_unit' => str_replace($matches['count'], '1', $keepPeriod),
  246. ];
  247. }
  248. FreshRSS_Context::$user_conf->volatile = $volatile;
  249. $entryDAO = FreshRSS_Factory::createEntryDao();
  250. $this->view->nb_total = $entryDAO->count();
  251. $databaseDAO = FreshRSS_Factory::createDatabaseDAO();
  252. $this->view->size_user = $databaseDAO->size();
  253. if (FreshRSS_Auth::hasAccess('admin')) {
  254. $this->view->size_total = $databaseDAO->size(true);
  255. }
  256. FreshRSS_View::prependTitle(_t('conf.archiving.title') . ' · ');
  257. }
  258. /**
  259. * This action handles the user queries configuration page.
  260. *
  261. * If this action is reached through a POST request, it stores all new
  262. * configuration values then sends a notification to the user then
  263. * redirect to the same page.
  264. * If this action is not reached through a POST request, it displays the
  265. * configuration page and verifies that every user query is runable by
  266. * checking if categories and feeds are still in use.
  267. */
  268. public function queriesAction(): void {
  269. FreshRSS_View::appendScript(Minz_Url::display('/scripts/draggable.js?' . @filemtime(PUBLIC_PATH . '/scripts/draggable.js')));
  270. $category_dao = FreshRSS_Factory::createCategoryDao();
  271. $feed_dao = FreshRSS_Factory::createFeedDao();
  272. $tag_dao = FreshRSS_Factory::createTagDao();
  273. if (Minz_Request::isPost()) {
  274. /** @var array<int,array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string}> $params */
  275. $params = Minz_Request::paramArray('queries');
  276. $queries = [];
  277. foreach ($params as $key => $query) {
  278. $key = (int)$key;
  279. if (empty($query['name'])) {
  280. $query['name'] = _t('conf.query.number', $key + 1);
  281. }
  282. if (!empty($query['search'])) {
  283. $query['search'] = urldecode($query['search']);
  284. }
  285. $queries[$key] = (new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao))->toArray();
  286. }
  287. FreshRSS_Context::$user_conf->queries = $queries;
  288. FreshRSS_Context::$user_conf->save();
  289. Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'queries' ]);
  290. } else {
  291. $this->view->queries = [];
  292. foreach (FreshRSS_Context::$user_conf->queries as $key => $query) {
  293. $this->view->queries[intval($key)] = new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao);
  294. }
  295. }
  296. $this->view->categories = $category_dao->listCategories(false) ?: [];
  297. $this->view->feeds = $feed_dao->listFeeds();
  298. $this->view->tags = $tag_dao->listTags() ?: [];
  299. if (Minz_Request::paramTernary('id') !== null) {
  300. $id = Minz_Request::paramInt('id');
  301. $this->view->query = $this->view->queries[$id];
  302. $this->view->queryId = $id;
  303. $this->view->displaySlider = true;
  304. } else {
  305. $this->view->displaySlider = false;
  306. }
  307. FreshRSS_View::prependTitle(_t('conf.query.title') . ' · ');
  308. }
  309. /**
  310. * Handles query configuration.
  311. * It displays the query configuration page and handles modifications
  312. * applied to the selected query.
  313. */
  314. public function queryAction(): void {
  315. if (Minz_Request::paramBoolean('ajax')) {
  316. $this->view->_layout(null);
  317. }
  318. $id = Minz_Request::paramInt('id');
  319. if (Minz_Request::paramTernary('id') === null || empty(FreshRSS_Context::$user_conf->queries[$id])) {
  320. Minz_Error::error(404);
  321. return;
  322. }
  323. $category_dao = FreshRSS_Factory::createCategoryDao();
  324. $feed_dao = FreshRSS_Factory::createFeedDao();
  325. $tag_dao = FreshRSS_Factory::createTagDao();
  326. $query = new FreshRSS_UserQuery(FreshRSS_Context::$user_conf->queries[$id], $feed_dao, $category_dao, $tag_dao);
  327. $this->view->query = $query;
  328. $this->view->queryId = $id;
  329. $this->view->categories = $category_dao->listCategories(false) ?: [];
  330. $this->view->feeds = $feed_dao->listFeeds();
  331. $this->view->tags = $tag_dao->listTags() ?: [];
  332. if (Minz_Request::isPost()) {
  333. /** @var array<string,string|array<string,string>> $params */
  334. $params = array_filter(Minz_Request::paramArray('query'));
  335. $queryParams = [];
  336. if (!empty($params['get']) && is_string($params['get'])) {
  337. $queryParams['get'] = htmlspecialchars_decode($params['get'], ENT_QUOTES);
  338. }
  339. if (!empty($params['order']) && is_string($params['order'])) {
  340. $queryParams['order'] = htmlspecialchars_decode($params['order'], ENT_QUOTES);
  341. }
  342. if (!empty($params['search']) && is_string($params['search'])) {
  343. $queryParams['search'] = htmlspecialchars_decode($params['search'], ENT_QUOTES);
  344. }
  345. if (!empty($params['state']) && is_array($params['state'])) {
  346. $queryParams['state'] = (int)(array_sum($params['state']));
  347. }
  348. $name = Minz_Request::paramString('name') ?: _t('conf.query.number', $id + 1);
  349. if ('' === $name) {
  350. $name = _t('conf.query.number', $id + 1);
  351. }
  352. $queryParams['name'] = $name;
  353. $queryParams['url'] = Minz_Url::display(['params' => $queryParams]);
  354. $queries = FreshRSS_Context::$user_conf->queries;
  355. $queries[$id] = (new FreshRSS_UserQuery($queryParams, $feed_dao, $category_dao, $tag_dao))->toArray();
  356. FreshRSS_Context::$user_conf->queries = $queries;
  357. FreshRSS_Context::$user_conf->save();
  358. Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'queries', 'params' => ['id' => (string)$id] ]);
  359. }
  360. FreshRSS_View::prependTitle($query->getName() . ' · ' . _t('conf.query.title') . ' · ');
  361. }
  362. /**
  363. * Handles query deletion
  364. */
  365. public function deleteQueryAction(): void {
  366. $id = Minz_Request::paramInt('id');
  367. if (Minz_Request::paramTernary('id') === null || empty(FreshRSS_Context::$user_conf->queries[$id])) {
  368. Minz_Error::error(404);
  369. return;
  370. }
  371. $queries = FreshRSS_Context::$user_conf->queries;
  372. unset($queries[$id]);
  373. FreshRSS_Context::$user_conf->queries = $queries;
  374. FreshRSS_Context::$user_conf->save();
  375. Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'queries' ]);
  376. }
  377. /**
  378. * This action handles the creation of a user query.
  379. *
  380. * It gets the GET parameters and stores them in the configuration query
  381. * storage. Before it is saved, the unwanted parameters are unset to keep
  382. * lean data.
  383. */
  384. public function bookmarkQueryAction(): void {
  385. $category_dao = FreshRSS_Factory::createCategoryDao();
  386. $feed_dao = FreshRSS_Factory::createFeedDao();
  387. $tag_dao = FreshRSS_Factory::createTagDao();
  388. $queries = [];
  389. foreach (FreshRSS_Context::$user_conf->queries as $key => $query) {
  390. $queries[$key] = (new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao))->toArray();
  391. }
  392. $params = $_GET;
  393. unset($params['rid']);
  394. $params['url'] = Minz_Url::display(['params' => $params]);
  395. $params['name'] = _t('conf.query.number', count($queries) + 1);
  396. $queries[] = (new FreshRSS_UserQuery($params, $feed_dao, $category_dao, $tag_dao))->toArray();
  397. FreshRSS_Context::$user_conf->queries = $queries;
  398. FreshRSS_Context::$user_conf->save();
  399. Minz_Request::good(_t('feedback.conf.query_created', $params['name']), [ 'c' => 'configure', 'a' => 'queries' ]);
  400. }
  401. /**
  402. * This action handles the system configuration page.
  403. *
  404. * It displays the system configuration page.
  405. * If this action is reach through a POST request, it stores all new
  406. * configuration values then sends a notification to the user.
  407. *
  408. * The options available on the page are:
  409. * - instance name (default: FreshRSS)
  410. * - auto update URL (default: false)
  411. * - force emails validation (default: false)
  412. * - user limit (default: 1)
  413. * - user category limit (default: 16384)
  414. * - user feed limit (default: 16384)
  415. * - user login duration for form auth (default: FreshRSS_Auth::DEFAULT_COOKIE_DURATION)
  416. *
  417. * The `force-email-validation` is ignored with PHP < 5.5
  418. */
  419. public function systemAction(): void {
  420. if (!FreshRSS_Auth::hasAccess('admin')) {
  421. Minz_Error::error(403);
  422. }
  423. if (Minz_Request::isPost()) {
  424. $limits = FreshRSS_Context::$system_conf->limits;
  425. $limits['max_registrations'] = Minz_Request::paramInt('max-registrations') ?: 1;
  426. $limits['max_feeds'] = Minz_Request::paramInt('max-feeds') ?: 16384;
  427. $limits['max_categories'] = Minz_Request::paramInt('max-categories') ?: 16384;
  428. $limits['cookie_duration'] = Minz_Request::paramInt('cookie-duration') ?: FreshRSS_Auth::DEFAULT_COOKIE_DURATION;
  429. FreshRSS_Context::$system_conf->limits = $limits;
  430. FreshRSS_Context::$system_conf->title = Minz_Request::paramString('instance-name') ?: 'FreshRSS';
  431. FreshRSS_Context::$system_conf->auto_update_url = Minz_Request::paramString('auto-update-url');
  432. FreshRSS_Context::$system_conf->force_email_validation = Minz_Request::paramBoolean('force-email-validation');
  433. FreshRSS_Context::$system_conf->base_url = Minz_Request::paramString('base-url');
  434. FreshRSS_Context::$system_conf->save();
  435. invalidateHttpCache();
  436. Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'system' ]);
  437. }
  438. }
  439. }