From ba9fd9941caf13424bc6fe969f1d161b2059a206 Mon Sep 17 00:00:00 2001 From: plopoyop Date: Sun, 21 Sep 2014 12:12:35 +0200 Subject: [PATCH] Upgrade sources to 0.7.4 --- sources/CHANGELOG | 20 + sources/{README.md => README.fr.md} | 15 +- .../app/Controllers/configureController.php | 2 + sources/app/Controllers/errorController.php | 52 +- .../Controllers/importExportController.php | 268 ++++--- sources/app/Controllers/indexController.php | 55 +- sources/app/Controllers/statsController.php | 53 +- sources/app/Controllers/usersController.php | 4 +- sources/app/FreshRSS.php | 49 +- sources/app/Models/Configuration.php | 8 + sources/app/Models/EntryDAO.php | 14 +- sources/app/Models/EntryDAOSQLite.php | 4 +- sources/app/Models/Feed.php | 12 +- sources/app/Models/StatsDAO.php | 132 +++- sources/app/Models/StatsDAOSQLite.php | 28 +- sources/app/Models/UserDAO.php | 39 +- sources/app/SQL/install.sql.sqlite.php | 1 + sources/app/i18n/en.php | 57 +- sources/app/i18n/fr.php | 35 +- sources/app/i18n/install.en.php | 4 +- sources/app/i18n/install.fr.php | 4 +- sources/app/install.php | 28 +- sources/app/layout/aside_flux.phtml | 17 +- sources/app/layout/aside_stats.phtml | 3 + sources/app/layout/layout.phtml | 2 +- sources/app/layout/nav_menu.phtml | 18 +- sources/app/views/configure/reading.phtml | 35 +- sources/app/views/error/index.phtml | 13 +- sources/app/views/helpers/export/opml.phtml | 6 +- .../app/views/helpers/javascript_vars.phtml | 3 +- sources/app/views/helpers/pagination.phtml | 2 +- .../app/views/helpers/view/normal_view.phtml | 17 +- .../app/views/helpers/view/reader_view.phtml | 18 +- sources/app/views/importExport/export.phtml | 0 sources/app/views/importExport/index.phtml | 31 +- sources/app/views/index/formLogin.phtml | 23 +- sources/app/views/javascript/actualize.phtml | 21 +- sources/app/views/stats/idle.phtml | 20 +- sources/app/views/stats/main.phtml | 127 ---- sources/app/views/stats/repartition.phtml | 114 +++ sources/constants.php | 2 +- sources/data/tokens/.gitignore | 1 + sources/data/tokens/index.html | 13 + sources/lib/Minz/Helper.php | 17 +- sources/lib/Minz/ModelPdo.php | 20 +- sources/lib/Minz/Request.php | 118 +-- sources/lib/Minz/Session.php | 74 +- sources/lib/Minz/Translate.php | 2 +- sources/lib/lib_rss.php | 24 +- sources/p/api/greader.php | 1 + sources/p/i/.gitignore | 1 + sources/p/scripts/jquery.lazyload.min.js | 15 - sources/p/scripts/main.js | 146 +++- sources/p/themes/Dark/dark.css | 6 +- sources/p/themes/Dark/template.css | 3 + sources/p/themes/Flat/flat.css | 11 +- sources/p/themes/Flat/template.css | 3 + sources/p/themes/Origine/origine.css | 20 +- sources/p/themes/Origine/template.css | 3 + sources/p/themes/Screwdriver/README.md | 36 + sources/p/themes/Screwdriver/icons/add.svg | 5 + sources/p/themes/Screwdriver/icons/all.svg | 7 + .../Screwdriver/icons/apple-touch-icon.png | Bin 0 -> 5648 bytes .../themes/Screwdriver/icons/bookmark-add.svg | 6 + .../p/themes/Screwdriver/icons/bookmark.svg | 60 ++ .../Screwdriver/icons/category-white.svg | 7 + .../p/themes/Screwdriver/icons/category.svg | 7 + sources/p/themes/Screwdriver/icons/close.svg | 7 + .../p/themes/Screwdriver/icons/configure.svg | 5 + sources/p/themes/Screwdriver/icons/down.svg | 5 + .../Screwdriver/icons/favicon-16-32-48-64.ico | Bin 0 -> 32038 bytes .../themes/Screwdriver/icons/favicon-256.png | Bin 0 -> 17174 bytes .../p/themes/Screwdriver/icons/favicon.svg | 13 + sources/p/themes/Screwdriver/icons/grey.gif | Bin 0 -> 56 bytes sources/p/themes/Screwdriver/icons/help.svg | 7 + .../{YunoHost => Screwdriver}/icons/icon.svg | 4 +- .../{YunoHost => Screwdriver}/icons/key.svg | 2 +- sources/p/themes/Screwdriver/icons/link.svg | 7 + sources/p/themes/Screwdriver/icons/login.svg | 6 + sources/p/themes/Screwdriver/icons/logout.svg | 6 + sources/p/themes/Screwdriver/icons/next.svg | 5 + .../themes/Screwdriver/icons/non-starred.svg | 5 + sources/p/themes/Screwdriver/icons/prev.svg | 5 + sources/p/themes/Screwdriver/icons/read.svg | 57 ++ .../p/themes/Screwdriver/icons/refresh.svg | 5 + .../{YunoHost => Screwdriver}/icons/rss.svg | 2 +- sources/p/themes/Screwdriver/icons/search.svg | 6 + sources/p/themes/Screwdriver/icons/share.svg | 8 + .../p/themes/Screwdriver/icons/starred.svg | 60 ++ sources/p/themes/Screwdriver/icons/tag.svg | 5 + sources/p/themes/Screwdriver/icons/unread.svg | 65 ++ sources/p/themes/Screwdriver/icons/up.svg | 5 + .../icons/view-global.svg | 2 +- .../icons/view-normal.svg | 2 +- .../icons/view-reader.svg | 2 +- sources/p/themes/Screwdriver/loader.gif | Bin 0 -> 4167 bytes sources/p/themes/Screwdriver/metadata.json | 7 + .../screwdriver.css} | 695 ++++++++++++------ .../{YunoHost => Screwdriver}/template.css | 4 +- sources/p/themes/YunoHost/icons/add.svg | 30 - sources/p/themes/YunoHost/icons/all.svg | 32 - sources/p/themes/YunoHost/icons/category.svg | 31 - sources/p/themes/YunoHost/icons/close.svg | 28 - sources/p/themes/YunoHost/icons/configure.svg | 31 - sources/p/themes/YunoHost/icons/down.svg | 31 - sources/p/themes/YunoHost/icons/next.svg | 31 - sources/p/themes/YunoHost/icons/prev.svg | 31 - sources/p/themes/YunoHost/icons/refresh.svg | 31 - sources/p/themes/YunoHost/icons/search.svg | 32 - sources/p/themes/YunoHost/icons/up.svg | 31 - sources/p/themes/YunoHost/loader.gif | Bin 4251 -> 0 bytes sources/p/themes/YunoHost/metadata.json | 7 - sources/p/themes/base-theme/base.css | 12 +- sources/p/themes/base-theme/template.css | 3 + 114 files changed, 2110 insertions(+), 1215 deletions(-) rename sources/{README.md => README.fr.md} (91%) create mode 100755 sources/app/views/importExport/export.phtml delete mode 100755 sources/app/views/stats/main.phtml create mode 100755 sources/app/views/stats/repartition.phtml create mode 100755 sources/data/tokens/.gitignore create mode 100755 sources/data/tokens/index.html create mode 100755 sources/p/i/.gitignore delete mode 100755 sources/p/scripts/jquery.lazyload.min.js create mode 100755 sources/p/themes/Screwdriver/README.md create mode 100755 sources/p/themes/Screwdriver/icons/add.svg create mode 100755 sources/p/themes/Screwdriver/icons/all.svg create mode 100755 sources/p/themes/Screwdriver/icons/apple-touch-icon.png create mode 100755 sources/p/themes/Screwdriver/icons/bookmark-add.svg create mode 100755 sources/p/themes/Screwdriver/icons/bookmark.svg create mode 100755 sources/p/themes/Screwdriver/icons/category-white.svg create mode 100755 sources/p/themes/Screwdriver/icons/category.svg create mode 100755 sources/p/themes/Screwdriver/icons/close.svg create mode 100755 sources/p/themes/Screwdriver/icons/configure.svg create mode 100755 sources/p/themes/Screwdriver/icons/down.svg create mode 100755 sources/p/themes/Screwdriver/icons/favicon-16-32-48-64.ico create mode 100755 sources/p/themes/Screwdriver/icons/favicon-256.png create mode 100755 sources/p/themes/Screwdriver/icons/favicon.svg create mode 100755 sources/p/themes/Screwdriver/icons/grey.gif create mode 100755 sources/p/themes/Screwdriver/icons/help.svg rename sources/p/themes/{YunoHost => Screwdriver}/icons/icon.svg (75%) rename sources/p/themes/{YunoHost => Screwdriver}/icons/key.svg (93%) create mode 100755 sources/p/themes/Screwdriver/icons/link.svg create mode 100755 sources/p/themes/Screwdriver/icons/login.svg create mode 100755 sources/p/themes/Screwdriver/icons/logout.svg create mode 100755 sources/p/themes/Screwdriver/icons/next.svg create mode 100755 sources/p/themes/Screwdriver/icons/non-starred.svg create mode 100755 sources/p/themes/Screwdriver/icons/prev.svg create mode 100755 sources/p/themes/Screwdriver/icons/read.svg create mode 100755 sources/p/themes/Screwdriver/icons/refresh.svg rename sources/p/themes/{YunoHost => Screwdriver}/icons/rss.svg (97%) create mode 100755 sources/p/themes/Screwdriver/icons/search.svg create mode 100755 sources/p/themes/Screwdriver/icons/share.svg create mode 100755 sources/p/themes/Screwdriver/icons/starred.svg create mode 100755 sources/p/themes/Screwdriver/icons/tag.svg create mode 100755 sources/p/themes/Screwdriver/icons/unread.svg create mode 100755 sources/p/themes/Screwdriver/icons/up.svg rename sources/p/themes/{YunoHost => Screwdriver}/icons/view-global.svg (90%) rename sources/p/themes/{YunoHost => Screwdriver}/icons/view-normal.svg (59%) rename sources/p/themes/{YunoHost => Screwdriver}/icons/view-reader.svg (93%) create mode 100755 sources/p/themes/Screwdriver/loader.gif create mode 100755 sources/p/themes/Screwdriver/metadata.json rename sources/p/themes/{YunoHost/yunohost.css => Screwdriver/screwdriver.css} (50%) mode change 100644 => 100755 rename sources/p/themes/{YunoHost => Screwdriver}/template.css (99%) mode change 100644 => 100755 delete mode 100755 sources/p/themes/YunoHost/icons/add.svg delete mode 100755 sources/p/themes/YunoHost/icons/all.svg delete mode 100755 sources/p/themes/YunoHost/icons/category.svg delete mode 100755 sources/p/themes/YunoHost/icons/close.svg delete mode 100755 sources/p/themes/YunoHost/icons/configure.svg delete mode 100755 sources/p/themes/YunoHost/icons/down.svg delete mode 100755 sources/p/themes/YunoHost/icons/next.svg delete mode 100755 sources/p/themes/YunoHost/icons/prev.svg delete mode 100755 sources/p/themes/YunoHost/icons/refresh.svg delete mode 100755 sources/p/themes/YunoHost/icons/search.svg delete mode 100755 sources/p/themes/YunoHost/icons/up.svg delete mode 100644 sources/p/themes/YunoHost/loader.gif delete mode 100644 sources/p/themes/YunoHost/metadata.json diff --git a/sources/CHANGELOG b/sources/CHANGELOG index cd48765..df43fe1 100755 --- a/sources/CHANGELOG +++ b/sources/CHANGELOG @@ -1,5 +1,25 @@ # Journal des modifications +## 2014-08-xx FreshRSS 0.7.4 + +* UI + * Hide categories/feeds with unread articles when showing only unread articles + * Dynamic favicon showing the number of unread articles + * New theme: Screwdriver by Mister aiR +* Statistics + * New page with article repartition + * Improvements +* Security + * Basic protection against XSRF (Cross-Site Request Forgery) based on HTTP Referer (POST requests only) +* API + * Compatible with lighttpd +* Misc. + * Changed lazyload implementation + * Support of HTML5 notifications for new upcoming articles + * Add option to stay logged in +* Bux fixes in export function, add/remove users, keyboard shortcuts, etc. + + ## 2014-07-21 FreshRSS 0.7.3 * New options diff --git a/sources/README.md b/sources/README.fr.md similarity index 91% rename from sources/README.md rename to sources/README.fr.md index f857bae..9c18f56 100755 --- a/sources/README.md +++ b/sources/README.fr.md @@ -1,3 +1,5 @@ +* [English version](README.md) + # FreshRSS FreshRSS est un agrégateur de flux RSS à auto-héberger à l’image de [Leed](http://projet.idleman.fr/leed/) ou de [Kriss Feed](http://tontof.net/kriss/feed/). @@ -8,8 +10,8 @@ Il permet de gérer plusieurs utilisateurs, et dispose d’un mode de lecture an * Site officiel : http://freshrss.org * Démo : http://demo.freshrss.org/ * Développeur : Marien Fressinaud -* Version actuelle : 0.7.3 -* Date de publication 2014-07-21 +* Version actuelle : 0.7.4 +* Date de publication 2014-08-24 * 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) @@ -31,11 +33,11 @@ Privilégiez pour cela des demandes sur GitHub # Pré-requis * Serveur modeste, par exemple sous Linux ou Windows * Fonctionne même sur un Raspberry Pi avec des temps de réponse < 1s (testé sur 150 flux, 22k articles, soit 32Mo de données partiellement compressées) -* Serveur Web Apache2 ou Nginx (non testé sur les autres) +* Serveur Web Apache2 (recommandé), ou nginx, lighttpd (non testé sur les autres) * PHP 5.2.1+ (PHP 5.3.7+ recommandé) - * Requis : [PDO_MySQL](http://php.net/pdo-mysql), [cURL](http://php.net/curl), [LibXML](http://php.net/xml), [PCRE](http://php.net/pcre), [ctype](http://php.net/ctype) - * Recommandés : [JSON](http://php.net/json), [zlib](http://php.net/zlib), [mbstring](http://php.net/mbstring), [iconv](http://php.net/iconv), [Zip](http://php.net/zip) -* MySQL 5.0.3+ (recommandé) ou SQLite 3.7.4+ (en bêta) + * Requis : [PDO_MySQL](http://php.net/pdo-mysql) ou [PDO_SQLite](http://php.net/pdo-sqlite), [cURL](http://php.net/curl), [GMP](http://php.net/gmp) (seulement pour accès API sur platformes < 64 bits) + * Recommandés : [JSON](http://php.net/json), [mbstring](http://php.net/mbstring), [zlib](http://php.net/zlib), [Zip](http://php.net/zip) +* MySQL 5.0.3+ (recommandé) ou SQLite 3.7.4+ * Un navigateur Web récent tel Firefox 4+, Chrome, Opera, Safari, Internet Explorer 9+ * Fonctionne aussi sur mobile @@ -93,7 +95,6 @@ mysqldump -u utilisateur -p --databases freshrss > freshrss.sql ## Uniquement pour certaines options * [bcrypt.js](https://github.com/dcodeIO/bcrypt.js) * [phpQuery](http://code.google.com/p/phpquery/) -* [Lazy Load](http://www.appelsiini.net/projects/lazyload) ## Si les fonctions natives ne sont pas disponibles * [Services_JSON](http://pear.php.net/pepr/pepr-proposal-show.php?id=198) diff --git a/sources/app/Controllers/configureController.php b/sources/app/Controllers/configureController.php index 79f40b3..bb96bfa 100755 --- a/sources/app/Controllers/configureController.php +++ b/sources/app/Controllers/configureController.php @@ -184,6 +184,8 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $this->view->conf->_default_view((int)Minz_Request::param('default_view', FreshRSS_Entry::STATE_ALL)); $this->view->conf->_auto_load_more(Minz_Request::param('auto_load_more', false)); $this->view->conf->_display_posts(Minz_Request::param('display_posts', false)); + $this->view->conf->_display_categories(Minz_Request::param('display_categories', false)); + $this->view->conf->_hide_read_feeds(Minz_Request::param('hide_read_feeds', false)); $this->view->conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false)); $this->view->conf->_lazyload(Minz_Request::param('lazyload', false)); $this->view->conf->_sticky_post(Minz_Request::param('sticky_post', false)); diff --git a/sources/app/Controllers/errorController.php b/sources/app/Controllers/errorController.php index dc9a2ee..922650b 100755 --- a/sources/app/Controllers/errorController.php +++ b/sources/app/Controllers/errorController.php @@ -1,26 +1,38 @@ view->code = 'Error 403 - Forbidden'; - break; - case 404: - $this->view->code = 'Error 404 - Not found'; - break; - case 500: - $this->view->code = 'Error 500 - Internal Server Error'; - break; - case 503: - $this->view->code = 'Error 503 - Service Unavailable'; - break; - default: - $this->view->code = 'Error 404 - Not found'; + public function indexAction() { + switch (Minz_Request::param('code')) { + case 403: + $this->view->code = 'Error 403 - Forbidden'; + break; + case 404: + $this->view->code = 'Error 404 - Not found'; + break; + case 500: + $this->view->code = 'Error 500 - Internal Server Error'; + break; + case 503: + $this->view->code = 'Error 503 - Service Unavailable'; + break; + default: + $this->view->code = 'Error 404 - Not found'; } - - $this->view->logs = Minz_Request::param ('logs'); - - Minz_View::prependTitle ($this->view->code . ' · '); + + $errors = Minz_Request::param('logs', array()); + $this->view->errorMessage = trim(implode($errors)); + if ($this->view->errorMessage == '') { + switch(Minz_Request::param('code')) { + case 403: + $this->view->errorMessage = Minz_Translate::t('forbidden_access'); + break; + case 404: + default: + $this->view->errorMessage = Minz_Translate::t('page_not_found'); + break; + } + } + + Minz_View::prependTitle($this->view->code . ' · '); } } diff --git a/sources/app/Controllers/importExportController.php b/sources/app/Controllers/importExportController.php index ba172cc..5adf387 100755 --- a/sources/app/Controllers/importExportController.php +++ b/sources/app/Controllers/importExportController.php @@ -5,7 +5,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { if (!$this->view->loginOk) { Minz_Error::error( 403, - array('error' => array(Minz_Translate::t('access_denied'))) + array('error' => array(_t('access_denied'))) ); } @@ -20,33 +20,51 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->view->categories = $this->catDAO->listCategories(); $this->view->feeds = $this->feedDAO->listFeeds(); - Minz_View::prependTitle(Minz_Translate::t('import_export') . ' · '); + Minz_View::prependTitle(_t('import_export') . ' · '); } public function importAction() { - if (Minz_Request::isPost() && $_FILES['file']['error'] == 0) { - @set_time_limit(300); + if (!Minz_Request::isPost()) { + Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); + } - $file = $_FILES['file']; - $type_file = $this->guessFileType($file['name']); + $file = $_FILES['file']; + $status_file = $file['error']; - $list_files = array( - 'opml' => array(), - 'json_starred' => array(), - 'json_feed' => array() - ); + if ($status_file !== 0) { + Minz_Log::error('File cannot be uploaded. Error code: ' . $status_file); + Minz_Request::bad(_t('file_cannot_be_uploaded'), + array('c' => 'importExport', 'a' => 'index')); + } - // We try to list all files according to their type - // A zip file is first opened and then its files are listed - $list = array(); - if ($type_file === 'zip') { - $zip = zip_open($file['tmp_name']); + @set_time_limit(300); - while (($zipfile = zip_read($zip)) !== false) { - $type_zipfile = $this->guessFileType( - zip_entry_name($zipfile) - ); + $type_file = $this->guessFileType($file['name']); + $list_files = array( + 'opml' => array(), + 'json_starred' => array(), + 'json_feed' => array() + ); + + // We try to list all files according to their type + $list = array(); + if ($type_file === 'zip' && extension_loaded('zip')) { + $zip = zip_open($file['tmp_name']); + + if (!is_resource($zip)) { + // zip_open cannot open file: something is wrong + Minz_Log::error('Zip archive cannot be imported. Error code: ' . $zip); + Minz_Request::bad(_t('zip_error'), + array('c' => 'importExport', 'a' => 'index')); + } + + while (($zipfile = zip_read($zip)) !== false) { + if (!is_resource($zipfile)) { + // zip_entry() can also return an error code! + Minz_Log::error('Zip file cannot be imported. Error code: ' . $zipfile); + } else { + $type_zipfile = $this->guessFileType(zip_entry_name($zipfile)); if ($type_file !== 'unknown') { $list_files[$type_zipfile][] = zip_entry_read( $zipfile, @@ -54,59 +72,37 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { ); } } - - zip_close($zip); - } elseif ($type_file !== 'unknown') { - $list_files[$type_file][] = file_get_contents( - $file['tmp_name'] - ); } - // Import different files. - // OPML first(so categories and feeds are imported) - // Starred articles then so the "favourite" status is already set - // And finally all other files. - $error = false; - foreach ($list_files['opml'] as $opml_file) { - $error = $this->importOpml($opml_file); - } - foreach ($list_files['json_starred'] as $article_file) { - $error = $this->importArticles($article_file, true); - } - foreach ($list_files['json_feed'] as $article_file) { - $error = $this->importArticles($article_file); - } - - // And finally, we get import status and redirect to the home page - $notif = null; - if ($error === true) { - $content_notif = Minz_Translate::t( - 'feeds_imported_with_errors' - ); - } else { - $content_notif = Minz_Translate::t( - 'feeds_imported' - ); - } - - Minz_Session::_param('notification', array( - 'type' => 'good', - 'content' => $content_notif - )); - Minz_Session::_param('actualize_feeds', true); - - Minz_Request::forward(array( - 'c' => 'index', - 'a' => 'index' - ), true); + zip_close($zip); + } elseif ($type_file === 'zip') { + // Zip extension is not loaded + Minz_Request::bad(_t('no_zip_extension'), + array('c' => 'importExport', 'a' => 'index')); + } elseif ($type_file !== 'unknown') { + $list_files[$type_file][] = file_get_contents($file['tmp_name']); } - // What are you doing? you have to call this controller - // with a POST request! - Minz_Request::forward(array( - 'c' => 'importExport', - 'a' => 'index' - )); + // Import file contents. + // OPML first(so categories and feeds are imported) + // Starred articles then so the "favourite" status is already set + // And finally all other files. + $error = false; + foreach ($list_files['opml'] as $opml_file) { + $error = $this->importOpml($opml_file); + } + foreach ($list_files['json_starred'] as $article_file) { + $error = $this->importArticles($article_file, true); + } + foreach ($list_files['json_feed'] as $article_file) { + $error = $this->importArticles($article_file); + } + + // And finally, we get import status and redirect to the home page + Minz_Session::_param('actualize_feeds', true); + $content_notif = $error === true ? _t('feeds_imported_with_errors') : + _t('feeds_imported'); + Minz_Request::good($content_notif); } private function guessFileType($filename) { @@ -120,7 +116,8 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } elseif (substr_compare($filename, '.opml', -5) === 0 || substr_compare($filename, '.xml', -4) === 0) { return 'opml'; - } elseif (strcmp($filename, 'starred.json') === 0) { + } elseif (substr_compare($filename, '.json', -5) === 0 && + strpos($filename, 'starred') !== false) { return 'json_starred'; } elseif (substr_compare($filename, '.json', -5) === 0 && strpos($filename, 'feed_') === 0) { @@ -176,15 +173,15 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } // We get different useful information - $url = html_chars_utf8($feed_elt['xmlUrl']); - $name = html_chars_utf8($feed_elt['text']); + $url = Minz_Helper::htmlspecialchars_utf8($feed_elt['xmlUrl']); + $name = Minz_Helper::htmlspecialchars_utf8($feed_elt['text']); $website = ''; if (isset($feed_elt['htmlUrl'])) { - $website = html_chars_utf8($feed_elt['htmlUrl']); + $website = Minz_Helper::htmlspecialchars_utf8($feed_elt['htmlUrl']); } $description = ''; if (isset($feed_elt['description'])) { - $description = html_chars_utf8($feed_elt['description']); + $description = Minz_Helper::htmlspecialchars_utf8($feed_elt['description']); } $error = false; @@ -210,7 +207,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { private function addCategoryOpml($cat_elt, $parent_cat) { // Create a new Category object - $cat = new FreshRSS_Category(html_chars_utf8($cat_elt['text'])); + $cat = new FreshRSS_Category(Minz_Helper::htmlspecialchars_utf8($cat_elt['text'])); $id = $this->catDAO->addCategoryObject($cat); $error = ($id === false); @@ -287,7 +284,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $url = $origin[$key]; $name = $origin['title']; $website = $origin['htmlUrl']; - $error = false; + try { // Create a Feed object and add it in DB $feed = new FreshRSS_Feed($url); @@ -311,44 +308,53 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } public function exportAction() { - if (Minz_Request::isPost()) { - $this->view->_useLayout(false); + if (!Minz_Request::isPost()) { + Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); + } - $export_opml = Minz_Request::param('export_opml', false); - $export_starred = Minz_Request::param('export_starred', false); - $export_feeds = Minz_Request::param('export_feeds', false); + $this->view->_useLayout(false); - // From https://stackoverflow.com/questions/1061710/php-zip-files-on-the-fly - $file = tempnam('tmp', 'zip'); - $zip = new ZipArchive(); - $zip->open($file, ZipArchive::OVERWRITE); + $export_opml = Minz_Request::param('export_opml', false); + $export_starred = Minz_Request::param('export_starred', false); + $export_feeds = Minz_Request::param('export_feeds', array()); - // Stuff with content - if ($export_opml) { - $zip->addFromString( - 'feeds.opml', $this->generateOpml() - ); - } - if ($export_starred) { - $zip->addFromString( - 'starred.json', $this->generateArticles('starred') - ); - } - foreach ($export_feeds as $feed_id) { - $feed = $this->feedDAO->searchById($feed_id); - $zip->addFromString( - 'feed_' . $feed->category() . '_' . $feed->id() . '.json', - $this->generateArticles('feed', $feed) + $export_files = array(); + if ($export_opml) { + $export_files['feeds.opml'] = $this->generateOpml(); + } + + if ($export_starred) { + $export_files['starred.json'] = $this->generateArticles('starred'); + } + + foreach ($export_feeds as $feed_id) { + $feed = $this->feedDAO->searchById($feed_id); + if ($feed) { + $filename = 'feed_' . $feed->category() . '_' + . $feed->id() . '.json'; + $export_files[$filename] = $this->generateArticles( + 'feed', $feed ); } + } - // Close and send to user - $zip->close(); - header('Content-Type: application/zip'); - header('Content-Length: ' . filesize($file)); - header('Content-Disposition: attachment; filename="freshrss_export.zip"'); - readfile($file); - unlink($file); + $nb_files = count($export_files); + if ($nb_files > 1) { + // If there are more than 1 file to export, we need a zip archive. + try { + $this->exportZip($export_files); + } catch (Exception $e) { + # Oops, there is no Zip extension! + Minz_Request::bad(_t('export_no_zip_extension'), + array('c' => 'importExport', 'a' => 'index')); + } + } elseif ($nb_files === 1) { + // Only one file? Guess its type and export it. + $filename = key($export_files); + $type = $this->guessFileType($filename); + $this->exportFile('freshrss_' . $filename, $export_files[$filename], $type); + } else { + Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); } } @@ -367,7 +373,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->view->categories = $this->catDAO->listCategories(); if ($type == 'starred') { - $this->view->list_title = Minz_Translate::t('starred_list'); + $this->view->list_title = _t('starred_list'); $this->view->type = 'starred'; $unread_fav = $this->entryDAO->countUnreadReadFavorites(); $this->view->entries = $this->entryDAO->listWhere( @@ -375,9 +381,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $unread_fav['all'] ); } elseif ($type == 'feed' && !is_null($feed)) { - $this->view->list_title = Minz_Translate::t( - 'feed_list', $feed->name() - ); + $this->view->list_title = _t('feed_list', $feed->name()); $this->view->type = 'feed/' . $feed->id(); $this->view->entries = $this->entryDAO->listWhere( 'f', $feed->id(), FreshRSS_Entry::STATE_ALL, 'ASC', @@ -388,4 +392,44 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $this->view->helperToString('export/articles'); } + + private function exportZip($files) { + if (!extension_loaded('zip')) { + throw new Exception(); + } + + // From https://stackoverflow.com/questions/1061710/php-zip-files-on-the-fly + $zip_file = tempnam('tmp', 'zip'); + $zip = new ZipArchive(); + $zip->open($zip_file, ZipArchive::OVERWRITE); + + foreach ($files as $filename => $content) { + $zip->addFromString($filename, $content); + } + + // Close and send to user + $zip->close(); + header('Content-Type: application/zip'); + header('Content-Length: ' . filesize($zip_file)); + header('Content-Disposition: attachment; filename="freshrss_export.zip"'); + readfile($zip_file); + unlink($zip_file); + } + + private function exportFile($filename, $content, $type) { + if ($type === 'unknown') { + return; + } + + $content_type = ''; + if ($type === 'opml') { + $content_type = "text/opml"; + } elseif ($type === 'json_feed' || $type === 'json_starred') { + $content_type = "text/json"; + } + + header('Content-Type: ' . $content_type . '; charset=utf-8'); + header('Content-disposition: attachment; filename=' . $filename); + print($content); + } } diff --git a/sources/app/Controllers/indexController.php b/sources/app/Controllers/indexController.php index 9a46bde..b0b0511 100755 --- a/sources/app/Controllers/indexController.php +++ b/sources/app/Controllers/indexController.php @@ -69,9 +69,6 @@ class FreshRSS_index_Controller extends Minz_ActionController { // mise à jour des titres $this->view->rss_title = $this->view->currentName . ' | ' . Minz_View::title(); - if ($this->view->nb_not_read > 0) { - Minz_View::prependTitle('(' . formatNumber($this->view->nb_not_read) . ') '); - } Minz_View::prependTitle( ($this->nb_not_read_cat > 0 ? '(' . formatNumber($this->nb_not_read_cat) . ') ' : '') . $this->view->currentName . @@ -79,14 +76,14 @@ class FreshRSS_index_Controller extends Minz_ActionController { ); // On récupère les différents éléments de filtrage - $this->view->state = $state = Minz_Request::param ('state', $this->view->conf->default_view); + $this->view->state = Minz_Request::param('state', $this->view->conf->default_view); $state_param = Minz_Request::param ('state', null); $filter = Minz_Request::param ('search', ''); $this->view->order = $order = Minz_Request::param ('order', $this->view->conf->sort_order); $nb = Minz_Request::param ('nb', $this->view->conf->posts_per_page); $first = Minz_Request::param ('next', ''); - if ($state === FreshRSS_Entry::STATE_NOT_READ) { //Any unread article in this category at all? + if ($this->view->state === FreshRSS_Entry::STATE_NOT_READ) { //Any unread article in this category at all? switch ($getType) { case 'a': $hasUnread = $this->view->nb_not_read > 0; @@ -107,7 +104,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { break; } if (!$hasUnread && ($state_param === null)) { - $this->view->state = $state = FreshRSS_Entry::STATE_ALL; + $this->view->state = FreshRSS_Entry::STATE_ALL; } } @@ -120,11 +117,11 @@ class FreshRSS_index_Controller extends Minz_ActionController { $keepHistoryDefault = $this->view->conf->keep_history_default; try { - $entries = $entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter, $date_min, true, $keepHistoryDefault); + $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb + 1, $first, $filter, $date_min, true, $keepHistoryDefault); // Si on a récupéré aucun article "non lus" // on essaye de récupérer tous les articles - if ($state === FreshRSS_Entry::STATE_NOT_READ && empty($entries) && ($state_param === null) && ($filter == '')) { + if ($this->view->state === FreshRSS_Entry::STATE_NOT_READ && empty($entries) && ($state_param === null) && ($filter == '')) { Minz_Log::record('Conflicting information about nbNotRead!', Minz_Log::DEBUG); $feedDAO = FreshRSS_Factory::createFeedDao(); try { @@ -135,6 +132,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { $this->view->state = FreshRSS_Entry::STATE_ALL; $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb, $first, $filter, $date_min, true, $keepHistoryDefault); } + Minz_Request::_param('state', $this->view->state); if (count($entries) <= $nb) { $this->view->nextId = ''; @@ -298,6 +296,41 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Session::_param('passwordHash'); } + private static function makeLongTermCookie($username, $passwordHash) { + do { + $token = sha1(Minz_Configuration::salt() . $username . uniqid(mt_rand(), true)); + $tokenFile = DATA_PATH . '/tokens/' . $token . '.txt'; + } while (file_exists($tokenFile)); + if (@file_put_contents($tokenFile, $username . "\t" . $passwordHash) === false) { + return false; + } + $expire = time() + 2629744; //1 month //TODO: Use a configuration instead + Minz_Session::setLongTermCookie('FreshRSS_login', $token, $expire); + Minz_Session::_param('token', $token); + return $token; + } + + private static function deleteLongTermCookie() { + Minz_Session::deleteLongTermCookie('FreshRSS_login'); + $token = Minz_Session::param('token', null); + if (ctype_alnum($token)) { + @unlink(DATA_PATH . '/tokens/' . $token . '.txt'); + } + Minz_Session::_param('token'); + if (rand(0, 10) === 1) { + self::purgeTokens(); + } + } + + private static function purgeTokens() { + $oldest = time() - 2629744; //1 month //TODO: Use a configuration instead + foreach (new DirectoryIterator(DATA_PATH . '/tokens/') as $fileInfo) { + if ($fileInfo->getExtension() === 'txt' && $fileInfo->getMTime() < $oldest) { + @unlink($fileInfo->getPathname()); + } + } + } + public function formLoginAction () { if (Minz_Request::isPost()) { $ok = false; @@ -315,6 +348,11 @@ class FreshRSS_index_Controller extends Minz_ActionController { if ($ok) { Minz_Session::_param('currentUser', $username); Minz_Session::_param('passwordHash', $s); + if (Minz_Request::param('keep_logged_in', false)) { + self::makeLongTermCookie($username, $s); + } else { + self::deleteLongTermCookie(); + } } else { Minz_Log::record('Password mismatch for user ' . $username . ', nonce=' . $nonce . ', c=' . $c, Minz_Log::WARNING); } @@ -374,6 +412,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Session::_param('currentUser'); Minz_Session::_param('mail'); Minz_Session::_param('passwordHash'); + self::deleteLongTermCookie(); Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); } } diff --git a/sources/app/Controllers/statsController.php b/sources/app/Controllers/statsController.php index 9009468..98f46f0 100755 --- a/sources/app/Controllers/statsController.php +++ b/sources/app/Controllers/statsController.php @@ -4,9 +4,9 @@ class FreshRSS_stats_Controller extends Minz_ActionController { public function indexAction() { $statsDAO = FreshRSS_Factory::createStatsDAO(); - Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); $this->view->repartition = $statsDAO->calculateEntryRepartition(); - $this->view->count = ($statsDAO->calculateEntryCount()); + $this->view->count = $statsDAO->calculateEntryCount(); $this->view->feedByCategory = $statsDAO->calculateFeedByCategory(); $this->view->entryByCategory = $statsDAO->calculateEntryByCategory(); $this->view->topFeed = $statsDAO->calculateTopFeed(); @@ -15,7 +15,13 @@ class FreshRSS_stats_Controller extends Minz_ActionController { public function idleAction() { $statsDAO = FreshRSS_Factory::createStatsDAO(); $feeds = $statsDAO->calculateFeedLastDate(); - $idleFeeds = array(); + $idleFeeds = array( + 'last_year' => array(), + 'last_6_month' => array(), + 'last_3_month' => array(), + 'last_month' => array(), + 'last_week' => array(), + ); $now = new \DateTime(); $feedDate = clone $now; $lastWeek = clone $now; @@ -34,26 +40,37 @@ class FreshRSS_stats_Controller extends Minz_ActionController { if ($feedDate >= $lastWeek) { continue; } - if ($feedDate < $lastWeek) { - $idleFeeds['last_week'][] = $feed['name']; - } - if ($feedDate < $lastMonth) { - $idleFeeds['last_month'][] = $feed['name']; - } - if ($feedDate < $last3Month) { - $idleFeeds['last_3_month'][] = $feed['name']; - } - if ($feedDate < $last6Month) { - $idleFeeds['last_6_month'][] = $feed['name']; - } if ($feedDate < $lastYear) { - $idleFeeds['last_year'][] = $feed['name']; + $idleFeeds['last_year'][] = $feed; + } elseif ($feedDate < $last6Month) { + $idleFeeds['last_6_month'][] = $feed; + } elseif ($feedDate < $last3Month) { + $idleFeeds['last_3_month'][] = $feed; + } elseif ($feedDate < $lastMonth) { + $idleFeeds['last_month'][] = $feed; + } elseif ($feedDate < $lastWeek) { + $idleFeeds['last_week'][] = $feed; } } - $this->view->idleFeeds = array_reverse($idleFeeds); + $this->view->idleFeeds = $idleFeeds; } - + + public function repartitionAction() { + $statsDAO = FreshRSS_Factory::createStatsDAO(); + $categoryDAO = new FreshRSS_CategoryDAO(); + $feedDAO = FreshRSS_Factory::createFeedDao(); + Minz_View::appendScript(Minz_Url::display('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); + $id = Minz_Request::param ('id', null); + $this->view->categories = $categoryDAO->listCategories(); + $this->view->feed = $feedDAO->searchById($id); + $this->view->days = $statsDAO->getDays(); + $this->view->months = $statsDAO->getMonths(); + $this->view->repartitionHour = $statsDAO->calculateEntryRepartitionPerFeedPerHour($id); + $this->view->repartitionDayOfWeek = $statsDAO->calculateEntryRepartitionPerFeedPerDayOfWeek($id); + $this->view->repartitionMonth = $statsDAO->calculateEntryRepartitionPerFeedPerMonth($id); + } + public function firstAction() { if (!$this->view->loginOk) { Minz_Error::error( diff --git a/sources/app/Controllers/usersController.php b/sources/app/Controllers/usersController.php index 35fa367..a9e6c32 100755 --- a/sources/app/Controllers/usersController.php +++ b/sources/app/Controllers/usersController.php @@ -100,7 +100,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { public function createAction() { if (Minz_Request::isPost() && Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) { $db = Minz_Configuration::dataBase(); - require_once(APP_PATH . '/SQL/sql.' . $db['type'] . '.php'); + require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); $new_user_language = Minz_Request::param('new_user_language', $this->view->conf->language); if (!in_array($new_user_language, $this->view->conf->availableLanguages())) { @@ -172,7 +172,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { public function deleteAction() { if (Minz_Request::isPost() && Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) { $db = Minz_Configuration::dataBase(); - require_once(APP_PATH . '/SQL/sql.' . $db['type'] . '.php'); + require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); $username = Minz_Request::param('username'); $ok = ctype_alnum($username); diff --git a/sources/app/FreshRSS.php b/sources/app/FreshRSS.php index 84cf342..30f711e 100755 --- a/sources/app/FreshRSS.php +++ b/sources/app/FreshRSS.php @@ -6,17 +6,49 @@ class FreshRSS extends Minz_FrontController { } $loginOk = $this->accessControl(Minz_Session::param('currentUser', '')); $this->loadParamsView(); + if (Minz_Request::isPost() && (empty($_SERVER['HTTP_REFERER']) || + Minz_Request::getDomainName() !== parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST))) { + $loginOk = false; //Basic protection against XSRF attacks + Minz_Error::error( + 403, + array('error' => array(Minz_Translate::t('access_denied') . ' [HTTP_REFERER=' . + htmlspecialchars(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']) . ']')) + ); + } + Minz_View::_param('loginOk', $loginOk); $this->loadStylesAndScripts($loginOk); //TODO: Do not load that when not needed, e.g. some Ajax requests $this->loadNotifications(); } + private static function getCredentialsFromLongTermCookie() { + $token = Minz_Session::getLongTermCookie('FreshRSS_login'); + if (!ctype_alnum($token)) { + return array(); + } + $tokenFile = DATA_PATH . '/tokens/' . $token . '.txt'; + $mtime = @filemtime($tokenFile); + if ($mtime + 2629744 < time()) { //1 month //TODO: Use a configuration instead + @unlink($tokenFile); + return array(); //Expired or token does not exist + } + $credentials = @file_get_contents($tokenFile); + return $credentials === false ? array() : explode("\t", $credentials, 2); + } + private function accessControl($currentUser) { if ($currentUser == '') { switch (Minz_Configuration::authType()) { case 'form': - $currentUser = Minz_Configuration::defaultUser(); - Minz_Session::_param('passwordHash'); - $loginOk = false; + $credentials = self::getCredentialsFromLongTermCookie(); + if (isset($credentials[1])) { + $currentUser = trim($credentials[0]); + Minz_Session::_param('passwordHash', trim($credentials[1])); + } + $loginOk = $currentUser != ''; + if (!$loginOk) { + $currentUser = Minz_Configuration::defaultUser(); + Minz_Session::_param('passwordHash'); + } break; case 'http_auth': $currentUser = httpAuthUser(); @@ -95,7 +127,6 @@ class FreshRSS extends Minz_FrontController { break; } } - Minz_View::_param ('loginOk', $loginOk); return $loginOk; } @@ -127,13 +158,9 @@ class FreshRSS extends Minz_FrontController { Minz_View::appendScript('https://login.persona.org/include.js'); break; } - $includeLazyLoad = $this->conf->lazyload && ($this->conf->display_posts || Minz_Request::param ('output') === 'reader'); - Minz_View::appendScript (Minz_Url::display ('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')), false, !$includeLazyLoad, !$includeLazyLoad); - if ($includeLazyLoad) { - Minz_View::appendScript (Minz_Url::display ('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js'))); - } - Minz_View::appendScript (Minz_Url::display ('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); - Minz_View::appendScript (Minz_Url::display ('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); } private function loadNotifications () { diff --git a/sources/app/Models/Configuration.php b/sources/app/Models/Configuration.php index 7596c54..4c804a9 100755 --- a/sources/app/Models/Configuration.php +++ b/sources/app/Models/Configuration.php @@ -17,6 +17,8 @@ class FreshRSS_Configuration { 'default_view' => FreshRSS_Entry::STATE_NOT_READ, 'auto_load_more' => true, 'display_posts' => false, + 'display_categories' => false, + 'hide_read_feeds' => true, 'onread_jump_next' => true, 'lazyload' => true, 'sticky_post' => true, @@ -141,6 +143,12 @@ class FreshRSS_Configuration { public function _display_posts ($value) { $this->data['display_posts'] = ((bool)$value) && $value !== 'no'; } + public function _display_categories ($value) { + $this->data['display_categories'] = ((bool)$value) && $value !== 'no'; + } + public function _hide_read_feeds($value) { + $this->data['hide_read_feeds'] = (bool)$value; + } public function _onread_jump_next ($value) { $this->data['onread_jump_next'] = ((bool)$value) && $value !== 'no'; } diff --git a/sources/app/Models/EntryDAO.php b/sources/app/Models/EntryDAO.php index 8c001e7..75a8aeb 100755 --- a/sources/app/Models/EntryDAO.php +++ b/sources/app/Models/EntryDAO.php @@ -17,7 +17,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { } public function addEntry($valuesTmp, $preparedStatement = null) { - $stm = $preparedStatement === null ? addEntryPrepare() : $preparedStatement; + $stm = $preparedStatement === null ? + FreshRSS_EntryDAO::addEntryPrepare() : + $preparedStatement; $values = array( $valuesTmp['id'], @@ -63,7 +65,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { } if (!isset($existingGuids[$entry->guid()]) && - ($feedHistory != 0 || $eDate >= $date_min)) { + ($feedHistory != 0 || $eDate >= $date_min || $entry->isFavorite())) { $values = $entry->toArray(); $useDeclaredDate = empty($existingGuids); @@ -173,7 +175,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { public function markReadEntries($idMax = 0, $onlyFavorites = false, $priorityMin = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record($nb . 'Calling markReadEntries(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::record('Calling markReadEntries(0) is deprecated!', Minz_Log::DEBUG); } $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id ' @@ -201,7 +203,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { public function markReadCat($id, $idMax = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record($nb . 'Calling markReadCat(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::record('Calling markReadCat(0) is deprecated!', Minz_Log::DEBUG); } $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id ' @@ -224,11 +226,11 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { public function markReadFeed($id, $idMax = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record($nb . 'Calling markReadFeed(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::record('Calling markReadFeed(0) is deprecated!', Minz_Log::DEBUG); } $this->bd->beginTransaction(); - $sql = 'UPDATE `' . $this->prefix . 'entry` ' + $sql = 'UPDATE `' . $this->prefix . 'entry` ' . 'SET is_read=1 ' . 'WHERE id_feed=? AND is_read=0 AND id <= ?'; $values = array($id, $idMax); diff --git a/sources/app/Models/EntryDAOSQLite.php b/sources/app/Models/EntryDAOSQLite.php index 3dabce4..9dc395c 100755 --- a/sources/app/Models/EntryDAOSQLite.php +++ b/sources/app/Models/EntryDAOSQLite.php @@ -72,7 +72,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { public function markReadEntries($idMax = 0, $onlyFavorites = false, $priorityMin = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record($nb . 'Calling markReadEntries(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::record('Calling markReadEntries(0) is deprecated!', Minz_Log::DEBUG); } $sql = 'UPDATE `' . $this->prefix . 'entry` SET is_read=1 WHERE is_read=0 AND id <= ?'; @@ -98,7 +98,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { public function markReadCat($id, $idMax = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record($nb . 'Calling markReadCat(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::record('Calling markReadCat(0) is deprecated!', Minz_Log::DEBUG); } $sql = 'UPDATE `' . $this->prefix . 'entry` ' diff --git a/sources/app/Models/Feed.php b/sources/app/Models/Feed.php index 576f377..2a5ea45 100755 --- a/sources/app/Models/Feed.php +++ b/sources/app/Models/Feed.php @@ -28,6 +28,12 @@ class FreshRSS_Feed extends Minz_Model { } } + public static function example() { + $f = new FreshRSS_Feed('http://example.net/', false); + $f->faviconPrepare(); + return $f; + } + public function id() { return $this->id; } @@ -277,11 +283,11 @@ class FreshRSS_Feed extends Minz_Model { $elinks[$elink] = '1'; $mime = strtolower($enclosure->get_type()); if (strpos($mime, 'image/') === 0) { - $content .= '
'; + $content .= '
'; } elseif (strpos($mime, 'audio/') === 0) { - $content .= '