aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-27 14:52:56 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-27 14:52:56 +0100
commitf52ccf7038199f1eb2f82d7e1f26d2a10caa867b (patch)
tree7c8235198b6b587574b41175a167103d31740a9a /app
parent7b4451912e2a9008a49854a2496cf9bb99b7ed10 (diff)
parentb99979cef78f7cd0c1cb4ae81115d09881e85926 (diff)
Merge remote-tracking branch 'origin/dev' into beta
Diffstat (limited to 'app')
-rw-r--r--app/.htaccess3
-rwxr-xr-xapp/Controllers/entryController.php2
-rwxr-xr-xapp/Controllers/feedController.php29
-rw-r--r--app/FreshRSS.php2
-rw-r--r--app/Models/CategoryDAO.php2
-rw-r--r--app/Models/Configuration.php16
-rw-r--r--app/Models/Entry.php7
-rw-r--r--app/Models/Feed.php39
-rw-r--r--app/Models/FeedDAO.php6
-rwxr-xr-xapp/actualize_script.php15
-rw-r--r--app/i18n/en.php3
-rw-r--r--app/i18n/fr.php3
-rw-r--r--app/index.html13
-rw-r--r--app/layout/nav_menu.phtml6
-rw-r--r--app/views/helpers/javascript_vars.phtml7
-rw-r--r--app/views/index/about.phtml3
16 files changed, 96 insertions, 60 deletions
diff --git a/app/.htaccess b/app/.htaccess
new file mode 100644
index 000000000..9e768397d
--- /dev/null
+++ b/app/.htaccess
@@ -0,0 +1,3 @@
+Order Allow,Deny
+Deny from all
+Satisfy all
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php
index 1c3c56c4d..26f3422ca 100755
--- a/app/Controllers/entryController.php
+++ b/app/Controllers/entryController.php
@@ -131,7 +131,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController {
$nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, $feedHistory);
if ($nb > 0) {
$nbTotal += $nb;
- Minz_Log::record($nb . ' old entries cleaned in feed ' . $feed->id(), Minz_Log::DEBUG);
+ Minz_Log::record($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG);
$feedDAO->updateLastUpdate($feed->id());
}
}
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 04d0aa98b..ca230232f 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -20,15 +20,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$this->catDAO->checkDefault ();
}
- private static function entryDateComparer($e1, $e2) {
- $d1 = $e1->date(true);
- $d2 = $e2->date(true);
- if ($d1 === $d2) {
- return 0;
- }
- return ($d1 < $d2) ? -1 : 1;
- }
-
public function addAction () {
@set_time_limit(300);
@@ -55,7 +46,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
$feed->_httpAuth ($httpAuth);
- $feed->load ();
+ $feed->load(true);
$feedDAO = new FreshRSS_FeedDAO ();
$values = array (
@@ -91,8 +82,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$is_read = $this->view->conf->markUponReception() === 'yes' ? 1 : 0;
$entryDAO = new FreshRSS_EntryDAO ();
- $entries = $feed->entries ();
- usort($entries, 'self::entryDateComparer');
+ $entries = array_reverse($feed->entries()); //We want chronological order and SimplePie uses reverse order
// on calcule la date des articles les plus anciens qu'on accepte
$nb_month_old = $this->view->conf->oldEntries ();
@@ -199,10 +189,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$flux_update = 0;
foreach ($feeds as $feed) {
try {
- $feed->load ();
- $feed->faviconPrepare();
- $entries = $feed->entries ();
- usort($entries, 'self::entryDateComparer');
+ $url = $feed->url();
+ $feed->load(false);
+ $entries = array_reverse($feed->entries()); //We want chronological order and SimplePie uses reverse order
$is_read = $this->view->conf->markUponReception() === 'yes' ? 1 : 0;
@@ -231,7 +220,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
if (($feedHistory >= 0) && (rand(0, 30) === 1)) {
$nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, max($feedHistory, count($entries) + 10));
if ($nb > 0) {
- Minz_Log::record ($nb . ' old entries cleaned in feed ' . $feed->id (), Minz_Log::DEBUG);
+ Minz_Log::record ($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG);
}
}
@@ -239,6 +228,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feedDAO->updateLastUpdate ($feed->id ());
$feedDAO->commit ();
$flux_update++;
+ if ($feed->url() !== $url) { //URL has changed (auto-discovery)
+ $feedDAO->updateFeed($feed->id(), array('url' => $feed->url()));
+ }
+ $feed->faviconPrepare();
} catch (FreshRSS_Feed_Exception $e) {
Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE);
$feedDAO->updateLastUpdate ($feed->id (), 1);
@@ -395,7 +388,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
'type' => 'good',
'content' => Minz_Translate::t ('feed_deleted')
);
- FreshRSS_Feed::faviconDelete($id);
+ //TODO: Delete old favicon
} else {
$notif = array (
'type' => 'bad',
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index 90548793d..60610e352 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -1,7 +1,7 @@
<?php
class FreshRSS extends Minz_FrontController {
public function init () {
- Minz_Session::init ();
+ Minz_Session::init ('FreshRSS');
Minz_Translate::init ();
$this->loadParamsView ();
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index 6b07ab063..1cc616ac0 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -90,7 +90,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
if ($prePopulateFeeds) {
$sql = 'SELECT c.id AS c_id, c.name AS c_name, '
. ($details ? 'c.color AS c_color, ' : '')
- . ($details ? 'f.* ' : 'f.id, f.name, f.website, f.priority, f.error, f.cache_nbEntries, f.cache_nbUnreads ')
+ . ($details ? 'f.* ' : 'f.id, f.name, f.url, f.website, f.priority, f.error, f.cache_nbEntries, f.cache_nbUnreads ')
. 'FROM `' . $this->prefix . 'category` c '
. 'LEFT OUTER JOIN `' . $this->prefix . 'feed` f ON f.category = c.id '
. 'GROUP BY f.id '
diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php
index 47509636f..cb2f90655 100644
--- a/app/Models/Configuration.php
+++ b/app/Models/Configuration.php
@@ -220,19 +220,13 @@ class FreshRSS_Configuration extends Minz_Model {
public function _sortOrder ($value) {
$this->sort_order = $value === 'ASC' ? 'ASC' : 'DESC';
}
- public function _oldEntries ($value) {
- if (ctype_digit ($value) && $value > 0) {
- $this->old_entries = intval($value);
- } else {
- $this->old_entries = 3;
- }
+ public function _oldEntries($value) {
+ $value = intval($value);
+ $this->old_entries = $value > 0 ? $value : 3;
}
public function _keepHistoryDefault($value) {
- if (ctype_digit($value) && $value >= -1) {
- $this->keep_history_default = intval($value);
- } else {
- $this->keep_history_default = 0;
- }
+ $value = intval($value);
+ $this->keep_history_default = $value >= -1 ? $value : 0;
}
public function _shortcuts ($values) {
foreach ($values as $key => $value) {
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index ed31ef2b1..ab9605eb1 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -106,11 +106,8 @@ class FreshRSS_Entry extends Minz_Model {
$this->link = $value;
}
public function _date ($value) {
- if (ctype_digit ($value)) {
- $this->date = intval ($value);
- } else {
- $this->date = time ();
- }
+ $value = intval($value);
+ $this->date = $value > 1 ? $value : time();
}
public function _isRead ($value) {
$this->is_read = $value;
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index dcf97d4ec..32f8546dd 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -16,6 +16,7 @@ class FreshRSS_Feed extends Minz_Model {
private $httpAuth = '';
private $error = false;
private $keep_history = -2;
+ private $hash = null;
public function __construct ($url, $validate=true) {
if ($validate) {
@@ -28,6 +29,14 @@ class FreshRSS_Feed extends Minz_Model {
public function id () {
return $this->id;
}
+
+ public function hash() {
+ if ($this->hash === null) {
+ $this->hash = hash('crc32b', Minz_Configuration::salt() . $this->url);
+ }
+ return $this->hash;
+ }
+
public function url () {
return $this->url;
}
@@ -96,7 +105,7 @@ class FreshRSS_Feed extends Minz_Model {
return $this->nbNotRead;
}
public function faviconPrepare() {
- $file = DATA_PATH . '/favicons/' . $this->id () . '.txt';
+ $file = DATA_PATH . '/favicons/' . $this->hash() . '.txt';
if (!file_exists ($file)) {
$t = $this->website;
if (empty($t)) {
@@ -105,13 +114,13 @@ class FreshRSS_Feed extends Minz_Model {
file_put_contents($file, $t);
}
}
- public static function faviconDelete($id) {
- $path = DATA_PATH . '/favicons/' . $id;
+ public static function faviconDelete($hash) {
+ $path = DATA_PATH . '/favicons/' . $hash;
@unlink($path . '.ico');
@unlink($path . '.txt');
}
public function favicon () {
- return Minz_Url::display ('/f.php?' . $this->id ());
+ return Minz_Url::display ('/f.php/' . $this->hash());
}
public function _id ($value) {
@@ -127,7 +136,8 @@ class FreshRSS_Feed extends Minz_Model {
$this->url = $value;
}
public function _category ($value) {
- $this->category = $value;
+ $value = intval($value);
+ $this->category = $value >= 0 ? $value : 0;
}
public function _name ($value) {
if (is_null ($value)) {
@@ -154,7 +164,8 @@ class FreshRSS_Feed extends Minz_Model {
$this->lastUpdate = $value;
}
public function _priority ($value) {
- $this->priority = ctype_digit ($value) ? intval ($value) : 10;
+ $value = intval($value);
+ $this->priority = $value >= 0 ? $value : 10;
}
public function _pathEntries ($value) {
$this->pathEntries = $value;
@@ -172,13 +183,13 @@ class FreshRSS_Feed extends Minz_Model {
$this->keep_history = $value;
}
public function _nbNotRead ($value) {
- $this->nbNotRead = ctype_digit ($value) ? intval ($value) : -1;
+ $this->nbNotRead = intval($value);
}
public function _nbEntries ($value) {
- $this->nbEntries = ctype_digit ($value) ? intval ($value) : -1;
+ $this->nbEntries = intval($value);
}
- public function load () {
+ public function load ($loadDetails = false) {
if (!is_null ($this->url)) {
if (CACHE_PATH === false) {
throw new Minz_FileNotExistException (
@@ -250,11 +261,13 @@ class FreshRSS_Feed extends Minz_Model {
$this->_url ($subscribe_url);
}
- $title = htmlspecialchars(html_only_entity_decode($feed->get_title()), ENT_COMPAT, 'UTF-8');
- $this->_name (!is_null ($title) ? $title : $this->url);
+ if ($loadDetails) {
+ $title = htmlspecialchars(html_only_entity_decode($feed->get_title()), ENT_COMPAT, 'UTF-8');
+ $this->_name (!is_null ($title) ? $title : $this->url);
- $this->_website(html_only_entity_decode($feed->get_link()));
- $this->_description(html_only_entity_decode($feed->get_description()));
+ $this->_website(html_only_entity_decode($feed->get_link()));
+ $this->_description(html_only_entity_decode($feed->get_description()));
+ }
// et on charge les articles du flux
$this->loadEntries ($feed);
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index d517f9580..e102da4ec 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -316,11 +316,13 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
$key = $dao['id'];
}
if ($catID === null) {
- $catID = isset($dao['category']) ? $dao['category'] : 0;
+ $category = isset($dao['category']) ? $dao['category'] : 0;
+ } else {
+ $category = $catID ;
}
$myFeed = new FreshRSS_Feed(isset($dao['url']) ? $dao['url'] : '', false);
- $myFeed->_category(intval($catID));
+ $myFeed->_category($category);
$myFeed->_name($dao['name']);
$myFeed->_website(isset($dao['website']) ? $dao['website'] : '', false);
$myFeed->_description(isset($dao['description']) ? $dao['description'] : '');
diff --git a/app/actualize_script.php b/app/actualize_script.php
new file mode 100755
index 000000000..20438128a
--- /dev/null
+++ b/app/actualize_script.php
@@ -0,0 +1,15 @@
+<?php
+require(dirname(__FILE__) . '/../constants.php');
+
+$_GET['c'] = 'feed';
+$_GET['a'] = 'actualize';
+$_GET['force'] = true;
+$_SERVER['HTTP_HOST'] = '';
+
+require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+
+$front_controller = new FreshRSS ();
+$front_controller->init ();
+Minz_Session::_param('mail', true); // permet de se passer de la phase de connexion
+$front_controller->run ();
+invalidateHttpCache();
diff --git a/app/i18n/en.php b/app/i18n/en.php
index 498fccd14..f74a7f198 100644
--- a/app/i18n/en.php
+++ b/app/i18n/en.php
@@ -60,7 +60,7 @@ return array (
'access_denied' => 'You don’t have permission to access this page',
'page_not_found' => 'You are looking for a page which doesn’t exist',
'error_occurred' => 'An error occurred',
- 'error_occurred_update' => 'An error occurred during update',
+ 'error_occurred_update' => 'Nothing was changed',
'default_category' => 'Uncategorized',
'categories_updated' => 'Categories have been updated',
@@ -239,6 +239,7 @@ return array (
'freshrss_description' => 'FreshRSS is a RSS feeds aggregator to self-host like <a href="http://tontof.net/kriss/feed/">Kriss Feed</a> or <a href="http://projet.idleman.fr/leed/">Leed</a>. It is light and easy to take in hand while being powerful and configurable tool.',
'credits' => 'Credits',
'credits_content' => 'Some design elements come from <a href="http://twitter.github.io/bootstrap/">Bootstrap</a> although FreshRSS doesn’t use this framework. <a href="https://git.gnome.org/browse/gnome-icon-theme-symbolic">Icons</a> come from <a href="https://www.gnome.org/">GNOME project</a>. <em>Open Sans</em> font police used has been created by <a href="https://www.google.com/webfonts/specimen/Open+Sans">Steve Matteson</a>. Favicons are collected with <a href="https://getfavicon.appspot.com/">getFavicon API</a>. FreshRSS is based on <a href="https://github.com/marienfressinaud/MINZ">Minz</a>, a PHP framework.',
+ 'version' => 'Version',
'logs' => 'Logs',
'logs_empty' => 'Log file is empty',
diff --git a/app/i18n/fr.php b/app/i18n/fr.php
index c918daa44..f9c4d00cc 100644
--- a/app/i18n/fr.php
+++ b/app/i18n/fr.php
@@ -60,7 +60,7 @@ return array (
'access_denied' => 'Vous n’avez pas le droit d’accéder à cette page',
'page_not_found' => 'La page que vous cherchez n’existe pas',
'error_occurred' => 'Une erreur est survenue',
- 'error_occurred_update' => 'Une erreur est survenue lors de la mise à jour',
+ 'error_occurred_update' => 'Rien n’a été modifié',
'default_category' => 'Sans catégorie',
'categories_updated' => 'Les catégories ont été mises à jour',
@@ -240,6 +240,7 @@ return array (
'freshrss_description' => 'FreshRSS est un agrégateur de flux RSS à auto-héberger à l’image de <a href="http://tontof.net/kriss/feed/">Kriss Feed</a> ou <a href="http://projet.idleman.fr/leed/">Leed</a>. Il se veut léger et facile à prendre en main tout en étant un outil puissant et paramétrable.',
'credits' => 'Crédits',
'credits_content' => 'Des éléments de design sont issus du <a href="http://twitter.github.io/bootstrap/">projet Bootstrap</a> bien que FreshRSS n’utilise pas ce framework. Les <a href="https://git.gnome.org/browse/gnome-icon-theme-symbolic">icônes</a> sont issues du <a href="https://www.gnome.org/">projet GNOME</a>. La police <em>Open Sans</em> utilisée a été créée par <a href="https://www.google.com/webfonts/specimen/Open+Sans">Steve Matteson</a>. Les favicons sont récupérés grâce au site <a href="https://getfavicon.appspot.com/">getFavicon</a>. FreshRSS repose sur <a href="https://github.com/marienfressinaud/MINZ">Minz</a>, un framework PHP.',
+ 'version' => 'Version',
'logs' => 'Logs',
'logs_empty' => 'Les logs sont vides',
diff --git a/app/index.html b/app/index.html
new file mode 100644
index 000000000..85faaa37e
--- /dev/null
+++ b/app/index.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+<meta charset="UTF-8" />
+<meta http-equiv="Refresh" content="0; url=/" />
+<title>Redirection</title>
+<meta name="robots" content="noindex" />
+</head>
+
+<body>
+<p><a href="/">Redirection</a></p>
+</body>
+</html>
diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml
index 045f391f9..1f2a7b408 100644
--- a/app/layout/nav_menu.phtml
+++ b/app/layout/nav_menu.phtml
@@ -25,7 +25,7 @@
switch ($get[0]) {
case 'c':
foreach ($this->cat_aside as $cat) {
- if ($cat->id () === $this->get_c) {
+ if ($cat->id () == $this->get_c) {
$foundCurrent = true;
continue;
}
@@ -37,9 +37,9 @@
break;
case 'f':
foreach ($this->cat_aside as $cat) {
- if ($cat->id () === $this->get_c) {
+ if ($cat->id () == $this->get_c) {
foreach ($cat->feeds () as $feed) {
- if ($feed->id () === $this->get_f) {
+ if ($feed->id () == $this->get_f) {
$foundCurrent = true;
continue;
}
diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml
index 0c1af45fc..d008e2e48 100644
--- a/app/views/helpers/javascript_vars.phtml
+++ b/app/views/helpers/javascript_vars.phtml
@@ -39,7 +39,8 @@
echo 'str_confirmation="', Minz_Translate::t('confirm_action'), '"', ",\n";
- echo 'auto_actualize_feeds=', Minz_Session::param('actualize_feeds', false) ? 'true' : 'false', ";\n";
- if (Minz_Session::param('actualize_feeds', false)) {
- Minz_Session::_param('actualize_feeds');
+ $autoActualise = Minz_Session::param('actualize_feeds', false);
+ echo 'auto_actualize_feeds=', $autoActualise ? 'true' : 'false', ";\n";
+ if ($autoActualise) {
+ Minz_Session::_param('actualize_feeds', false);
}
diff --git a/app/views/index/about.phtml b/app/views/index/about.phtml
index b5c00a1ed..ae64727d7 100644
--- a/app/views/index/about.phtml
+++ b/app/views/index/about.phtml
@@ -15,6 +15,9 @@
<dt><?php echo Minz_Translate::t ('license'); ?></dt>
<dd><?php echo Minz_Translate::t ('agpl3'); ?></dd>
+
+ <dt><?php echo Minz_Translate::t ('version'); ?></dt>
+ <dd><?php echo FRESHRSS_VERSION; ?></dd>
</dl>
<p><?php echo Minz_Translate::t ('freshrss_description'); ?></p>