aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-04 13:30:45 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-04 13:30:45 +0100
commitb3239256dc6d188cda970adab516b3fcf1b86129 (patch)
treed8e65dd9784834ba2e82ce7ee94b4718f8af19ea /app/Controllers
parent27b71ffa99f7dff013fb8d51d020ed628e0d2ce6 (diff)
parent0fe0ce894cbad09757d719dd4b400b9862c1a12a (diff)
Merge branch 'edge' into latest
Diffstat (limited to 'app/Controllers')
-rw-r--r--[-rwxr-xr-x]app/Controllers/configureController.php35
-rw-r--r--[-rwxr-xr-x]app/Controllers/entryController.php0
-rw-r--r--[-rwxr-xr-x]app/Controllers/feedController.php18
-rw-r--r--app/Controllers/importExportController.php2
-rw-r--r--[-rwxr-xr-x]app/Controllers/indexController.php2
-rw-r--r--[-rwxr-xr-x]app/Controllers/javascriptController.php8
-rw-r--r--app/Controllers/statsController.php37
-rw-r--r--app/Controllers/subscriptionController.php18
-rw-r--r--app/Controllers/updateController.php12
-rw-r--r--app/Controllers/userController.php3
10 files changed, 62 insertions, 73 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 613bacade..791d58d6d 100755..100644
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -25,6 +25,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
* The options available on the page are:
* - language (default: en)
* - theme (default: Origin)
+ * - darkMode (default: no)
* - content width (default: thin)
* - display of read action in header
* - display of favorite action in header
@@ -42,7 +43,9 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
public function displayAction() {
if (Minz_Request::isPost()) {
FreshRSS_Context::$user_conf->language = Minz_Request::param('language', 'en');
+ FreshRSS_Context::$user_conf->timezone = Minz_Request::param('timezone', '');
FreshRSS_Context::$user_conf->theme = Minz_Request::param('theme', FreshRSS_Themes::$defaultTheme);
+ FreshRSS_Context::$user_conf->darkMode = Minz_Request::param('darkMode', 'no');
FreshRSS_Context::$user_conf->content_width = Minz_Request::param('content_width', 'thin');
FreshRSS_Context::$user_conf->topline_read = Minz_Request::param('topline_read', false);
FreshRSS_Context::$user_conf->topline_favorite = Minz_Request::param('topline_favorite', false);
@@ -106,32 +109,32 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
FreshRSS_Context::$user_conf->posts_per_page = Minz_Request::param('posts_per_page', 10);
FreshRSS_Context::$user_conf->view_mode = Minz_Request::param('view_mode', 'normal');
FreshRSS_Context::$user_conf->default_view = Minz_Request::param('default_view', 'adaptive');
- FreshRSS_Context::$user_conf->show_fav_unread = Minz_Request::param('show_fav_unread', false);
- FreshRSS_Context::$user_conf->auto_load_more = Minz_Request::param('auto_load_more', false);
- FreshRSS_Context::$user_conf->display_posts = Minz_Request::param('display_posts', false);
+ FreshRSS_Context::$user_conf->show_fav_unread = Minz_Request::paramBoolean('show_fav_unread');
+ FreshRSS_Context::$user_conf->auto_load_more = Minz_Request::paramBoolean('auto_load_more');
+ FreshRSS_Context::$user_conf->display_posts = Minz_Request::paramBoolean('display_posts');
FreshRSS_Context::$user_conf->display_categories = Minz_Request::param('display_categories', 'active');
FreshRSS_Context::$user_conf->show_tags = Minz_Request::param('show_tags', '0');
FreshRSS_Context::$user_conf->show_tags_max = Minz_Request::param('show_tags_max', '0');
FreshRSS_Context::$user_conf->show_author_date = Minz_Request::param('show_author_date', '0');
FreshRSS_Context::$user_conf->show_feed_name = Minz_Request::param('show_feed_name', 't');
- FreshRSS_Context::$user_conf->hide_read_feeds = Minz_Request::param('hide_read_feeds', false);
- FreshRSS_Context::$user_conf->onread_jump_next = Minz_Request::param('onread_jump_next', false);
- FreshRSS_Context::$user_conf->lazyload = Minz_Request::param('lazyload', false);
- FreshRSS_Context::$user_conf->sides_close_article = Minz_Request::param('sides_close_article', false);
- FreshRSS_Context::$user_conf->sticky_post = Minz_Request::param('sticky_post', false);
- FreshRSS_Context::$user_conf->reading_confirm = Minz_Request::param('reading_confirm', false);
- FreshRSS_Context::$user_conf->auto_remove_article = Minz_Request::param('auto_remove_article', false);
- FreshRSS_Context::$user_conf->mark_updated_article_unread = Minz_Request::param('mark_updated_article_unread', false);
+ FreshRSS_Context::$user_conf->hide_read_feeds = Minz_Request::paramBoolean('hide_read_feeds');
+ FreshRSS_Context::$user_conf->onread_jump_next = Minz_Request::paramBoolean('onread_jump_next');
+ FreshRSS_Context::$user_conf->lazyload = Minz_Request::paramBoolean('lazyload');
+ FreshRSS_Context::$user_conf->sides_close_article = Minz_Request::paramBoolean('sides_close_article');
+ FreshRSS_Context::$user_conf->sticky_post = Minz_Request::paramBoolean('sticky_post');
+ FreshRSS_Context::$user_conf->reading_confirm = Minz_Request::paramBoolean('reading_confirm');
+ FreshRSS_Context::$user_conf->auto_remove_article = Minz_Request::paramBoolean('auto_remove_article');
+ FreshRSS_Context::$user_conf->mark_updated_article_unread = Minz_Request::paramBoolean('mark_updated_article_unread');
FreshRSS_Context::$user_conf->sort_order = Minz_Request::param('sort_order', 'DESC');
FreshRSS_Context::$user_conf->mark_when = array(
- 'article' => Minz_Request::param('mark_open_article', false),
- 'gone' => Minz_Request::param('read_upon_gone', false),
+ 'article' => Minz_Request::paramBoolean('mark_open_article'),
+ 'gone' => Minz_Request::paramBoolean('read_upon_gone'),
'max_n_unread' => Minz_Request::paramBoolean('enable_keep_max_n_unread') ? Minz_Request::param('keep_max_n_unread', false) : false,
- 'reception' => Minz_Request::param('mark_upon_reception', false),
+ 'reception' => Minz_Request::paramBoolean('mark_upon_reception'),
'same_title_in_feed' => Minz_Request::paramBoolean('enable_read_when_same_title_in_feed') ?
Minz_Request::param('read_when_same_title_in_feed', false) : false,
- 'scroll' => Minz_Request::param('mark_scroll', false),
- 'site' => Minz_Request::param('mark_open_site', false),
+ 'scroll' => Minz_Request::paramBoolean('mark_scroll'),
+ 'site' => Minz_Request::paramBoolean('mark_open_site'),
);
FreshRSS_Context::$user_conf->save();
invalidateHttpCache();
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php
index 6750de43b..6750de43b 100755..100644
--- a/app/Controllers/entryController.php
+++ b/app/Controllers/entryController.php
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 319faece8..84f38fe5e 100755..100644
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -81,6 +81,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$feed->load(true); //Throws FreshRSS_Feed_Exception, Minz_FileNotExistException
break;
case FreshRSS_Feed::KIND_HTML_XPATH:
+ case FreshRSS_Feed::KIND_XML_XPATH:
$feed->_website($url);
break;
}
@@ -172,7 +173,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$proxy_address = Minz_Request::param('curl_params', '');
$proxy_type = Minz_Request::param('proxy_type', '');
$opts = [];
- if ($proxy_address !== '' && $proxy_type !== '' && in_array($proxy_type, [0, 2, 4, 5, 6, 7])) {
+ if ($proxy_type !== '') {
$opts[CURLOPT_PROXY] = $proxy_address;
$opts[CURLOPT_PROXYTYPE] = intval($proxy_type);
}
@@ -201,8 +202,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$timeout = intval(Minz_Request::param('timeout', 0));
$attributes['timeout'] = $timeout > 0 ? $timeout : null;
- $feed_kind = Minz_Request::param('feed_kind', FreshRSS_Feed::KIND_RSS);
- if ($feed_kind == FreshRSS_Feed::KIND_HTML_XPATH) {
+ $feed_kind = (int)Minz_Request::param('feed_kind', FreshRSS_Feed::KIND_RSS);
+ if ($feed_kind === FreshRSS_Feed::KIND_HTML_XPATH || $feed_kind === FreshRSS_Feed::KIND_XML_XPATH) {
$xPathSettings = [];
if (Minz_Request::param('xPathFeedTitle', '') != '') $xPathSettings['feedTitle'] = Minz_Request::param('xPathFeedTitle', '', true);
if (Minz_Request::param('xPathItem', '') != '') $xPathSettings['item'] = Minz_Request::param('xPathItem', '', true);
@@ -385,10 +386,15 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
if ($simplePiePush) {
$simplePie = $simplePiePush; //Used by WebSub
} elseif ($feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH) {
- $simplePie = $feed->loadHtmlXpath(false, $isNewFeed);
- if ($simplePie == null) {
+ $simplePie = $feed->loadHtmlXpath();
+ if ($simplePie === null) {
throw new FreshRSS_Feed_Exception('HTML+XPath Web scraping failed for [' . $feed->url(false) . ']');
}
+ } elseif ($feed->kind() === FreshRSS_Feed::KIND_XML_XPATH) {
+ $simplePie = $feed->loadHtmlXpath();
+ if ($simplePie === null) {
+ throw new FreshRSS_Feed_Exception('XML+XPath parsing failed for [' . $feed->url(false) . ']');
+ }
} else {
$simplePie = $feed->load(false, $isNewFeed);
}
@@ -949,7 +955,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$this->view->htmlContent = $fullContent;
} else {
$this->view->selectorSuccess = false;
- $this->view->htmlContent = $entry->content();
+ $this->view->htmlContent = $entry->content(false);
}
} catch (Exception $e) {
$this->view->fatalError = _t('feedback.sub.feed.selector_preview.http_error');
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index a1e1106c1..6c4b684e9 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -21,8 +21,6 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
Minz_Error::error(403);
}
- require_once(LIB_PATH . '/lib_opml.php');
-
$this->entryDAO = FreshRSS_Factory::createEntryDao();
$this->feedDAO = FreshRSS_Factory::createFeedDao();
}
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index 7fced48af..968518e3f 100755..100644
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -237,8 +237,6 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
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');
diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php
index c2a5cb872..b4e769738 100755..100644
--- a/app/Controllers/javascriptController.php
+++ b/app/Controllers/javascriptController.php
@@ -1,11 +1,11 @@
<?php
class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
- public function firstAction() {
+ public function firstAction(): void {
$this->view->_layout(false);
}
- public function actualizeAction() {
+ public function actualizeAction(): void {
header('Content-Type: application/json; charset=UTF-8');
Minz_Session::_param('actualize_feeds', false);
@@ -16,7 +16,7 @@ class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
$this->view->feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::$user_conf->ttl_default);
}
- public function nbUnreadsPerFeedAction() {
+ public function nbUnreadsPerFeedAction(): void {
header('Content-Type: application/json; charset=UTF-8');
$catDAO = FreshRSS_Factory::createCategoryDao();
$this->view->categories = $catDAO->listCategories(true, false);
@@ -25,7 +25,7 @@ class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
}
//For Web-form login
- public function nonceAction() {
+ public function nonceAction(): void {
header('Content-Type: application/json; charset=UTF-8');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s \G\M\T'));
header('Expires: 0');
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
index 1798ee3cf..16b09d702 100644
--- a/app/Controllers/statsController.php
+++ b/app/Controllers/statsController.php
@@ -10,7 +10,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
* the common boiler plate for every action. It is triggered by the
* underlying framework.
*/
- public function firstAction() {
+ public function firstAction(): void {
if (!FreshRSS_Auth::hasAccess()) {
Minz_Error::error(403);
}
@@ -32,27 +32,6 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
FreshRSS_View::prependTitle(_t('admin.stats.title') . ' ยท ');
}
- private function convertToSeries($data) {
- $series = array();
-
- foreach ($data as $key => $value) {
- $series[] = array($key, $value);
- }
-
- return $series;
- }
-
- private function convertToPieSeries($data) {
- $series = array();
-
- foreach ($data as $value) {
- $value['data'] = array(array(0, (int) $value['data']));
- $series[] = $value;
- }
-
- return $series;
- }
-
/**
* This action handles the statistic main page.
*
@@ -64,7 +43,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
* - number of article by category (entryByCategory)
* - list of most prolific feed (topFeed)
*/
- public function indexAction() {
+ public function indexAction(): void {
$statsDAO = FreshRSS_Factory::createStatsDAO();
FreshRSS_View::appendScript(Minz_Url::display('/scripts/vendor/chart.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/vendor/chart.min.js')));
@@ -94,7 +73,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
$last30DaysLabels = [];
for ($i = 0; $i < 30; $i++) {
- $last30DaysLabels[$i] = date('d.m.Y', strtotime((-30 + $i) . ' days'));
+ $last30DaysLabels[$i] = date('d.m.Y', strtotime((-30 + $i) . ' days') ?: null);
}
$this->view->last30DaysLabels = $last30DaysLabels;
@@ -106,9 +85,9 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
* to use the subscription controller to save it,
* but shows the stats idle page
*/
- public function feedAction() {
- $id = Minz_Request::param('id');
- $ajax = Minz_Request::param('ajax');
+ public function feedAction(): void {
+ $id = '' . Minz_Request::param('id', '');
+ $ajax = '' . Minz_Request::param('ajax', '');
if ($ajax) {
$url_redirect = array('c' => 'subscription', 'a' => 'feed', 'params' => array('id' => $id, 'from' => 'stats', 'ajax' => $ajax));
} else {
@@ -131,7 +110,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
* - last month
* - last week
*/
- public function idleAction() {
+ public function idleAction(): void {
FreshRSS_View::appendScript(Minz_Url::display('/scripts/feed.js?' . @filemtime(PUBLIC_PATH . '/scripts/feed.js')));
$feed_dao = FreshRSS_Factory::createFeedDao();
$statsDAO = FreshRSS_Factory::createStatsDAO();
@@ -216,7 +195,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
* @todo verify that the metrics used here make some sense. Especially
* for the average.
*/
- public function repartitionAction() {
+ public function repartitionAction(): void {
$statsDAO = FreshRSS_Factory::createStatsDAO();
$categoryDAO = FreshRSS_Factory::createCategoryDao();
$feedDAO = FreshRSS_Factory::createFeedDao();
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index 4a63d1ee4..f0355a82a 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -118,8 +118,6 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
$httpAuth = $user . ':' . $pass;
}
- $cat = intval(Minz_Request::param('category', 0));
-
$feed->_ttl(intval(Minz_Request::param('ttl', FreshRSS_Feed::TTL_DEFAULT)));
$feed->_mute(boolval(Minz_Request::param('mute', false)));
@@ -149,7 +147,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
$proxy_address = Minz_Request::param('curl_params', '');
$proxy_type = Minz_Request::param('proxy_type', '');
$opts = [];
- if ($proxy_address !== '' && $proxy_type !== '' && in_array($proxy_type, [0, 2, 4, 5, 6, 7])) {
+ if ($proxy_type !== '') {
$opts[CURLOPT_PROXY] = $proxy_address;
$opts[CURLOPT_PROXYTYPE] = intval($proxy_type);
}
@@ -205,7 +203,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
$feed->_filtersAction('read', preg_split('/[\n\r]+/', Minz_Request::param('filteractions_read', '')));
$feed->_kind(intval(Minz_Request::param('feed_kind', FreshRSS_Feed::KIND_RSS)));
- if ($feed->kind() == FreshRSS_Feed::KIND_HTML_XPATH) {
+ if ($feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH || $feed->kind() === FreshRSS_Feed::KIND_XML_XPATH) {
$xPathSettings = [];
if (Minz_Request::param('xPathItem', '') != '') $xPathSettings['item'] = Minz_Request::param('xPathItem', '', true);
if (Minz_Request::param('xPathItemTitle', '') != '') $xPathSettings['itemTitle'] = Minz_Request::param('xPathItemTitle', '', true);
@@ -230,7 +228,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
'description' => sanitizeHTML(Minz_Request::param('description', '', true)),
'website' => checkUrl(Minz_Request::param('website', '')),
'url' => checkUrl(Minz_Request::param('url', '')),
- 'category' => $cat,
+ 'category' => intval(Minz_Request::param('category', 0)),
'pathEntries' => Minz_Request::param('path_entries', ''),
'priority' => intval(Minz_Request::param('priority', FreshRSS_Feed::PRIORITY_MAIN_STREAM)),
'httpAuth' => $httpAuth,
@@ -258,12 +256,18 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
$url_redirect = array('c' => 'subscription', 'params' => array('id' => $id));
}
- if ($feedDAO->updateFeed($id, $values) !== false) {
- $feed->_categoryId($cat);
+ if ($values['url'] != '' && $feedDAO->updateFeed($id, $values) !== false) {
+ $feed->_categoryId($values['category']);
+ // update url and website values for faviconPrepare
+ $feed->_url($values['url'], false);
+ $feed->_website($values['website'], false);
$feed->faviconPrepare();
Minz_Request::good(_t('feedback.sub.feed.updated'), $url_redirect);
} else {
+ if ($values['url'] == '') {
+ Minz_Log::warning('Invalid feed URL!');
+ }
Minz_Request::bad(_t('feedback.sub.feed.error'), $url_redirect);
}
}
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 675bd7def..f638ce96c 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -14,7 +14,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
public static function migrateToGitEdge() {
$errorMessage = 'Error during git checkout to edge branch. Please change branch manually!';
- if (!is_writable(FRESHRSS_PATH . '/.git/')) {
+ if (!is_writable(FRESHRSS_PATH . '/.git/config')) {
throw new Exception($errorMessage);
}
@@ -23,7 +23,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
if ($return != 0) {
throw new Exception($errorMessage);
}
- $line = is_array($output) ? implode('', $output) : $output;
+ $line = implode('', $output);
if ($line !== 'master' && $line !== 'dev') {
return true; // not on master or dev, nothing to do
}
@@ -54,14 +54,14 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
$output = [];
exec('git status -sb --porcelain remote', $output, $return);
} else {
- $line = is_array($output) ? implode('; ', $output) : $output;
+ $line = implode('; ', $output);
Minz_Log::warning('git fetch warning: ' . $line);
}
} catch (Exception $e) {
Minz_Log::warning('git fetch error: ' . $e->getMessage());
}
chdir($cwd);
- $line = is_array($output) ? implode('; ', $output) : $output;
+ $line = implode('; ', $output);
return $line == '' ||
strpos($line, '[behind') !== false || strpos($line, '[ahead') !== false || strpos($line, '[gone') !== false;
}
@@ -118,7 +118,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
if ($version == '') {
$version = 'unknown';
}
- if (is_writable(FRESHRSS_PATH)) {
+ if (touch(FRESHRSS_PATH . '/index.html')) {
$this->view->update_to_apply = true;
$this->view->message = array(
'status' => 'good',
@@ -217,7 +217,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
}
public function applyAction() {
- if (!file_exists(UPDATE_FILENAME) || !is_writable(FRESHRSS_PATH) || Minz_Configuration::get('system')->disable_update) {
+ if (FreshRSS_Context::$system_conf->disable_update || !file_exists(UPDATE_FILENAME) || !touch(FRESHRSS_PATH . '/index.html')) {
Minz_Request::forward(array('c' => 'update'), true);
}
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index 06dbab9fa..ac8f3be82 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -242,7 +242,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
}
if ($ok) {
if (!is_dir($homeDir)) {
- mkdir($homeDir);
+ mkdir($homeDir, 0770, true);
}
$ok &= (file_put_contents($configPath, "<?php\n return " . var_export($userConfig, true) . ';') !== false);
}
@@ -344,6 +344,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
$ok = self::createUser($new_user_name, $email, $passwordPlain, array(
'language' => Minz_Request::param('new_user_language', FreshRSS_Context::$user_conf->language),
+ 'timezone' => Minz_Request::param('new_user_timezone', ''),
'is_admin' => Minz_Request::paramBoolean('new_user_is_admin'),
'enabled' => true,
));