configureController.php 21 KB

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