From 4ee4f16ffe06e247d2cb79a2054ab5d5315d82b2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 15 Dec 2013 11:24:14 +0100 Subject: Problème de casse renommage répertoire MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Feed.php | 319 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 app/Models/Feed.php (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php new file mode 100644 index 000000000..e63ac8c7a --- /dev/null +++ b/app/Models/Feed.php @@ -0,0 +1,319 @@ +_url ($url); + } else { + $this->url = $url; + } + } + + public function id () { + return $this->id; + } + public function url () { + return $this->url; + } + public function category () { + return $this->category; + } + public function entries () { + if (!is_null ($this->entries)) { + return $this->entries; + } else { + return array (); + } + } + public function name () { + return $this->name; + } + public function website () { + return $this->website; + } + public function description () { + return $this->description; + } + public function lastUpdate () { + return $this->lastUpdate; + } + public function priority () { + return $this->priority; + } + public function pathEntries () { + return $this->pathEntries; + } + public function httpAuth ($raw = true) { + if ($raw) { + return $this->httpAuth; + } else { + $pos_colon = strpos ($this->httpAuth, ':'); + $user = substr ($this->httpAuth, 0, $pos_colon); + $pass = substr ($this->httpAuth, $pos_colon + 1); + + return array ( + 'username' => $user, + 'password' => $pass + ); + } + } + public function inError () { + return $this->error; + } + public function keepHistory () { + return $this->keep_history; + } + public function nbEntries () { + if ($this->nbEntries < 0) { + $feedDAO = new FreshRSS_FeedDAO (); + $this->nbEntries = $feedDAO->countEntries ($this->id ()); + } + + return $this->nbEntries; + } + public function nbNotRead () { + if ($this->nbNotRead < 0) { + $feedDAO = new FreshRSS_FeedDAO (); + $this->nbNotRead = $feedDAO->countNotRead ($this->id ()); + } + + return $this->nbNotRead; + } + public function faviconPrepare() { + $file = DATA_PATH . '/favicons/' . $this->id () . '.txt'; + if (!file_exists ($file)) { + $t = $this->website; + if (empty($t)) { + $t = $this->url; + } + file_put_contents($file, $t); + } + } + public static function faviconDelete($id) { + $path = DATA_PATH . '/favicons/' . $id; + @unlink($path . '.ico'); + @unlink($path . '.txt'); + } + public function favicon () { + return Minz_Url::display ('/f.php?' . $this->id ()); + } + + public function _id ($value) { + $this->id = $value; + } + public function _url ($value, $validate=true) { + if ($validate) { + $value = checkUrl($value); + } + if (empty ($value)) { + throw new FreshRSS_BadUrl_Exception ($value); + } + $this->url = $value; + } + public function _category ($value) { + $this->category = $value; + } + public function _name ($value) { + if (is_null ($value)) { + $value = ''; + } + $this->name = $value; + } + public function _website ($value, $validate=true) { + if ($validate) { + $value = checkUrl($value); + } + if (empty ($value)) { + $value = ''; + } + $this->website = $value; + } + public function _description ($value) { + if (is_null ($value)) { + $value = ''; + } + $this->description = $value; + } + public function _lastUpdate ($value) { + $this->lastUpdate = $value; + } + public function _priority ($value) { + $this->priority = ctype_digit ($value) ? intval ($value) : 10; + } + public function _pathEntries ($value) { + $this->pathEntries = $value; + } + public function _httpAuth ($value) { + $this->httpAuth = $value; + } + public function _error ($value) { + if ($value) { + $value = true; + } else { + $value = false; + } + $this->error = $value; + } + public function _keepHistory ($value) { + if ($value) { + $value = true; + } else { + $value = false; + } + $this->keep_history = $value; + } + public function _nbNotRead ($value) { + $this->nbNotRead = ctype_digit ($value) ? intval ($value) : -1; + } + public function _nbEntries ($value) { + $this->nbEntries = ctype_digit ($value) ? intval ($value) : -1; + } + + public function load () { + if (!is_null ($this->url)) { + if (CACHE_PATH === false) { + throw new Minz_FileNotExistException ( + 'CACHE_PATH', + Minz_Exception::ERROR + ); + } else { + $feed = new SimplePie (); + $feed->set_useragent(Minz_Translate::t ('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); + $url = htmlspecialchars_decode ($this->url, ENT_QUOTES); + if ($this->httpAuth != '') { + $url = preg_replace ('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url); + } + + $feed->set_feed_url ($url); + $feed->set_cache_location (CACHE_PATH); + $feed->set_cache_duration(1500); + $feed->strip_htmltags (array ( + 'base', 'blink', 'body', 'doctype', 'embed', + 'font', 'form', 'frame', 'frameset', 'html', + 'input', 'marquee', 'meta', 'noscript', + 'object', 'param', 'plaintext', 'script', 'style', + )); + $feed->strip_attributes(array_merge($feed->strip_attributes, array( + 'autoplay', 'onload', 'onunload', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', + 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', + 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless'))); + $feed->add_attributes(array( + 'img' => array('lazyload' => ''), //http://www.w3.org/TR/resource-priorities/ + 'audio' => array('preload' => 'none'), + 'iframe' => array('postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), + 'video' => array('postpone' => '', 'preload' => 'none'), + )); + $feed->set_url_replacements(array( + 'a' => 'href', + 'area' => 'href', + 'audio' => 'src', + 'blockquote' => 'cite', + 'del' => 'cite', + 'form' => 'action', + 'iframe' => 'src', + 'img' => array( + 'longdesc', + 'src' + ), + 'input' => 'src', + 'ins' => 'cite', + 'q' => 'cite', + 'source' => 'src', + 'track' => 'src', + 'video' => array( + 'poster', + 'src', + ), + )); + $feed->init (); + + if ($feed->error ()) { + throw new FreshRSS_Feed_Exception ($feed->error . ' [' . $url . ']'); + } + + // si on a utilisé l'auto-discover, notre url va avoir changé + $subscribe_url = $feed->subscribe_url (); + if (!is_null ($subscribe_url) && $subscribe_url != $this->url) { + if ($this->httpAuth != '') { + // on enlève les id si authentification HTTP + $subscribe_url = preg_replace ('#((.+)://)((.+)@)(.+)#', '${1}${5}', $subscribe_url); + } + $this->_url ($subscribe_url); + } + + $title = $feed->get_title (); + $this->_name (!is_null ($title) ? $title : $this->url); + + $this->_website ($feed->get_link ()); + $this->_description ($feed->get_description ()); + + // et on charge les articles du flux + $this->loadEntries ($feed); + } + } + } + private function loadEntries ($feed) { + $entries = array (); + + foreach ($feed->get_items () as $item) { + $title = html_only_entity_decode (strip_tags ($item->get_title ())); + $author = $item->get_author (); + $link = $item->get_permalink (); + $date = @strtotime ($item->get_date ()); + + // gestion des tags (catégorie == tag) + $tags_tmp = $item->get_categories (); + $tags = array (); + if (!is_null ($tags_tmp)) { + foreach ($tags_tmp as $tag) { + $tags[] = html_only_entity_decode ($tag->get_label ()); + } + } + + $content = html_only_entity_decode ($item->get_content ()); + + $elinks = array(); + foreach ($item->get_enclosures() as $enclosure) { + $elink = $enclosure->get_link(); + if (array_key_exists($elink, $elinks)) continue; + $elinks[$elink] = '1'; + $mime = strtolower($enclosure->get_type()); + if (strpos($mime, 'image/') === 0) { + $content .= '
'; + } + } + + $entry = new FreshRSS_Entry ( + $this->id (), + $item->get_id (), + !is_null ($title) ? $title : '', + !is_null ($author) ? html_only_entity_decode ($author->name) : '', + !is_null ($content) ? $content : '', + !is_null ($link) ? $link : '', + $date ? $date : time () + ); + $entry->_tags ($tags); + // permet de récupérer le contenu des flux tronqués + $entry->loadCompleteContent($this->pathEntries()); + + $entries[] = $entry; + } + + $this->entries = $entries; + } +} -- cgit v1.2.3 From 7b7acf5c8738e949109672748dbd9f39a6e5a2c4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 23 Dec 2013 13:35:54 +0100 Subject: Synchronisation quelques lignes blanches --- README.md | 4 ++-- app/Models/CategoryDAO.php | 1 + app/Models/Configuration.php | 1 + app/Models/ConfigurationDAO.php | 1 + app/Models/Entry.php | 1 + app/Models/EntryDAO.php | 1 + app/Models/Feed.php | 1 + app/Models/FeedDAO.php | 1 + app/Models/LogDAO.php | 1 + public/install.php | 1 + 10 files changed, 11 insertions(+), 2 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/README.md b/README.md index a45c8e67c..87ed9de99 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Il se veut léger et facile à prendre en main tout en étant un outil puissant * Site officiel : http://marienfressinaud.github.io/FreshRSS/ * Démo : http://marienfressinaud.fr/projets/freshrss/ * Développeur : Marien Fressinaud -* Version actuelle : 0.7-dev -* Date de publication 2013-12-xx +* Version actuelle : 0.7-beta +* Date de publication 2014-01-xx * License [GNU AGPL 3](http://www.gnu.org/licenses/agpl-3.0.html) ![Logo de FreshRSS](http://marienfressinaud.fr/data/images/freshrss/freshrss_title.png) diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index 3a810e9f0..6b07ab063 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -1,4 +1,5 @@ prefix . 'category` (name, color) VALUES(?, ?)'; diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 7ef76b522..d5f69601f 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -1,4 +1,5 @@ 'English', diff --git a/app/Models/ConfigurationDAO.php b/app/Models/ConfigurationDAO.php index 57fc98047..0eebf2d90 100644 --- a/app/Models/ConfigurationDAO.php +++ b/app/Models/ConfigurationDAO.php @@ -1,4 +1,5 @@ prefix . 'entry`(id, guid, title, author, content_bin, link, date, is_read, is_favorite, id_feed, tags) ' diff --git a/app/Models/Feed.php b/app/Models/Feed.php index e63ac8c7a..70efb0fa3 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -1,4 +1,5 @@ prefix . 'feed` (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, 0)'; diff --git a/app/Models/LogDAO.php b/app/Models/LogDAO.php index bf043fd6d..06855ec66 100644 --- a/app/Models/LogDAO.php +++ b/app/Models/LogDAO.php @@ -1,4 +1,5 @@ Date: Tue, 24 Dec 2013 01:21:11 +0100 Subject: Permet de configurer plus finement le nombre d’articles minimum à conserver par flux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 1 + app/Controllers/feedController.php | 20 ++++++++------------ app/Models/EntryDAO.php | 2 +- app/Models/Feed.php | 17 +++++------------ app/Models/FeedDAO.php | 4 ++-- app/i18n/en.php | 7 +++++-- app/i18n/fr.php | 8 ++++++-- app/views/configure/display.phtml | 29 +++++++++++++++++++++-------- app/views/configure/feed.phtml | 22 ++++++++++++++++++---- public/install.php | 2 +- 10 files changed, 68 insertions(+), 44 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/CHANGELOG b/CHANGELOG index af6936204..0c816dbd7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ * Améliorations partage vers Shaarli, Poche, Diaspora*, Facebook, Twitter, Google+, courriel * Permet la suppression de tous les articles d’un flux * Option pour marquer les articles comme lus dès la réception + * Permet de configurer plus finement le nombre d’articles minimum à conserver par flux * Permet de modifier la description et l’adresse d’un flux RSS ainsi que le site Web associé * Nouveau raccourci pour ouvrir/fermer un article (‘c’ par défaut) * Bouton pour effacer les logs diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 27b76dd42..e7d9c97c3 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -102,14 +102,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->beginTransaction (); // on ajoute les articles en masse sans vérification foreach ($entries as $entry) { - if ($entry->date (true) >= $date_min || - $feed->keepHistory ()) { - $values = $entry->toArray (); - $values['id_feed'] = $feed->id (); - $values['id'] = min(time(), $entry->date (true)) . uSecString(); - $values['is_read'] = $is_read; - $entryDAO->addEntry ($values); - } + $values = $entry->toArray (); + $values['id_feed'] = $feed->id (); + $values['id'] = min(time(), $entry->date (true)) . uSecString(); + $values['is_read'] = $is_read; + $entryDAO->addEntry ($values); } $feedDAO->updateLastUpdate ($feed->id ()); $feedDAO->commit (); @@ -217,8 +214,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->beginTransaction (); foreach ($entries as $entry) { if ((!isset ($existingGuids[$entry->guid ()])) && - ($entry->date (true) >= $date_min || - $feed->keepHistory ())) { + ($entry->date (true) >= $date_min)) { $values = $entry->toArray (); //Use declared date at first import, otherwise use discovery date $values['id'] = empty($existingGuids) ? min(time(), $entry->date (true)) . uSecString() : uTimeString(); @@ -227,8 +223,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } - if ((!$feed->keepHistory()) && (rand(0, 30) === 1)) { - $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, count($entries) + 10); + if (($feed->keepHistory() >= 0) && (rand(0, 30) === 1)) { + $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, max($feed->keepHistory(), count($entries) + 10)); if ($nb > 0) { Minz_Log::record ($nb . ' old entries cleaned in feed ' . $feed->id (), Minz_Log::DEBUG); } diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index c6bd5c404..f0207e96d 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -307,7 +307,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $where .= 'AND e1.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' '; } if (($date_min > 0) && ($type !== 's')) { - $where .= 'AND (e1.id >= ' . $date_min . '000000 OR e1.is_favorite = 1 OR f.keep_history = 1) '; + $where .= 'AND (e1.id >= ' . $date_min . '000000 OR e1.is_favorite = 1 OR f.keep_history <> 0) '; $joinFeed = true; } $search = ''; diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 70efb0fa3..5bdf5e6d7 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -15,7 +15,7 @@ class FreshRSS_Feed extends Minz_Model { private $pathEntries = ''; private $httpAuth = ''; private $error = false; - private $keep_history = false; + private $keep_history = 0; public function __construct ($url, $validate=true) { if ($validate) { @@ -163,19 +163,12 @@ class FreshRSS_Feed extends Minz_Model { $this->httpAuth = $value; } public function _error ($value) { - if ($value) { - $value = true; - } else { - $value = false; - } - $this->error = $value; + $this->error = (bool)$value; } public function _keepHistory ($value) { - if ($value) { - $value = true; - } else { - $value = false; - } + $value = intval($value); + $value = min($value, 1000000); + $value = max($value, -1); $this->keep_history = $value; } public function _nbNotRead ($value) { diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 9bd480544..451fc3850 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -193,7 +193,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { } public function listFeedsOrderUpdate () { - $sql = 'SELECT * FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; + $sql = 'SELECT id, url, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; $stm = $this->bd->prepare ($sql); $stm->execute (); @@ -326,7 +326,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { $myFeed->_pathEntries (isset($dao['pathEntries']) ? $dao['pathEntries'] : ''); $myFeed->_httpAuth (isset($dao['httpAuth']) ? base64_decode ($dao['httpAuth']) : ''); $myFeed->_error ($dao['error']); - $myFeed->_keepHistory (isset($dao['keep_history']) ? $dao['keep_history'] : ''); + $myFeed->_keepHistory (isset($dao['keep_history']) ? $dao['keep_history'] : 0); $myFeed->_nbNotRead ($dao['cache_nbUnreads']); $myFeed->_nbEntries ($dao['cache_nbEntries']); if (isset ($dao['id'])) { diff --git a/app/i18n/en.php b/app/i18n/en.php index 9c30573e8..b6417d8db 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -137,7 +137,8 @@ return array ( 'feed_url' => 'Feed URL', 'articles' => 'articles', 'number_articles' => 'Number of articles', - 'keep_history' => 'Keep old articles?', + 'keep_history' => 'Minimum number of articles to keep', + 'keep_history_help' => 'Set to -1 to keep everything', 'categorize' => 'Store in a category', 'truncate' => 'Delete all articles', 'advanced' => 'Advanced', @@ -157,13 +158,15 @@ return array ( 'general_configuration' => 'General configuration', 'language' => 'Language', - 'delete_articles_every' => 'Remove articles after', 'month' => 'months', 'default_user' => 'Username of the default user (maximum 16 alphanumeric characters)', 'persona_connection_email' => 'Login mail address (use Mozilla Persona)', 'allow_anonymous' => 'Allow anonymous reading', 'auth_token' => 'Authentication token', 'explain_token' => 'Allows to access RSS output without authentication.
%s?token=%s', + 'archiving_configuration' => 'Archiving configuration', + 'delete_articles_every' => 'Remove articles after', + 'archiving_configuration_help' => 'More options are available in the individual stream settings', 'reading_configuration' => 'Reading configuration', 'articles_per_page' => 'Number of articles per page', 'default_view' => 'Default view', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 85bbeb4b7..b27f29940 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -137,7 +137,8 @@ return array ( 'feed_url' => 'URL du flux', 'articles' => 'articles', 'number_articles' => 'Nombre d’articles', - 'keep_history' => 'Garder les vieux articles ?', + 'keep_history' => 'Nombre minimum d’articles à conserver', + 'keep_history_help' => 'Mettre à -1 pour tout conserver', 'categorize' => 'Ranger dans une catégorie', 'truncate' => 'Supprimer tous les articles', 'advanced' => 'Avancé', @@ -157,13 +158,16 @@ return array ( 'general_configuration' => 'Configuration générale', 'language' => 'Langue', - 'delete_articles_every' => 'Supprimer les articles après', + 'month' => 'mois', 'default_user' => 'Nom de l’utilisateur par défaut (16 caractères alphanumériques maximum)', 'persona_connection_email' => 'Adresse courriel de connexion (utilise Mozilla Persona)', 'allow_anonymous' => 'Autoriser la lecture anonyme', 'auth_token' => 'Jeton d’identification', 'explain_token' => 'Permet d’accéder à la sortie RSS sans besoin de s’authentifier.
%s?output=rss&token=%s', + 'archiving_configuration' => 'Configuration de l’archivage', + 'delete_articles_every' => 'Supprimer les articles après', + 'archiving_configuration_help' => 'D’autres options sont disponibles dans la configuration individuelle des flux', 'reading_configuration' => 'Configuration de lecture', 'articles_per_page' => 'Nombre d’articles par page', 'default_view' => 'Vue par défaut', diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index ad35d7c71..68ef26bbf 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -31,13 +31,6 @@ -
- -
- -
-
-
conf->mailLogin (); ?> @@ -59,7 +52,27 @@
- + + + +
+ +
+ + + + + + + + + + +
+ +
+
+
diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 4504b8d76..3fe7d1b3a 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -52,6 +52,9 @@
+ + +
@@ -64,10 +67,21 @@
flux->nbEntries (); ?> - +
+
+
+ +
+ + + + + + + + + +
diff --git a/public/install.php b/public/install.php index afef7e473..3885f143e 100644 --- a/public/install.php +++ b/public/install.php @@ -93,7 +93,7 @@ FROM `%1$scategory006` ORDER BY id2; INSERT IGNORE INTO `%2$sfeed` (url, category, name, website, description, priority, pathEntries, httpAuth, keep_history) -SELECT url, category2, name, website, description, priority, pathEntries, httpAuth, keep_history +SELECT url, category2, name, website, description, priority, pathEntries, httpAuth, -1 * keep_history FROM `%1$sfeed006` ORDER BY id2; -- cgit v1.2.3 From 06d4b8d10247146d9c6f7c78ff9fc584438dd8fe Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 25 Dec 2013 17:37:52 +0100 Subject: Option globale pour la taille minimale de l'historique par défaut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plus une réorganisation des options --- app/Controllers/configureController.php | 5 ++- app/Controllers/feedController.php | 9 +++-- app/Controllers/indexController.php | 5 +-- app/Models/Configuration.php | 14 +++++++- app/Models/ConfigurationDAO.php | 8 +++-- app/Models/EntryDAO.php | 8 +++-- app/Models/Feed.php | 4 +-- app/Models/FeedDAO.php | 4 +-- app/i18n/en.php | 8 +++-- app/i18n/fr.php | 8 +++-- app/views/configure/display.phtml | 35 ++++++++++++------- app/views/configure/feed.phtml | 62 ++++++++++++++++++--------------- public/install.php | 4 +-- public/themes/default/freshrss.css | 4 +++ public/themes/default/global.css | 3 ++ public/themes/flat-design/freshrss.css | 4 +++ public/themes/flat-design/global.css | 3 ++ 17 files changed, 124 insertions(+), 64 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index b83501f0b..762134dd0 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -97,7 +97,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $description = sanitizeHTML(Minz_Request::param('description', '', true)); $website = Minz_Request::param('website', ''); $url = Minz_Request::param('url', ''); - $keep_history = intval(Minz_Request::param ('keep_history', 0)); + $keep_history = intval(Minz_Request::param ('keep_history', -2)); $cat = Minz_Request::param ('category', 0); $path = Minz_Request::param ('path_entries', ''); $priority = Minz_Request::param ('priority', 0); @@ -160,6 +160,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $lazyload = Minz_Request::param ('lazyload', 'no'); $sort = Minz_Request::param ('sort_order', 'DESC'); $old = Minz_Request::param ('old_entries', 3); + $keepHistoryDefault = Minz_Request::param('keep_history_default', 0); $mail = Minz_Request::param ('mail_login', false); $anon = Minz_Request::param ('anon_access', 'no'); $token = Minz_Request::param ('token', $current_token); @@ -189,6 +190,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $this->view->conf->_lazyload ($lazyload); $this->view->conf->_sortOrder ($sort); $this->view->conf->_oldEntries ($old); + $this->view->conf->_keepHistoryDefault($keepHistoryDefault); $this->view->conf->_mailLogin ($mail); $this->view->conf->_anonAccess ($anon); $this->view->conf->_token ($token); @@ -221,6 +223,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { 'lazyload' => $this->view->conf->lazyload (), 'sort_order' => $this->view->conf->sortOrder (), 'old_entries' => $this->view->conf->oldEntries (), + 'keep_history_default' => $this->view->conf->keepHistoryDefault(), 'mail_login' => $this->view->conf->mailLogin (), 'anon_access' => $this->view->conf->anonAccess (), 'token' => $this->view->conf->token (), diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index e7d9c97c3..836044da6 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -223,8 +223,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } - if (($feed->keepHistory() >= 0) && (rand(0, 30) === 1)) { - $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, max($feed->keepHistory(), count($entries) + 10)); + $feedHistory = $feed->keepHistory(); + if ($feedHistory == -2) { //default + $feedHistory = $this->view->conf->keepHistoryDefault(); + } + + 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); } diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index e3c253518..6c0ba9058 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -130,16 +130,17 @@ class FreshRSS_index_Controller extends Minz_ActionController { // on calcule la date des articles les plus anciens qu'on affiche $nb_month_old = $this->view->conf->oldEntries (); $date_min = $today - (3600 * 24 * 30 * $nb_month_old); //Do not use a fast changing value such as time() to allow SQL caching + $keepHistoryDefault = $this->view->conf->keepHistoryDefault(); try { - $entries = $this->entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter, $date_min); + $entries = $this->entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter, $date_min, $keepHistoryDefault); // Si on a récupéré aucun article "non lus" // on essaye de récupérer tous les articles if ($state === 'not_read' && empty($entries)) { //TODO: Remove in v0.8 Minz_Log::record ('Conflicting information about nbNotRead!', Minz_Log::DEBUG); $this->view->state = 'all'; - $entries = $this->entryDAO->listWhere($getType, $getId, 'all', $order, $nb, $first, $filter, $date_min); + $entries = $this->entryDAO->listWhere($getType, $getId, 'all', $order, $nb, $first, $filter, $date_min, $keepHistoryDefault); } if (count($entries) <= $nb) { diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index d5f69601f..47509636f 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -14,6 +14,7 @@ class FreshRSS_Configuration extends Minz_Model { private $lazyload; private $sort_order; private $old_entries; + private $keep_history_default; private $shortcuts = array (); private $mail_login = ''; private $mark_when = array (); @@ -44,6 +45,7 @@ class FreshRSS_Configuration extends Minz_Model { $this->_lazyload ($confDAO->lazyload); $this->_sortOrder ($confDAO->sort_order); $this->_oldEntries ($confDAO->old_entries); + $this->_keepHistoryDefault($confDAO->keep_history_default); $this->_shortcuts ($confDAO->shortcuts); $this->_mailLogin ($confDAO->mail_login); $this->_markWhen ($confDAO->mark_when); @@ -95,6 +97,9 @@ class FreshRSS_Configuration extends Minz_Model { public function oldEntries () { return $this->old_entries; } + public function keepHistoryDefault() { + return $this->keep_history_default; + } public function shortcuts () { return $this->shortcuts; } @@ -217,11 +222,18 @@ class FreshRSS_Configuration extends Minz_Model { } public function _oldEntries ($value) { if (ctype_digit ($value) && $value > 0) { - $this->old_entries = $value; + $this->old_entries = intval($value); } else { $this->old_entries = 3; } } + public function _keepHistoryDefault($value) { + if (ctype_digit($value) && $value >= -1) { + $this->keep_history_default = intval($value); + } else { + $this->keep_history_default = 0; + } + } public function _shortcuts ($values) { foreach ($values as $key => $value) { $this->shortcuts[$key] = $value; diff --git a/app/Models/ConfigurationDAO.php b/app/Models/ConfigurationDAO.php index 0eebf2d90..91210e701 100644 --- a/app/Models/ConfigurationDAO.php +++ b/app/Models/ConfigurationDAO.php @@ -10,6 +10,7 @@ class FreshRSS_ConfigurationDAO extends Minz_ModelArray { public $lazyload = 'yes'; public $sort_order = 'DESC'; public $old_entries = 3; + public $keep_history_default = 0; public $shortcuts = array ( 'mark_read' => 'r', 'mark_favorite' => 'f', @@ -62,7 +63,7 @@ class FreshRSS_ConfigurationDAO extends Minz_ModelArray { $this->language = $this->array['language']; } if (isset ($this->array['posts_per_page'])) { - $this->posts_per_page = $this->array['posts_per_page']; + $this->posts_per_page = intval($this->array['posts_per_page']); } if (isset ($this->array['view_mode'])) { $this->view_mode = $this->array['view_mode']; @@ -83,7 +84,10 @@ class FreshRSS_ConfigurationDAO extends Minz_ModelArray { $this->sort_order = $this->array['sort_order']; } if (isset ($this->array['old_entries'])) { - $this->old_entries = $this->array['old_entries']; + $this->old_entries = intval($this->array['old_entries']); + } + if (isset ($this->array['keep_history_default'])) { + $this->keep_history_default = intval($this->array['keep_history_default']); } if (isset ($this->array['shortcuts'])) { $this->shortcuts = array_merge ( diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index f0207e96d..14d3ddcff 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -260,7 +260,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { return isset ($entries[0]) ? $entries[0] : false; } - public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { + public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $keepHistoryDefault = 0) { $where = ''; $joinFeed = false; $values = array(); @@ -307,7 +307,11 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $where .= 'AND e1.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' '; } if (($date_min > 0) && ($type !== 's')) { - $where .= 'AND (e1.id >= ' . $date_min . '000000 OR e1.is_favorite = 1 OR f.keep_history <> 0) '; + $where .= 'AND (e1.id >= ' . $date_min . '000000 OR e1.is_favorite = 1 OR (f.keep_history <> 0'; + if (intval($keepHistoryDefault) === 0) { + $where .= ' AND f.keep_history <> -2'; //default + } + $where .= ')) '; $joinFeed = true; } $search = ''; diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 5bdf5e6d7..ef554e083 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -15,7 +15,7 @@ class FreshRSS_Feed extends Minz_Model { private $pathEntries = ''; private $httpAuth = ''; private $error = false; - private $keep_history = 0; + private $keep_history = -2; public function __construct ($url, $validate=true) { if ($validate) { @@ -168,7 +168,7 @@ class FreshRSS_Feed extends Minz_Model { public function _keepHistory ($value) { $value = intval($value); $value = min($value, 1000000); - $value = max($value, -1); + $value = max($value, -2); $this->keep_history = $value; } public function _nbNotRead ($value) { diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 7d91a032a..c1d1f24e8 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -2,7 +2,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { public function addFeed ($valuesTmp) { - $sql = 'INSERT INTO `' . $this->prefix . 'feed` (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, 0)'; + $sql = 'INSERT INTO `' . $this->prefix . 'feed` (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, -2)'; $stm = $this->bd->prepare ($sql); $values = array ( @@ -326,7 +326,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { $myFeed->_pathEntries (isset($dao['pathEntries']) ? $dao['pathEntries'] : ''); $myFeed->_httpAuth (isset($dao['httpAuth']) ? base64_decode ($dao['httpAuth']) : ''); $myFeed->_error ($dao['error']); - $myFeed->_keepHistory (isset($dao['keep_history']) ? $dao['keep_history'] : 0); + $myFeed->_keepHistory(isset($dao['keep_history']) ? $dao['keep_history'] : -2); $myFeed->_nbNotRead ($dao['cache_nbUnreads']); $myFeed->_nbEntries ($dao['cache_nbEntries']); if (isset ($dao['id'])) { diff --git a/app/i18n/en.php b/app/i18n/en.php index b6417d8db..ca72d885c 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -137,8 +137,9 @@ return array ( 'feed_url' => 'Feed URL', 'articles' => 'articles', 'number_articles' => 'Number of articles', + 'by_feed' => 'by feed', + 'by_default' => 'By default', 'keep_history' => 'Minimum number of articles to keep', - 'keep_history_help' => 'Set to -1 to keep everything', 'categorize' => 'Store in a category', 'truncate' => 'Delete all articles', 'advanced' => 'Advanced', @@ -164,10 +165,11 @@ return array ( 'allow_anonymous' => 'Allow anonymous reading', 'auth_token' => 'Authentication token', 'explain_token' => 'Allows to access RSS output without authentication.
%s?token=%s', - 'archiving_configuration' => 'Archiving configuration', + 'login_configuration' => 'Login', + 'archiving_configuration' => 'Archiving', 'delete_articles_every' => 'Remove articles after', 'archiving_configuration_help' => 'More options are available in the individual stream settings', - 'reading_configuration' => 'Reading configuration', + 'reading_configuration' => 'Reading', 'articles_per_page' => 'Number of articles per page', 'default_view' => 'Default view', 'sort_order' => 'Sort order', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index b27f29940..053a97c8a 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -137,8 +137,9 @@ return array ( 'feed_url' => 'URL du flux', 'articles' => 'articles', 'number_articles' => 'Nombre d’articles', + 'by_feed' => 'par flux', + 'by_default' => 'Par défaut', 'keep_history' => 'Nombre minimum d’articles à conserver', - 'keep_history_help' => 'Mettre à -1 pour tout conserver', 'categorize' => 'Ranger dans une catégorie', 'truncate' => 'Supprimer tous les articles', 'advanced' => 'Avancé', @@ -165,10 +166,11 @@ return array ( 'allow_anonymous' => 'Autoriser la lecture anonyme', 'auth_token' => 'Jeton d’identification', 'explain_token' => 'Permet d’accéder à la sortie RSS sans besoin de s’authentifier.
%s?output=rss&token=%s', - 'archiving_configuration' => 'Configuration de l’archivage', + 'login_configuration' => 'Identification', + 'archiving_configuration' => 'Archivage', 'delete_articles_every' => 'Supprimer les articles après', 'archiving_configuration_help' => 'D’autres options sont disponibles dans la configuration individuelle des flux', - 'reading_configuration' => 'Configuration de lecture', + 'reading_configuration' => 'Lecture', 'articles_per_page' => 'Nombre d’articles par page', 'default_view' => 'Vue par défaut', 'sort_order' => 'Ordre de tri', diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 8995dc839..3280f657f 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -31,6 +31,15 @@
+
+
+ + +
+
+ + +
conf->mailLogin (); ?> @@ -61,22 +70,22 @@
- +

+
- - - - - - - - - - -
- + +
+
+
+ +
+
diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 5940055ed..e738ab64f 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -52,6 +52,15 @@ +
+ +
+ +
+
@@ -78,16 +87,11 @@
- - - - - - - - - - +
@@ -97,24 +101,7 @@
- -
- -
- -
-
-
- -
- - -
-
- + flux->httpAuth (false); ?>
@@ -131,7 +118,24 @@
- + + +
+
+ + +
+ +
+ + +
+
+ +
+
+ +
diff --git a/public/install.php b/public/install.php index 3885f143e..13abb010b 100644 --- a/public/install.php +++ b/public/install.php @@ -33,7 +33,7 @@ define ('SQL_FEED', 'CREATE TABLE IF NOT EXISTS `%1$sfeed` ( `pathEntries` varchar(511) DEFAULT NULL, `httpAuth` varchar(511) DEFAULT NULL, `error` boolean DEFAULT 0, - `keep_history` MEDIUMINT NOT NULL DEFAULT 0, + `keep_history` MEDIUMINT NOT NULL DEFAULT -2, -- v0.7, -2 = default `cache_nbEntries` int DEFAULT 0, -- v0.7 `cache_nbUnreads` int DEFAULT 0, -- v0.7 PRIMARY KEY (`id`), @@ -93,7 +93,7 @@ FROM `%1$scategory006` ORDER BY id2; INSERT IGNORE INTO `%2$sfeed` (url, category, name, website, description, priority, pathEntries, httpAuth, keep_history) -SELECT url, category2, name, website, description, priority, pathEntries, httpAuth, -1 * keep_history +SELECT url, category2, name, website, description, priority, pathEntries, httpAuth, IF(keep_history = 1, -1, -2) FROM `%1$sfeed006` ORDER BY id2; diff --git a/public/themes/default/freshrss.css b/public/themes/default/freshrss.css index e3c4c3c3b..2b157b27a 100644 --- a/public/themes/default/freshrss.css +++ b/public/themes/default/freshrss.css @@ -667,6 +667,10 @@ padding:.5em; } +select.number option { + text-align:right; +} + @media(max-width: 840px) { .header, .aside .btn-important, diff --git a/public/themes/default/global.css b/public/themes/default/global.css index 1c554d2dc..440fc6e41 100644 --- a/public/themes/default/global.css +++ b/public/themes/default/global.css @@ -99,6 +99,9 @@ input, select, textarea { vertical-align: middle; box-shadow: 0 2px 2px #eee inset; } + option { + padding:0 .5em 0 .5em; + } input[type="radio"], input[type="checkbox"] { width: 15px !important; diff --git a/public/themes/flat-design/freshrss.css b/public/themes/flat-design/freshrss.css index fa1ed13e6..7e3f4c81a 100644 --- a/public/themes/flat-design/freshrss.css +++ b/public/themes/flat-design/freshrss.css @@ -662,6 +662,10 @@ body { padding:.5em; } +select.number option { + text-align:right; +} + @media(max-width: 840px) { .header, .aside .btn-important, diff --git a/public/themes/flat-design/global.css b/public/themes/flat-design/global.css index 8cf6412b3..90b59d002 100644 --- a/public/themes/flat-design/global.css +++ b/public/themes/flat-design/global.css @@ -101,6 +101,9 @@ input, select, textarea { vertical-align: middle; border-radius: 5px; } + option { + padding:0 .5em 0 .5em; + } input[type="radio"], input[type="checkbox"] { width: 15px !important; -- cgit v1.2.3 From 0b3d79745d7b8db5dc684f91e0bbad6c1a03d0ee Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 25 Dec 2013 18:50:05 +0100 Subject: Encodage titre flux pour cas Glazman --- app/Models/Feed.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index ef554e083..dcf97d4ec 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -250,11 +250,11 @@ class FreshRSS_Feed extends Minz_Model { $this->_url ($subscribe_url); } - $title = $feed->get_title (); + $title = htmlspecialchars(html_only_entity_decode($feed->get_title()), ENT_COMPAT, 'UTF-8'); $this->_name (!is_null ($title) ? $title : $this->url); - $this->_website ($feed->get_link ()); - $this->_description ($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); -- cgit v1.2.3 From 2788aaeb1a463012cfa90bf31f5efb4bf6ca7344 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 26 Dec 2013 02:50:58 +0100 Subject: Problème ctype_digit qui ne marche pas sur des variables qui sont déjà des entiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Configuration.php | 16 +++++----------- app/Models/Entry.php | 7 ++----- app/Models/Feed.php | 7 ++++--- 3 files changed, 11 insertions(+), 19 deletions(-) (limited to 'app/Models/Feed.php') 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..3008e33d7 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -154,7 +154,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,10 +173,10 @@ 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 () { -- cgit v1.2.3 From 574d37bddc4e00ddbc6af57c28838e1dea6a730b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 26 Dec 2013 19:58:17 +0100 Subject: Favicons compatibles multi-utilisateurs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126 --- app/Controllers/feedController.php | 2 +- app/Models/CategoryDAO.php | 2 +- app/Models/Feed.php | 13 +++++++++---- lib/Minz/Configuration.php | 2 +- p/f.php | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 04d0aa98b..dc8a854a9 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -395,7 +395,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/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/Feed.php b/app/Models/Feed.php index 3008e33d7..f9a586122 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -28,6 +28,11 @@ class FreshRSS_Feed extends Minz_Model { public function id () { return $this->id; } + + public function hash() { + return hash('crc32b', Minz_Configuration::salt() . $this->url); + } + public function url () { return $this->url; } @@ -96,7 +101,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 +110,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) { diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 1b108dcdf..6c7206988 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -63,7 +63,7 @@ class Minz_Configuration { /* * Getteurs */ - public static function selApplication () { + public static function salt () { return self::$sel_application; } public static function environment () { diff --git a/p/f.php b/p/f.php index a56d58617..872b8cc2c 100644 --- a/p/f.php +++ b/p/f.php @@ -37,7 +37,7 @@ function download_favicon ($website, $dest) { } $id = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '0'; -if (!ctype_digit($id)) { +if (!ctype_xdigit($id)) { $id = '0'; } -- cgit v1.2.3 From 2c57e7254d613683ec20076d37b33ea2a7dd2d83 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 26 Dec 2013 20:11:18 +0100 Subject: Favicons : test pour améliorer le cache HTTP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test d'utilisation de PATH_INFO plutôt que QUERY_STRING pour améliorer la mise en cache. À tester sur différents serveurs --- app/Models/Feed.php | 2 +- p/f.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index f9a586122..4f90b9872 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -116,7 +116,7 @@ class FreshRSS_Feed extends Minz_Model { @unlink($path . '.txt'); } public function favicon () { - return Minz_Url::display ('/f.php?' . $this->hash()); + return Minz_Url::display ('/f.php/' . $this->hash()); } public function _id ($value) { diff --git a/p/f.php b/p/f.php index 872b8cc2c..660128a59 100644 --- a/p/f.php +++ b/p/f.php @@ -36,7 +36,14 @@ function download_favicon ($website, $dest) { return true; } -$id = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '0'; +if (isset($_SERVER['PATH_INFO'])) { + $id = substr($_SERVER['PATH_INFO'], 1); +} elseif (isset($_SERVER['QUERY_STRING'])) { + $id = $_SERVER['QUERY_STRING']; +} else { + $id = '0'; +} + if (!ctype_xdigit($id)) { $id = '0'; } -- cgit v1.2.3 From 43fd0a543900866f4feaf0713e1726b98a60b22d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 26 Dec 2013 22:20:24 +0100 Subject: Mise à jour de f.url en base de données lorsque SimplePie découvre que l'adresse a changé MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Et correction problème favicon lorsque l'adresse du flux a changé du point de vue de SimplePie. Plus petites optimisations. --- app/Controllers/entryController.php | 2 +- app/Controllers/feedController.php | 27 ++++++++++----------------- app/Models/Feed.php | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 24 deletions(-) (limited to 'app/Models/Feed.php') 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 dc8a854a9..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); diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 4f90b9872..0f467f776 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) { @@ -30,7 +31,10 @@ class FreshRSS_Feed extends Minz_Model { } public function hash() { - return hash('crc32b', Minz_Configuration::salt() . $this->url); + if ($this->hash === null) { + $this->hash = hash('crc32b', Minz_Configuration::salt() . $this->url); + } + return $this->hash; } public function url () { @@ -184,7 +188,7 @@ class FreshRSS_Feed extends Minz_Model { $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 ( @@ -256,11 +260,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); -- cgit v1.2.3 From b99979cef78f7cd0c1cb4ae81115d09881e85926 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 27 Dec 2013 14:11:17 +0100 Subject: Bug affichage ID category introduit récemment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Feed.php | 3 ++- app/Models/FeedDAO.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 0f467f776..32f8546dd 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -136,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)) { 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'] : ''); -- cgit v1.2.3 From 4d6ab45b03031e1c13ac2d3589364a43a0fe5578 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 30 Dec 2013 12:43:39 +0100 Subject: Micro-optimisation : évite is_null et quelques if/else MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/303 --- app/Models/Category.php | 2 +- app/Models/Entry.php | 6 +----- app/Models/Feed.php | 32 +++++++++++--------------------- lib/Minz/Dispatcher.php | 2 +- 4 files changed, 14 insertions(+), 28 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Category.php b/app/Models/Category.php index e70d1303f..8e1e44ef8 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -48,7 +48,7 @@ class FreshRSS_Category extends Minz_Model { return $this->nbNotRead; } public function feeds () { - if (is_null ($this->feeds)) { + if ($this->feeds === null) { $feedDAO = new FreshRSS_FeedDAO (); $this->feeds = $feedDAO->listByCategory ($this->id ()); $this->nbFeed = 0; diff --git a/app/Models/Entry.php b/app/Models/Entry.php index ab9605eb1..83f68ce78 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -38,11 +38,7 @@ class FreshRSS_Entry extends Minz_Model { return $this->title; } public function author () { - if (is_null ($this->author)) { - return ''; - } else { - return $this->author; - } + return $this->author === null ? '' : $this->author; } public function content () { return $this->content; diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 32f8546dd..f38828a42 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -44,11 +44,7 @@ class FreshRSS_Feed extends Minz_Model { return $this->category; } public function entries () { - if (!is_null ($this->entries)) { - return $this->entries; - } else { - return array (); - } + return $this->entries === null ? array() : $this->entries; } public function name () { return $this->name; @@ -140,10 +136,7 @@ class FreshRSS_Feed extends Minz_Model { $this->category = $value >= 0 ? $value : 0; } public function _name ($value) { - if (is_null ($value)) { - $value = ''; - } - $this->name = $value; + $this->name = $value === null ? '' : $value; } public function _website ($value, $validate=true) { if ($validate) { @@ -155,10 +148,7 @@ class FreshRSS_Feed extends Minz_Model { $this->website = $value; } public function _description ($value) { - if (is_null ($value)) { - $value = ''; - } - $this->description = $value; + $this->description = $value === null ? '' : $value; } public function _lastUpdate ($value) { $this->lastUpdate = $value; @@ -190,7 +180,7 @@ class FreshRSS_Feed extends Minz_Model { } public function load ($loadDetails = false) { - if (!is_null ($this->url)) { + if ($this->url !== null) { if (CACHE_PATH === false) { throw new Minz_FileNotExistException ( 'CACHE_PATH', @@ -253,7 +243,7 @@ class FreshRSS_Feed extends Minz_Model { // si on a utilisé l'auto-discover, notre url va avoir changé $subscribe_url = $feed->subscribe_url (); - if (!is_null ($subscribe_url) && $subscribe_url != $this->url) { + if ($subscribe_url !== null && $subscribe_url !== $this->url) { if ($this->httpAuth != '') { // on enlève les id si authentification HTTP $subscribe_url = preg_replace ('#((.+)://)((.+)@)(.+)#', '${1}${5}', $subscribe_url); @@ -263,7 +253,7 @@ class FreshRSS_Feed extends Minz_Model { if ($loadDetails) { $title = htmlspecialchars(html_only_entity_decode($feed->get_title()), ENT_COMPAT, 'UTF-8'); - $this->_name (!is_null ($title) ? $title : $this->url); + $this->_name ($title === null ? $this->url : $title); $this->_website(html_only_entity_decode($feed->get_link())); $this->_description(html_only_entity_decode($feed->get_description())); @@ -286,7 +276,7 @@ class FreshRSS_Feed extends Minz_Model { // gestion des tags (catégorie == tag) $tags_tmp = $item->get_categories (); $tags = array (); - if (!is_null ($tags_tmp)) { + if ($tags_tmp !== null) { foreach ($tags_tmp as $tag) { $tags[] = html_only_entity_decode ($tag->get_label ()); } @@ -308,10 +298,10 @@ class FreshRSS_Feed extends Minz_Model { $entry = new FreshRSS_Entry ( $this->id (), $item->get_id (), - !is_null ($title) ? $title : '', - !is_null ($author) ? html_only_entity_decode ($author->name) : '', - !is_null ($content) ? $content : '', - !is_null ($link) ? $link : '', + $title === null ? '' : $title, + $author === null ? '' : html_only_entity_decode ($author->name), + $content === null ? '' : $content, + $link === null ? '' : $link, $date ? $date : time () ); $entry->_tags ($tags); diff --git a/lib/Minz/Dispatcher.php b/lib/Minz/Dispatcher.php index 2898b5f00..c2c5e7f65 100644 --- a/lib/Minz/Dispatcher.php +++ b/lib/Minz/Dispatcher.php @@ -22,7 +22,7 @@ class Minz_Dispatcher { * Récupère l'instance du Dispatcher */ public static function getInstance ($router) { - if (is_null (self::$instance)) { + if (self::$instance === null) { self::$instance = new Minz_Dispatcher ($router); } return self::$instance; -- cgit v1.2.3 From 6eea96656a933b29b699999eec97299c4e363c79 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 5 Jan 2014 18:06:06 +0100 Subject: Utilise QUERY_STRING plutôt que PATH_INFO pour favicons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige https://github.com/marienfressinaud/FreshRSS/issues/348 Revenir dessus en cas de problème de cache HTTP des favicons. --- app/Models/Feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index f38828a42..df762c8fa 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -116,7 +116,7 @@ class FreshRSS_Feed extends Minz_Model { @unlink($path . '.txt'); } public function favicon () { - return Minz_Url::display ('/f.php/' . $this->hash()); + return Minz_Url::display ('/f.php?' . $this->hash()); } public function _id ($value) { -- cgit v1.2.3 From bc6aba67bbe023c461a47bdf7c0c81d061ca6b5a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 22 Jan 2014 21:34:59 +0100 Subject: Bug récupération flux tronqués MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige https://github.com/marienfressinaud/FreshRSS/issues/381 --- app/Models/Feed.php | 44 +------------------------------------------ lib/lib_rss.php | 54 +++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 47 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index df762c8fa..22c019080 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -187,54 +187,12 @@ class FreshRSS_Feed extends Minz_Model { Minz_Exception::ERROR ); } else { - $feed = new SimplePie (); - $feed->set_useragent(Minz_Translate::t ('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); $url = htmlspecialchars_decode ($this->url, ENT_QUOTES); if ($this->httpAuth != '') { $url = preg_replace ('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url); } - + $feed = customSimplePie(); $feed->set_feed_url ($url); - $feed->set_cache_location (CACHE_PATH); - $feed->set_cache_duration(1500); - $feed->strip_htmltags (array ( - 'base', 'blink', 'body', 'doctype', 'embed', - 'font', 'form', 'frame', 'frameset', 'html', - 'input', 'marquee', 'meta', 'noscript', - 'object', 'param', 'plaintext', 'script', 'style', - )); - $feed->strip_attributes(array_merge($feed->strip_attributes, array( - 'autoplay', 'onload', 'onunload', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', - 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', - 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless'))); - $feed->add_attributes(array( - 'img' => array('lazyload' => ''), //http://www.w3.org/TR/resource-priorities/ - 'audio' => array('preload' => 'none'), - 'iframe' => array('postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), - 'video' => array('postpone' => '', 'preload' => 'none'), - )); - $feed->set_url_replacements(array( - 'a' => 'href', - 'area' => 'href', - 'audio' => 'src', - 'blockquote' => 'cite', - 'del' => 'cite', - 'form' => 'action', - 'iframe' => 'src', - 'img' => array( - 'longdesc', - 'src' - ), - 'input' => 'src', - 'ins' => 'cite', - 'q' => 'cite', - 'source' => 'src', - 'track' => 'src', - 'video' => array( - 'poster', - 'src', - ), - )); $feed->init (); if ($feed->error ()) { diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 33d7ebc32..ba5b01112 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -106,13 +106,59 @@ function html_only_entity_decode($text) { return strtr($text, $htmlEntitiesOnly); } -function sanitizeHTML($data) { +function customSimplePie() { + $simplePie = new SimplePie(); + $simplePie->set_useragent(Minz_Translate::t('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); + $simplePie->set_cache_location(CACHE_PATH); + $simplePie->set_cache_duration(1500); + $simplePie->strip_htmltags(array( + 'base', 'blink', 'body', 'doctype', 'embed', + 'font', 'form', 'frame', 'frameset', 'html', + 'input', 'marquee', 'meta', 'noscript', + 'object', 'param', 'plaintext', 'script', 'style', + )); + $simplePie->strip_attributes(array_merge($simplePie->strip_attributes, array( + 'autoplay', 'onload', 'onunload', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', + 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', + 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless'))); + $simplePie->add_attributes(array( + 'img' => array('lazyload' => ''), //http://www.w3.org/TR/resource-priorities/ + 'audio' => array('preload' => 'none'), + 'iframe' => array('postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), + 'video' => array('postpone' => '', 'preload' => 'none'), + )); + $simplePie->set_url_replacements(array( + 'a' => 'href', + 'area' => 'href', + 'audio' => 'src', + 'blockquote' => 'cite', + 'del' => 'cite', + 'form' => 'action', + 'iframe' => 'src', + 'img' => array( + 'longdesc', + 'src' + ), + 'input' => 'src', + 'ins' => 'cite', + 'q' => 'cite', + 'source' => 'src', + 'track' => 'src', + 'video' => array( + 'poster', + 'src', + ), + )); + return $simplePie; +} + +function sanitizeHTML($data, $base = '') { static $simplePie = null; if ($simplePie == null) { - $simplePie = new SimplePie(); + $simplePie = customSimplePie(); $simplePie->init(); } - return html_only_entity_decode($simplePie->sanitize->sanitize($data, SIMPLEPIE_CONSTRUCT_MAYBE_HTML)); + return html_only_entity_decode($simplePie->sanitize->sanitize($data, SIMPLEPIE_CONSTRUCT_HTML, $base)); } /* permet de récupérer le contenu d'un article pour un flux qui n'est pas complet */ @@ -125,7 +171,7 @@ function get_content_by_parsing ($url, $path) { if ($html) { $doc = phpQuery::newDocument ($html); $content = $doc->find ($path); - return sanitizeHTML($content->__toString()); + return sanitizeHTML($content->__toString(), $url); } else { throw new Exception (); } -- cgit v1.2.3