From 6655c1b4299897944dea06309261137a7fa91ad7 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 10 Aug 2014 15:28:54 +0200 Subject: Improve design of actualize notification - Remove progress bar - Show title of updated feed --- app/views/javascript/actualize.phtml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml index d08dc47d1..74cef4998 100644 --- a/app/views/javascript/actualize.phtml +++ b/app/views/javascript/actualize.phtml @@ -1,25 +1,24 @@ "use strict"; -var feeds = [feeds as $feed) { - echo "'", Minz_Url::display(array('c' => 'feed', 'a' => 'actualize', 'params' => array('id' => $feed->id(), 'ajax' => '1')), 'php'), "',\n"; - } - ?>], +var feeds = [feeds as $feed) { ?>{url: " 'feed', 'a' => 'actualize', 'params' => array('id' => $feed->id(), 'ajax' => '1')), 'php'); ?>",title: "name(); ?>"},], feed_processed = 0, feed_count = feeds.length; function initProgressBar(init) { if (init) { $("body").after("\
\ - 0 / " + feed_count + "
\ - \ +
/
\ + 0 / " + feed_count + "\
"); } else { window.location.reload(); } } -function updateProgressBar(i) { - $("#actualizeProgressBar").val(i); +function updateProgressBar(i, title_feed) { $("#actualizeProgress .progress").html(i + " / " + feed_count); + $("#actualizeProgress .title").html(title_feed); } function updateFeeds() { @@ -43,10 +42,10 @@ function updateFeed() { $.ajax({ type: 'POST', - url: feed, + url: feed['url'], }).complete(function (data) { feed_processed++; - updateProgressBar(feed_processed); + updateProgressBar(feed_processed, feed['title']); if (feed_processed === feed_count) { initProgressBar(false); -- cgit v1.2.3 From eceb7756cfcf117c2a18984291181a84697ed3cd Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 10 Aug 2014 20:29:43 +0200 Subject: Add possibility to keep logged in with form Add an option to keep logged in. Change lifetime of session cookie to 1 year. See https://github.com/marienfressinaud/FreshRSS/issues/465 --- app/Controllers/indexController.php | 9 +++++++++ app/i18n/en.php | 1 + app/i18n/fr.php | 1 + app/views/index/formLogin.phtml | 23 +++++++++++++++-------- lib/Minz/Session.php | 35 ++++++++++++++++++++++++++++++----- 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 3119073b8..18b99d0df 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -298,6 +298,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { public function formLoginAction () { if (Minz_Request::isPost()) { $ok = false; + $keep_logged_in = Minz_Request::param('keep_logged_in', false); $nonce = Minz_Session::param('nonce'); $username = Minz_Request::param('username', ''); $c = Minz_Request::param('challenge', ''); @@ -312,6 +313,11 @@ class FreshRSS_index_Controller extends Minz_ActionController { if ($ok) { Minz_Session::_param('currentUser', $username); Minz_Session::_param('passwordHash', $s); + if ($keep_logged_in) { + // New cookie with a lifetime of 1 year! + Minz_Session::keepCookie(31536000); + Minz_Session::regenerateID(); + } } else { Minz_Log::record('Password mismatch for user ' . $username . ', nonce=' . $nonce . ', c=' . $c, Minz_Log::WARNING); } @@ -371,6 +377,9 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Session::_param('currentUser'); Minz_Session::_param('mail'); Minz_Session::_param('passwordHash'); + Minz_Session::keepCookie(0); + Minz_Session::regenerateID(); + Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); } } diff --git a/app/i18n/en.php b/app/i18n/en.php index d80299b10..3c55f62a2 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -3,6 +3,7 @@ return array ( // LAYOUT 'login' => 'Login', + 'keep_logged_in' => 'Keep me logged in', 'login_with_persona' => 'Login with Persona', 'logout' => 'Logout', 'search' => 'Search words or #tags', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 4be028ac3..63d779471 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -3,6 +3,7 @@ return array ( // LAYOUT 'login' => 'Connexion', + 'session_active' => 'Rester connecté', 'login_with_persona' => 'Connexion avec Persona', 'logout' => 'Déconnexion', 'search' => 'Rechercher des mots ou des #tags', diff --git a/app/views/index/formLogin.phtml b/app/views/index/formLogin.phtml index cc925ea59..f01a950b6 100644 --- a/app/views/index/formLogin.phtml +++ b/app/views/index/formLogin.phtml @@ -1,32 +1,39 @@
-

- +
- +
- +
- + +
+
+
+

- - + +

-

+

diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php index ddabc4658..c859be2ed 100644 --- a/lib/Minz/Session.php +++ b/lib/Minz/Session.php @@ -15,13 +15,15 @@ class Minz_Session { * Le nom de session est utilisé comme nom pour les cookies et les URLs (i.e. PHPSESSID). * Il ne doit contenir que des caractères alphanumériques ; il doit être court et descriptif */ - public static function init ($name) { + public static function init($name) { + $cookie = session_get_cookie_params(); + self::keepCookie($cookie['lifetime']); + // démarre la session - session_name ($name); - session_set_cookie_params (0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true); - session_start (); + session_name($name); + session_start(); - if (isset ($_SESSION)) { + if (isset($_SESSION)) { self::$session = $_SESSION; } } @@ -68,4 +70,27 @@ class Minz_Session { Minz_Translate::reset (); } } + + + /** + * Spécifie la durée de vie des cookies + * @param $l la durée de vie + */ + public static function keepCookie($l) { + $cookie_dir = dirname( + empty($_SERVER['SCRIPT_NAME']) ? '' : $_SERVER['SCRIPT_NAME'] + ) . '/'; + session_set_cookie_params($l, $cookie_dir, $_SERVER['HTTP_HOST'], + false, true); + } + + + /** + * Régénère un id de session. + * Utile pour appeler session_set_cookie_params après session_start() + */ + public static function regenerateID() { + session_regenerate_id(true); + } + } -- cgit v1.2.3 From b43733d847ef70c0be55553a1c713c9ce90e8298 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 10 Aug 2014 20:51:49 +0200 Subject: Forget to change the i18n string See https://github.com/marienfressinaud/FreshRSS/issues/465 --- app/i18n/fr.php | 2 +- app/views/index/formLogin.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 63d779471..0607f7c47 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -3,7 +3,7 @@ return array ( // LAYOUT 'login' => 'Connexion', - 'session_active' => 'Rester connecté', + 'keep_logged_in' => 'Rester connecté', 'login_with_persona' => 'Connexion avec Persona', 'logout' => 'Déconnexion', 'search' => 'Rechercher des mots ou des #tags', diff --git a/app/views/index/formLogin.phtml b/app/views/index/formLogin.phtml index f01a950b6..b79c1b614 100644 --- a/app/views/index/formLogin.phtml +++ b/app/views/index/formLogin.phtml @@ -17,7 +17,7 @@

-- cgit v1.2.3 From afa8f92b800bcb8f9187478b0d2528c29279fb1b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 10 Aug 2014 20:54:46 +0200 Subject: Update CHANGELOG Add option to stay logged in --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index d402c7c39..e96a957df 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ * 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. -- cgit v1.2.3 From 93a77f84d45ee4eccda7c837dc08f17360f3de0f Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 10 Aug 2014 21:08:10 +0200 Subject: Change cookie lifetime to 1 month. See https://github.com/marienfressinaud/FreshRSS/issues/465 --- app/Controllers/indexController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 18b99d0df..b907c8eed 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -314,8 +314,8 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Session::_param('currentUser', $username); Minz_Session::_param('passwordHash', $s); if ($keep_logged_in) { - // New cookie with a lifetime of 1 year! - Minz_Session::keepCookie(31536000); + // New cookie with a lifetime of 1 month. + Minz_Session::keepCookie(2592000); Minz_Session::regenerateID(); } } else { -- cgit v1.2.3 From 086bb8df35cf3d9b4de50b7e549f8abbff55635b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 10 Aug 2014 21:59:08 +0200 Subject: Add 1 month indication for "keep me logged in" .prompt .form is also now larger See https://github.com/marienfressinaud/FreshRSS/issues/465 --- app/i18n/en.php | 2 +- app/i18n/fr.php | 2 +- p/themes/Dark/dark.css | 2 +- p/themes/Flat/flat.css | 2 +- p/themes/Origine/origine.css | 2 +- p/themes/Screwdriver/screwdriver.css | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/i18n/en.php b/app/i18n/en.php index 3c55f62a2..748d9a81b 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -3,7 +3,7 @@ return array ( // LAYOUT 'login' => 'Login', - 'keep_logged_in' => 'Keep me logged in', + 'keep_logged_in' => 'Keep me logged in (1 month)', 'login_with_persona' => 'Login with Persona', 'logout' => 'Logout', 'search' => 'Search words or #tags', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 0607f7c47..ba8c8686a 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -3,7 +3,7 @@ return array ( // LAYOUT 'login' => 'Connexion', - 'keep_logged_in' => 'Rester connecté', + 'keep_logged_in' => 'Rester connecté (1 mois)', 'login_with_persona' => 'Connexion avec Persona', 'logout' => 'Déconnexion', 'search' => 'Rechercher des mots ou des #tags', diff --git a/p/themes/Dark/dark.css b/p/themes/Dark/dark.css index 5edc09042..c01cc0dda 100644 --- a/p/themes/Dark/dark.css +++ b/p/themes/Dark/dark.css @@ -570,7 +570,7 @@ a.btn { } .prompt form { margin: 10px auto 20px auto; - width: 180px; + width: 200px; } .prompt input { margin: 5px auto; diff --git a/p/themes/Flat/flat.css b/p/themes/Flat/flat.css index 4ae3e98e9..3e9afb3fd 100644 --- a/p/themes/Flat/flat.css +++ b/p/themes/Flat/flat.css @@ -551,7 +551,7 @@ a.btn { } .prompt form { margin: 10px auto 20px auto; - width: 180px; + width: 200px; } .prompt input { margin: 5px auto; diff --git a/p/themes/Origine/origine.css b/p/themes/Origine/origine.css index 0b95e2d70..efbb9ee64 100644 --- a/p/themes/Origine/origine.css +++ b/p/themes/Origine/origine.css @@ -598,7 +598,7 @@ a.btn { } .prompt form { margin: 10px auto 20px auto; - width: 180px; + width: 200px; } .prompt input { margin: 5px auto; diff --git a/p/themes/Screwdriver/screwdriver.css b/p/themes/Screwdriver/screwdriver.css index 683eece88..addd75851 100644 --- a/p/themes/Screwdriver/screwdriver.css +++ b/p/themes/Screwdriver/screwdriver.css @@ -665,7 +665,7 @@ ul.feeds.active{ } .prompt form { margin: 10px auto 20px auto; - width: 180px; + width: 200px; } .prompt input { margin: 5px auto; -- cgit v1.2.3 From df47217839ccddb8e03015959c61b61e748d9700 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 10 Aug 2014 23:41:36 +0200 Subject: Set session.gc_maxlifetime Take the maxvalue between 1440 (24m) and cookie lifetime when calling Minz_Session::keepCookie() See https://github.com/marienfressinaud/FreshRSS/issues/465 --- lib/Minz/Session.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php index c859be2ed..fb3c5d74b 100644 --- a/lib/Minz/Session.php +++ b/lib/Minz/Session.php @@ -82,6 +82,9 @@ class Minz_Session { ) . '/'; session_set_cookie_params($l, $cookie_dir, $_SERVER['HTTP_HOST'], false, true); + + $l_session = max(1440, $l); + ini_set('session.gc_maxlifetime', $l_session); } -- cgit v1.2.3 From bc71a577fe3154080df9949b394c7ae552773c7b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 11 Aug 2014 18:39:22 +0200 Subject: Revert "Set session.gc_maxlifetime" This reverts commit df47217839ccddb8e03015959c61b61e748d9700. See https://github.com/marienfressinaud/FreshRSS/issues/465 --- lib/Minz/Session.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php index fb3c5d74b..c859be2ed 100644 --- a/lib/Minz/Session.php +++ b/lib/Minz/Session.php @@ -82,9 +82,6 @@ class Minz_Session { ) . '/'; session_set_cookie_params($l, $cookie_dir, $_SERVER['HTTP_HOST'], false, true); - - $l_session = max(1440, $l); - ini_set('session.gc_maxlifetime', $l_session); } -- cgit v1.2.3 From 94570aaf5a23dfc02bf1120d168ec30c2ab3f044 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 11 Aug 2014 19:02:27 +0200 Subject: Improve system import/export Miss checking presence of zip extension during import See https://github.com/marienfressinaud/FreshRSS/issues/494 --- app/Controllers/importExportController.php | 10 +++++++++- app/i18n/en.php | 2 ++ app/i18n/fr.php | 2 ++ app/views/importExport/index.phtml | 4 +++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 2b3353d93..dd6c23322 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -39,7 +39,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { // 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') { + if ($type_file === 'zip' && extension_loaded('zip')) { $zip = zip_open($file['tmp_name']); while (($zipfile = zip_read($zip)) !== false) { @@ -56,6 +56,14 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } zip_close($zip); + } elseif ($type_file === 'zip') { + // Zip extension is not loaded + Minz_Session::_param('notification', array( + 'type' => 'bad', + 'content' => _t('no_zip_extension') + )); + + Minz_Request::forward(array('c' => 'importExport'), true); } elseif ($type_file !== 'unknown') { $list_files[$type_file][] = file_get_contents( $file['tmp_name'] diff --git a/app/i18n/en.php b/app/i18n/en.php index 748d9a81b..0c87f52be 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -182,7 +182,9 @@ return array ( 'focus_search' => 'Access search box', 'file_to_import' => 'File to import
(OPML, Json or Zip)', + 'file_to_import_no_zip' => 'File to import
(OPML or Json)', 'import' => 'Import', + 'no_zip_extension' => 'Zip extension is not present on your server.', 'export' => 'Export', 'export_opml' => 'Export list of feeds (OPML)', 'export_starred' => 'Export your favourites', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index ba8c8686a..57ddebc20 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -182,7 +182,9 @@ return array ( 'focus_search' => 'Accéder à la recherche', 'file_to_import' => 'Fichier à importer
(OPML, Json ou Zip)', + 'file_to_import_no_zip' => 'Fichier à importer
(OPML ou Json)', 'import' => 'Importer', + 'no_zip_extension' => 'L’extension Zip n’est pas présente sur votre serveur.', 'export' => 'Exporter', 'export_opml' => 'Exporter la liste des flux (OPML)', 'export_starred' => 'Exporter les favoris', diff --git a/app/views/importExport/index.phtml b/app/views/importExport/index.phtml index e1458e916..35371faca 100644 --- a/app/views/importExport/index.phtml +++ b/app/views/importExport/index.phtml @@ -6,7 +6,9 @@
- +
-- cgit v1.2.3 From 8ffd59f34ac458827f2a0217e4630caf69705853 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 11 Aug 2014 19:18:12 +0200 Subject: Improve import system Catch errors of zip_open and log it. A notification is shown to indicate something went wrong. See https://github.com/marienfressinaud/FreshRSS/issues/494 --- app/Controllers/importExportController.php | 14 ++++++++++++++ app/i18n/en.php | 1 + app/i18n/fr.php | 1 + 3 files changed, 16 insertions(+) diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index dd6c23322..15871ed80 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -42,6 +42,20 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { if ($type_file === 'zip' && extension_loaded('zip')) { $zip = zip_open($file['tmp_name']); + if (!is_resource($zip)) { + Minz_Log::error( + 'Zip file cannot be imported. Error code: ' . $zip + ); + + // zip_open cannot open file: something is wrong + Minz_Session::_param('notification', array( + 'type' => 'bad', + 'content' => _t('zip_error') + )); + + Minz_Request::forward(array('c' => 'importExport'), true); + } + while (($zipfile = zip_read($zip)) !== false) { $type_zipfile = $this->guessFileType( zip_entry_name($zipfile) diff --git a/app/i18n/en.php b/app/i18n/en.php index 0c87f52be..416ca851f 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -184,6 +184,7 @@ return array ( 'file_to_import' => 'File to import
(OPML, Json or Zip)', 'file_to_import_no_zip' => 'File to import
(OPML or Json)', 'import' => 'Import', + 'zip_error' => 'An error occured during Zip import.', 'no_zip_extension' => 'Zip extension is not present on your server.', 'export' => 'Export', 'export_opml' => 'Export list of feeds (OPML)', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 57ddebc20..d68006a87 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -184,6 +184,7 @@ return array ( 'file_to_import' => 'Fichier à importer
(OPML, Json ou Zip)', 'file_to_import_no_zip' => 'Fichier à importer
(OPML ou Json)', 'import' => 'Importer', + 'zip_error' => 'Une erreur est survenue durant l’import du fichier Zip.', 'no_zip_extension' => 'L’extension Zip n’est pas présente sur votre serveur.', 'export' => 'Exporter', 'export_opml' => 'Exporter la liste des flux (OPML)', -- cgit v1.2.3 From 3674a7a7644853fbb52000d5e687d5df8983e051 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 11 Aug 2014 21:26:57 +0200 Subject: gitignore /p/i/.htaccess This can be the place of a user's .htaccess, for instance for HTTP password control. --- p/i/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 p/i/.gitignore diff --git a/p/i/.gitignore b/p/i/.gitignore new file mode 100644 index 000000000..03c88fd7a --- /dev/null +++ b/p/i/.gitignore @@ -0,0 +1 @@ +.htaccess -- cgit v1.2.3 From 1b20f6bd025a08a7a741b2751d837f736758eb2d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 20:59:27 +0200 Subject: New wrappers Minz_Request::good() and bad() 1. Set a notification message in session variable 2. Redirect to a specific url First use in importExportController.php See https://github.com/marienfressinaud/FreshRSS/conversations/576 --- app/Controllers/importExportController.php | 57 ++++++------------------------ lib/Minz/Request.php | 25 +++++++++++++ 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 15871ed80..92b39b575 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -43,17 +43,9 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $zip = zip_open($file['tmp_name']); if (!is_resource($zip)) { - Minz_Log::error( - 'Zip file cannot be imported. Error code: ' . $zip - ); - // zip_open cannot open file: something is wrong - Minz_Session::_param('notification', array( - 'type' => 'bad', - 'content' => _t('zip_error') - )); - - Minz_Request::forward(array('c' => 'importExport'), true); + Minz_Log::error('Zip file cannot be imported. Error code: ' . $zip); + Minz_Request::bad(_t('zip_error'), array('c' => 'importExport')); } while (($zipfile = zip_read($zip)) !== false) { @@ -72,12 +64,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { zip_close($zip); } elseif ($type_file === 'zip') { // Zip extension is not loaded - Minz_Session::_param('notification', array( - 'type' => 'bad', - 'content' => _t('no_zip_extension') - )); - - Minz_Request::forward(array('c' => 'importExport'), true); + Minz_Request::bad(_t('no_zip_extension'), array('c' => 'importExport')); } elseif ($type_file !== 'unknown') { $list_files[$type_file][] = file_get_contents( $file['tmp_name'] @@ -100,35 +87,16 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } // 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); + $content_notif = $error === true ? _t('feeds_imported_with_errors') : + _t('feeds_imported'); + Minz_Request::good($content_notif); } // What are you doing? you have to call this controller // with a POST request! - Minz_Request::forward(array( - 'c' => 'importExport', - 'a' => 'index' - )); + Minz_Request::forward(array('c' => 'importExport')); } private function guessFileType($filename) { @@ -362,17 +330,12 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $nb_files = count($export_files); if ($nb_files > 1) { - // If there are more than 1 file to export, we need an .zip + // 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! - $notif = array( - 'type' => 'bad', - 'content' => _t('export_no_zip_extension') - ); - Minz_Session::_param('notification', $notif); - Minz_Request::forward(array('c' => 'importExport'), true); + Minz_Request::bad(_t('export_no_zip_extension'), array('c' => 'importExport')); } } elseif ($nb_files === 1) { // Only one file? Guess its type and export it. @@ -386,7 +349,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->exportFile($filename, $export_files[$filename], $type); } else { - Minz_Request::forward(array('c' => 'importExport'), true); + Minz_Request::forward(array('c' => 'importExport')); } } } diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 755784522..2f745a04c 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -146,6 +146,31 @@ class Minz_Request { } } + + /** + * Wrappers good notifications + redirection + * @param $msg notification content + * @param $url url array to where we should be forwarded + */ + public static function good($msg, $url = array()) { + Minz_Session::_param('notification', array( + 'type' => 'good', + 'content' => $msg + )); + + Minz_Request::forward($url, true); + } + + public static function bad($msg, $url = array()) { + Minz_Session::_param('notification', array( + 'type' => 'bad', + 'content' => $msg + )); + + Minz_Request::forward($url, true); + } + + /** * Permet de récupérer une variable de type $_GET * @param $param nom de la variable -- cgit v1.2.3 From ed7d8aa44fe5a005380056b7d164fc53079506fb Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 21:04:39 +0200 Subject: Use REQUEST_URI instead of SCRIPT_NAME for cookies See https://github.com/marienfressinaud/FreshRSS/commit/eceb7756cfcf117c2a18984291181a84697ed3cd#commitcomment-7345438 --- lib/Minz/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php index c859be2ed..efc8332e5 100644 --- a/lib/Minz/Session.php +++ b/lib/Minz/Session.php @@ -78,7 +78,7 @@ class Minz_Session { */ public static function keepCookie($l) { $cookie_dir = dirname( - empty($_SERVER['SCRIPT_NAME']) ? '' : $_SERVER['SCRIPT_NAME'] + empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'] ) . '/'; session_set_cookie_params($l, $cookie_dir, $_SERVER['HTTP_HOST'], false, true); -- cgit v1.2.3 From 08a9009c19b2ae84555340622c344a2da38ae019 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 21:09:13 +0200 Subject: Fix a Minz_Session TODO Not use additional variable to manipulate session variables Fix coding style --- lib/Minz/Session.php | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php index efc8332e5..906acc03c 100644 --- a/lib/Minz/Session.php +++ b/lib/Minz/Session.php @@ -2,17 +2,11 @@ /** * La classe Session gère la session utilisateur - * C'est un singleton */ class Minz_Session { - /** - * $session stocke les variables de session - */ - private static $session = array (); //TODO: Try to avoid having another local copy - /** * Initialise la session, avec un nom - * Le nom de session est utilisé comme nom pour les cookies et les URLs (i.e. PHPSESSID). + * Le nom de session est utilisé comme nom pour les cookies et les URLs(i.e. PHPSESSID). * Il ne doit contenir que des caractères alphanumériques ; il doit être court et descriptif */ public static function init($name) { @@ -22,10 +16,6 @@ class Minz_Session { // démarre la session session_name($name); session_start(); - - if (isset($_SESSION)) { - self::$session = $_SESSION; - } } @@ -34,8 +24,8 @@ class Minz_Session { * @param $p le paramètre à récupérer * @return la valeur de la variable de session, false si n'existe pas */ - public static function param ($p, $default = false) { - return isset(self::$session[$p]) ? self::$session[$p] : $default; + public static function param($p, $default = false) { + return isset($_SESSION[$p]) ? $_SESSION[$p] : $default; } @@ -44,13 +34,11 @@ class Minz_Session { * @param $p le paramètre à créer ou modifier * @param $v la valeur à attribuer, false pour supprimer */ - public static function _param ($p, $v = false) { + public static function _param($p, $v = false) { if ($v === false) { - unset ($_SESSION[$p]); - unset (self::$session[$p]); + unset($_SESSION[$p]); } else { $_SESSION[$p] = $v; - self::$session[$p] = $v; } } @@ -59,15 +47,15 @@ class Minz_Session { * Permet d'effacer une session * @param $force si à false, n'efface pas le paramètre de langue */ - public static function unset_session ($force = false) { - $language = self::param ('language'); + public static function unset_session($force = false) { + $language = self::param('language'); session_destroy(); - self::$session = array (); + $_SESSION = array(); if (!$force) { - self::_param ('language', $language); - Minz_Translate::reset (); + self::_param('language', $language); + Minz_Translate::reset(); } } -- cgit v1.2.3 From 22e2bf9239c3c5ee87a59910d88107ff359b24df Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 21:12:02 +0200 Subject: Fix coding style of Minz_Request --- lib/Minz/Request.php | 84 ++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 2f745a04c..f9b8e2564 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -10,7 +10,7 @@ class Minz_Request { private static $controller_name = ''; private static $action_name = ''; - private static $params = array (); + private static $params = array(); private static $default_controller_name = 'index'; private static $default_action_name = 'index'; @@ -18,25 +18,25 @@ class Minz_Request { /** * Getteurs */ - public static function controllerName () { + public static function controllerName() { return self::$controller_name; } - public static function actionName () { + public static function actionName() { return self::$action_name; } - public static function params () { + public static function params() { return self::$params; } - static function htmlspecialchars_utf8 ($p) { + static function htmlspecialchars_utf8($p) { if (is_array($p)) { return array_map('self::htmlspecialchars_utf8', $p); } return htmlspecialchars($p, ENT_COMPAT, 'UTF-8'); } - public static function param ($key, $default = false, $specialchars = false) { - if (isset (self::$params[$key])) { + public static function param($key, $default = false, $specialchars = false) { + if (isset(self::$params[$key])) { $p = self::$params[$key]; - if(is_object($p) || $specialchars) { + if (is_object($p) || $specialchars) { return $p; } else { return self::htmlspecialchars_utf8($p); @@ -45,32 +45,32 @@ class Minz_Request { return $default; } } - public static function defaultControllerName () { + public static function defaultControllerName() { return self::$default_controller_name; } - public static function defaultActionName () { + public static function defaultActionName() { return self::$default_action_name; } /** * Setteurs */ - public static function _controllerName ($controller_name) { + public static function _controllerName($controller_name) { self::$controller_name = $controller_name; } - public static function _actionName ($action_name) { + public static function _actionName($action_name) { self::$action_name = $action_name; } - public static function _params ($params) { + public static function _params($params) { if (!is_array($params)) { - $params = array ($params); + $params = array($params); } self::$params = $params; } - public static function _param ($key, $value = false) { + public static function _param($key, $value = false) { if ($value === false) { - unset (self::$params[$key]); + unset(self::$params[$key]); } else { self::$params[$key] = $value; } @@ -79,14 +79,14 @@ class Minz_Request { /** * Initialise la Request */ - public static function init () { - self::magicQuotesOff (); + public static function init() { + self::magicQuotesOff(); } /** * Retourn le nom de domaine du site */ - public static function getDomainName () { + public static function getDomainName() { return $_SERVER['HTTP_HOST']; } @@ -94,7 +94,7 @@ class Minz_Request { * Détermine la base de l'url * @return la base de l'url */ - public static function getBaseUrl () { + public static function getBaseUrl() { $defaultBaseUrl = Minz_Configuration::baseUrl(); if (!empty($defaultBaseUrl)) { return $defaultBaseUrl; @@ -109,13 +109,13 @@ class Minz_Request { * Récupère l'URI de la requête * @return l'URI */ - public static function getURI () { - if (isset ($_SERVER['REQUEST_URI'])) { - $base_url = self::getBaseUrl (); + public static function getURI() { + if (isset($_SERVER['REQUEST_URI'])) { + $base_url = self::getBaseUrl(); $uri = $_SERVER['REQUEST_URI']; - $len_base_url = strlen ($base_url); - $real_uri = substr ($uri, $len_base_url); + $len_base_url = strlen($base_url); + $real_uri = substr($uri, $len_base_url); } else { $real_uri = ''; } @@ -129,16 +129,16 @@ class Minz_Request { * @param $redirect si vrai, force la redirection http * > sinon, le dispatcher recharge en interne */ - public static function forward ($url = array (), $redirect = false) { - $url = Minz_Url::checkUrl ($url); + public static function forward($url = array(), $redirect = false) { + $url = Minz_Url::checkUrl($url); if ($redirect) { - header ('Location: ' . Minz_Url::display ($url, 'php')); - exit (); + header('Location: ' . Minz_Url::display($url, 'php')); + exit(); } else { - self::_controllerName ($url['c']); - self::_actionName ($url['a']); - self::_params (array_merge ( + self::_controllerName($url['c']); + self::_actionName($url['a']); + self::_params(array_merge( self::$params, $url['params'] )); @@ -179,10 +179,10 @@ class Minz_Request { * $_GET si $param = false * $default si $_GET[$param] n'existe pas */ - public static function fetchGET ($param = false, $default = false) { + public static function fetchGET($param = false, $default = false) { if ($param === false) { return $_GET; - } elseif (isset ($_GET[$param])) { + } elseif (isset($_GET[$param])) { return $_GET[$param]; } else { return $default; @@ -197,10 +197,10 @@ class Minz_Request { * $_POST si $param = false * $default si $_POST[$param] n'existe pas */ - public static function fetchPOST ($param = false, $default = false) { + public static function fetchPOST($param = false, $default = false) { if ($param === false) { return $_POST; - } elseif (isset ($_POST[$param])) { + } elseif (isset($_POST[$param])) { return $_POST[$param]; } else { return $default; @@ -213,15 +213,15 @@ class Minz_Request { * $_POST * $_COOKIE */ - private static function magicQuotesOff () { - if (get_magic_quotes_gpc ()) { - $_GET = Minz_Helper::stripslashes_r ($_GET); - $_POST = Minz_Helper::stripslashes_r ($_POST); - $_COOKIE = Minz_Helper::stripslashes_r ($_COOKIE); + private static function magicQuotesOff() { + if (get_magic_quotes_gpc()) { + $_GET = Minz_Helper::stripslashes_r($_GET); + $_POST = Minz_Helper::stripslashes_r($_POST); + $_COOKIE = Minz_Helper::stripslashes_r($_COOKIE); } } - public static function isPost () { + public static function isPost() { return $_SERVER['REQUEST_METHOD'] === 'POST'; } } -- cgit v1.2.3 From ede94098be5d330d4bf120eb8064c5c87eed7ef0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 21:15:12 +0200 Subject: Fix missing REQUEST_METHOD Useful when executing actualize_script.php --- lib/Minz/Request.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index f9b8e2564..f3ecaf55c 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -222,6 +222,7 @@ class Minz_Request { } public static function isPost() { - return $_SERVER['REQUEST_METHOD'] === 'POST'; + return isset($_SERVER['REQUEST_METHOD']) && + $_SERVER['REQUEST_METHOD'] === 'POST'; } } -- cgit v1.2.3 From 7900c5e550acafaf0b877635840a8a270eb06078 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 21:56:34 +0200 Subject: Move htmlspecialchars_utf8 from Request to Helper And remove html_chars_utf8 to use htmlspecialchars_utf8 instead in importExportController --- app/Controllers/importExportController.php | 10 +++++----- lib/Minz/Helper.php | 11 +++++++++++ lib/Minz/Request.php | 8 +------- lib/lib_rss.php | 4 ---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 92b39b575..a8e2c2bc2 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -166,15 +166,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; @@ -200,7 +200,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); diff --git a/lib/Minz/Helper.php b/lib/Minz/Helper.php index b058211d3..13bfdd93e 100644 --- a/lib/Minz/Helper.php +++ b/lib/Minz/Helper.php @@ -19,4 +19,15 @@ class Minz_Helper { return stripslashes($var); } } + + /** + * Wrapper for htmlspecialchars. + * Force UTf-8 value and can be used on array too. + */ + public static function htmlspecialchars_utf8($p) { + if (is_array($p)) { + return array_map('self::htmlspecialchars_utf8', $p); + } + return htmlspecialchars($p, ENT_COMPAT, 'UTF-8'); + } } diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index f3ecaf55c..52f53012f 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -27,19 +27,13 @@ class Minz_Request { public static function params() { return self::$params; } - static function htmlspecialchars_utf8($p) { - if (is_array($p)) { - return array_map('self::htmlspecialchars_utf8', $p); - } - return htmlspecialchars($p, ENT_COMPAT, 'UTF-8'); - } public static function param($key, $default = false, $specialchars = false) { if (isset(self::$params[$key])) { $p = self::$params[$key]; if (is_object($p) || $specialchars) { return $p; } else { - return self::htmlspecialchars_utf8($p); + return Minz_Helper::htmlspecialchars_utf8($p); } } else { return $default; diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 86c0a4ae4..823f53716 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -230,7 +230,3 @@ function cryptAvailable() { } return false; } - -function html_chars_utf8($str) { - return htmlspecialchars($str, ENT_COMPAT, 'UTF-8'); -} -- cgit v1.2.3 From 93b2a5f240b061103fce5cf563a3cd5cae2c6bfe Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 21:59:07 +0200 Subject: Coding style in Minz_Helper --- lib/Minz/Helper.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Minz/Helper.php b/lib/Minz/Helper.php index 13bfdd93e..8d8b177ae 100644 --- a/lib/Minz/Helper.php +++ b/lib/Minz/Helper.php @@ -12,9 +12,9 @@ class Minz_Helper { * Annule les effets des magic_quotes pour une variable donnée * @param $var variable à traiter (tableau ou simple variable) */ - public static function stripslashes_r ($var) { - if (is_array ($var)){ - return array_map (array ('Helper', 'stripslashes_r'), $var); + public static function stripslashes_r($var) { + if (is_array($var)){ + return array_map(array('Helper', 'stripslashes_r'), $var); } else { return stripslashes($var); } @@ -24,10 +24,10 @@ class Minz_Helper { * Wrapper for htmlspecialchars. * Force UTf-8 value and can be used on array too. */ - public static function htmlspecialchars_utf8($p) { - if (is_array($p)) { - return array_map('self::htmlspecialchars_utf8', $p); + public static function htmlspecialchars_utf8($var) { + if (is_array($var)) { + return array_map(array('Helper', 'htmlspecialchars_utf8'), $var); } - return htmlspecialchars($p, ENT_COMPAT, 'UTF-8'); + return htmlspecialchars($var, ENT_COMPAT, 'UTF-8'); } } -- cgit v1.2.3 From f2b1826b475a7ad71ee68b13d22c03259e631195 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 22:27:07 +0200 Subject: Fix missing Minz_ prefix in Minz_Helper Nice bug :) It means another hidden bug is now corrected! --- lib/Minz/Helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Minz/Helper.php b/lib/Minz/Helper.php index 8d8b177ae..f4a547c4e 100644 --- a/lib/Minz/Helper.php +++ b/lib/Minz/Helper.php @@ -14,7 +14,7 @@ class Minz_Helper { */ public static function stripslashes_r($var) { if (is_array($var)){ - return array_map(array('Helper', 'stripslashes_r'), $var); + return array_map(array('Minz_Helper', 'stripslashes_r'), $var); } else { return stripslashes($var); } @@ -26,7 +26,7 @@ class Minz_Helper { */ public static function htmlspecialchars_utf8($var) { if (is_array($var)) { - return array_map(array('Helper', 'htmlspecialchars_utf8'), $var); + return array_map(array('Minz_Helper', 'htmlspecialchars_utf8'), $var); } return htmlspecialchars($var, ENT_COMPAT, 'UTF-8'); } -- cgit v1.2.3 From 775ff40780935471dcd74b0d81c04b80e3e4603c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 12 Aug 2014 22:55:43 +0200 Subject: Improve import system Catch more errors Code refactoring --- app/Controllers/importExportController.php | 125 ++++++++++++++++------------- app/i18n/en.php | 1 + app/i18n/fr.php | 1 + 3 files changed, 70 insertions(+), 57 deletions(-) diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index a8e2c2bc2..c7f47fc13 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -24,35 +24,49 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } public function importAction() { - if (Minz_Request::isPost() && $_FILES['file']['error'] == 0) { - @set_time_limit(300); + if (!Minz_Request::isPost()) { + // What are you doing? you have to call this controller + // with a POST request! + 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 imported. Error code: ' . $status_file); + Minz_Request::bad(_t('file_cannot_be_imported'), + 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' && extension_loaded('zip')) { - $zip = zip_open($file['tmp_name']); + @set_time_limit(300); - if (!is_resource($zip)) { - // zip_open cannot open file: something is wrong - Minz_Log::error('Zip file cannot be imported. Error code: ' . $zip); - Minz_Request::bad(_t('zip_error'), array('c' => 'importExport')); - } + $type_file = $this->guessFileType($file['name']); - while (($zipfile = zip_read($zip)) !== false) { - $type_zipfile = $this->guessFileType( - zip_entry_name($zipfile) - ); + $list_files = array( + 'opml' => array(), + 'json_starred' => array(), + 'json_feed' => array() + ); + // 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' && 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')); + } + + 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, @@ -60,43 +74,39 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { ); } } - - zip_close($zip); - } elseif ($type_file === 'zip') { - // Zip extension is not loaded - Minz_Request::bad(_t('no_zip_extension'), array('c' => 'importExport')); - } 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 - Minz_Session::_param('actualize_feeds', true); + zip_close($zip); + } elseif ($type_file === 'zip') { + // Zip extension is not loaded + Minz_Request::bad(_t('no_zip_extension'), array('c' => 'importExport')); + } elseif ($type_file !== 'unknown') { + $list_files[$type_file][] = file_get_contents( + $file['tmp_name'] + ); + } - $content_notif = $error === true ? _t('feeds_imported_with_errors') : - _t('feeds_imported'); - Minz_Request::good($content_notif); + // 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 + Minz_Session::_param('actualize_feeds', true); - // What are you doing? you have to call this controller - // with a POST request! - Minz_Request::forward(array('c' => 'importExport')); + $content_notif = $error === true ? _t('feeds_imported_with_errors') : + _t('feeds_imported'); + Minz_Request::good($content_notif); } private function guessFileType($filename) { @@ -335,7 +345,8 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->exportZip($export_files); } catch (Exception $e) { # Oops, there is no Zip extension! - Minz_Request::bad(_t('export_no_zip_extension'), array('c' => 'importExport')); + 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. @@ -349,7 +360,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->exportFile($filename, $export_files[$filename], $type); } else { - Minz_Request::forward(array('c' => 'importExport')); + Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); } } } diff --git a/app/i18n/en.php b/app/i18n/en.php index 416ca851f..f4a15e747 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -184,6 +184,7 @@ return array ( 'file_to_import' => 'File to import
(OPML, Json or Zip)', 'file_to_import_no_zip' => 'File to import
(OPML or Json)', 'import' => 'Import', + 'file_cannot_be_uploaded' => 'File cannot be uploaded!', 'zip_error' => 'An error occured during Zip import.', 'no_zip_extension' => 'Zip extension is not present on your server.', 'export' => 'Export', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index d68006a87..4675e17ee 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -184,6 +184,7 @@ return array ( 'file_to_import' => 'Fichier à importer
(OPML, Json ou Zip)', 'file_to_import_no_zip' => 'Fichier à importer
(OPML ou Json)', 'import' => 'Importer', + 'file_cannot_be_uploaded' => 'Le fichier ne peut pas être téléchargé!', 'zip_error' => 'Une erreur est survenue durant l’import du fichier Zip.', 'no_zip_extension' => 'L’extension Zip n’est pas présente sur votre serveur.', 'export' => 'Exporter', -- cgit v1.2.3 From ee1b8f6f72e8c2cbd3e0ad7b4322a4bb6863c028 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 13 Aug 2014 00:09:48 +0200 Subject: Long term cookie to keep session open Token system https://github.com/marienfressinaud/FreshRSS/issues/465 --- app/Controllers/indexController.php | 41 +++++++++++++++++++++++++++++-------- app/FreshRSS.php | 28 ++++++++++++++++++++++--- data/tokens/.gitignore | 1 + data/tokens/index.html | 13 ++++++++++++ lib/Minz/Session.php | 19 ++++++++++++----- 5 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 data/tokens/.gitignore create mode 100644 data/tokens/index.html diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index b907c8eed..dd5b91e47 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -295,10 +295,39 @@ 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() { + //TODO: Delete old token files + } + public function formLoginAction () { if (Minz_Request::isPost()) { $ok = false; - $keep_logged_in = Minz_Request::param('keep_logged_in', false); $nonce = Minz_Session::param('nonce'); $username = Minz_Request::param('username', ''); $c = Minz_Request::param('challenge', ''); @@ -313,10 +342,8 @@ class FreshRSS_index_Controller extends Minz_ActionController { if ($ok) { Minz_Session::_param('currentUser', $username); Minz_Session::_param('passwordHash', $s); - if ($keep_logged_in) { - // New cookie with a lifetime of 1 month. - Minz_Session::keepCookie(2592000); - Minz_Session::regenerateID(); + if (Minz_Request::param('keep_logged_in', false)) { + self::makeLongTermCookie($username, $s); } } else { Minz_Log::record('Password mismatch for user ' . $username . ', nonce=' . $nonce . ', c=' . $c, Minz_Log::WARNING); @@ -377,9 +404,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Session::_param('currentUser'); Minz_Session::_param('mail'); Minz_Session::_param('passwordHash'); - Minz_Session::keepCookie(0); - Minz_Session::regenerateID(); - + self::deleteLongTermCookie(); Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); } } diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 7c333b090..30f711e20 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -20,13 +20,35 @@ class FreshRSS extends Minz_FrontController { $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(); diff --git a/data/tokens/.gitignore b/data/tokens/.gitignore new file mode 100644 index 000000000..2211df63d --- /dev/null +++ b/data/tokens/.gitignore @@ -0,0 +1 @@ +*.txt diff --git a/data/tokens/index.html b/data/tokens/index.html new file mode 100644 index 000000000..85faaa37e --- /dev/null +++ b/data/tokens/index.html @@ -0,0 +1,13 @@ + + + + + +Redirection + + + + +

Redirection

+ + diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php index 906acc03c..af4de75bb 100644 --- a/lib/Minz/Session.php +++ b/lib/Minz/Session.php @@ -65,11 +65,8 @@ class Minz_Session { * @param $l la durée de vie */ public static function keepCookie($l) { - $cookie_dir = dirname( - empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'] - ) . '/'; - session_set_cookie_params($l, $cookie_dir, $_SERVER['HTTP_HOST'], - false, true); + $cookie_dir = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI']; + session_set_cookie_params($l, $cookie_dir, '', false, true); } @@ -81,4 +78,16 @@ class Minz_Session { session_regenerate_id(true); } + public static function deleteLongTermCookie($name) { + setcookie($name, '', 1, '', '', false, true); + } + + public static function setLongTermCookie($name, $value, $expire) { + setcookie($name, $value, $expire, '', '', false, true); + } + + public static function getLongTermCookie($name) { + return isset($_COOKIE[$name]) ? $_COOKIE[$name] : null; + } + } -- cgit v1.2.3 From 359ccc8e4c20a60506c680e5054dbe8416fef4a9 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 13 Aug 2014 00:25:52 +0200 Subject: Long term cookie minor change https://github.com/marienfressinaud/FreshRSS/issues/465 --- app/Controllers/indexController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index dd5b91e47..834db496c 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -344,6 +344,8 @@ class FreshRSS_index_Controller extends Minz_ActionController { 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); -- cgit v1.2.3 From 5c2f3349fa4341533aad6294c896b32c4befd58f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 13 Aug 2014 20:09:23 +0200 Subject: Long term cookie: purge old tokens https://github.com/marienfressinaud/FreshRSS/issues/465 --- app/Controllers/indexController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 834db496c..9202f2b85 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -322,7 +322,12 @@ class FreshRSS_index_Controller extends Minz_ActionController { } private static function purgeTokens() { - //TODO: Delete old token files + $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 () { -- cgit v1.2.3 From 0f1133ddfe8e3967470ea50f235e12ad04dc71a7 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 17 Aug 2014 21:03:01 +0200 Subject: Fix some forward() actions See https://github.com/marienfressinaud/FreshRSS/issues/494 --- app/Controllers/importExportController.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index c7f47fc13..2f5fcc137 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -34,8 +34,8 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $status_file = $file['error']; if ($status_file !== 0) { - Minz_Log::error('File cannot be imported. Error code: ' . $status_file); - Minz_Request::bad(_t('file_cannot_be_imported'), + Minz_Log::error('File cannot be uploaded. Error code: ' . $status_file); + Minz_Request::bad(_t('file_cannot_be_uploaded'), array('c' => 'importExport', 'a' => 'index')); } @@ -50,7 +50,6 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { ); // 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' && extension_loaded('zip')) { $zip = zip_open($file['tmp_name']); @@ -58,7 +57,8 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { 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')); + Minz_Request::bad(_t('zip_error'), + array('c' => 'importExport', 'a' => 'index')); } while (($zipfile = zip_read($zip)) !== false) { @@ -79,14 +79,13 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { zip_close($zip); } elseif ($type_file === 'zip') { // Zip extension is not loaded - Minz_Request::bad(_t('no_zip_extension'), array('c' => 'importExport')); + 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'] - ); + $list_files[$type_file][] = file_get_contents($file['tmp_name']); } - // Import different files. + // 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. @@ -103,7 +102,6 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { // 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); -- cgit v1.2.3 From e3bb80de17c79cf32a2e3a606f216aebf48f92e5 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 17 Aug 2014 22:14:13 +0200 Subject: Refactor import / export source code See https://github.com/marienfressinaud/FreshRSS/issues/494 --- app/Controllers/importExportController.php | 107 ++++++++++++++--------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 2f5fcc137..2197c3af5 100644 --- a/app/Controllers/importExportController.php +++ b/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,13 +20,11 @@ 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()) { - // What are you doing? you have to call this controller - // with a POST request! Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); } @@ -309,57 +307,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', array ()); + $this->view->_useLayout(false); - $export_files = array (); - if ($export_opml) { - $export_files['feeds.opml'] = $this->generateOpml(); - } + $export_opml = Minz_Request::param('export_opml', false); + $export_starred = Minz_Request::param('export_starred', false); + $export_feeds = Minz_Request::param('export_feeds', array()); - if ($export_starred) { - $export_files['starred.json'] = $this->generateArticles('starred'); - } + $export_files = array(); + if ($export_opml) { + $export_files['feeds.opml'] = $this->generateOpml(); + } - 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 - ); - } - } + if ($export_starred) { + $export_files['starred.json'] = $this->generateArticles('starred'); + } - $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 = null; - if (substr_compare($filename, '.opml', -5) === 0) { - $type = "text/xml"; - } elseif (substr_compare($filename, '.json', -5) === 0) { - $type = "text/json"; - } + 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 + ); + } + } - $this->exportFile($filename, $export_files[$filename], $type); - } else { - Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); + $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); } } @@ -378,7 +372,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( @@ -386,9 +380,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', @@ -424,11 +416,18 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } private function exportFile($filename, $content, $type) { - if (is_null($type)) { + if ($type === 'unknown') { return; } - header('Content-Type: ' . $type . '; charset=utf-8'); + $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); } -- cgit v1.2.3 From 393fce3e8aaef1b00ab34bf35b7e8b329a5e3dc5 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Tue, 19 Aug 2014 08:55:44 -0400 Subject: Add a feed selector in repartition statistics. Before we could choose the feed in the statistics only from the feed options in the main view. Now with the new drop-down list, it is possible to choose it from the statistics page. The rendering needs to be polished to be nicer. --- app/Controllers/statsController.php | 2 ++ app/views/stats/repartition.phtml | 39 +++++++++++++++++++++++++------------ p/scripts/main.js | 7 +++++++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 06a20c2a6..934b076a5 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -58,9 +58,11 @@ class FreshRSS_stats_Controller extends Minz_ActionController { 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(); diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml index 09892d3c5..3dc319731 100644 --- a/app/views/stats/repartition.phtml +++ b/app/views/stats/repartition.phtml @@ -2,23 +2,38 @@
- + +

+ + + feed) {?> -

- - - feed->name(); ?> - -

- -

+ + + - +

- +

@@ -93,7 +108,7 @@ function initStats() { yaxis: {min: 0}, mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}} }); - + } initStats(); diff --git a/p/scripts/main.js b/p/scripts/main.js index ae7b69364..4802e0941 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1063,6 +1063,12 @@ function init_share_observers() { }); } +function init_stats_observers() { + $('#feed_select').on('change', function(e) { + redirect($(this).find(':selected').data('url')); + }); +} + function init_remove_observers() { $('.post').on('click', 'a.remove', function(e) { var remove_what = $(this).attr('data-remove'); @@ -1177,6 +1183,7 @@ function init_all() { init_remove_observers(); init_feed_observers(); init_password_observers(); + init_stats_observers(); } if (window.console) { -- cgit v1.2.3 From 50075bfbdcd6a7be010eb82ce1fffac0ea283de7 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 19 Aug 2014 20:58:18 +0200 Subject: Improvement for ASC order https://github.com/marienfressinaud/FreshRSS/issues/495 --- app/Models/EntryDAO.php | 2 +- app/layout/nav_menu.phtml | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index a9ffa138b..488b70fb6 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -230,7 +230,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { } $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/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 73a921c5d..25833c16d 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -164,11 +164,15 @@ break; } } - if ($this->order === 'ASC') { - $idMax = 0; - } else { - $p = isset($this->entries[0]) ? $this->entries[0] : null; - $idMax = $p === null ? '0' : $p->id(); + + $p = isset($this->entries[0]) ? $this->entries[0] : null; + $idMax = $p === null ? (time() - 1) . '000000' : $p->id(); + + if ($this->order === 'ASC') { //In this case we do not know but we guess idMax + $idMax2 = (time() - 1) . '000000'; + if (strcmp($idMax2, $idMax) > 0) { + $idMax = $idMax2; + } } $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('get' => $get, 'nextGet' => $nextGet, 'idMax' => $idMax)); -- cgit v1.2.3 From 0d0b8cd39b8de765aa351a2e66fff850bdcb2000 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 19 Aug 2014 21:39:45 +0200 Subject: Error when feed does not exist https://github.com/marienfressinaud/FreshRSS/issues/579 --- app/Models/Feed.php | 6 ++++++ app/views/helpers/view/normal_view.phtml | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Models/Feed.php b/app/Models/Feed.php index fe1e52ea2..2a5ea45ac 100644 --- a/app/Models/Feed.php +++ b/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; } diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml index 55ef6bdf6..87bf2e22a 100644 --- a/app/views/helpers/view/normal_view.phtml +++ b/app/views/helpers/view/normal_view.phtml @@ -81,7 +81,12 @@ if (!empty($this->entries)) { } } $feed = FreshRSS_CategoryDAO::findFeed($this->cat_aside, $item->feed ()); //We most likely already have the feed object in cache - if (empty($feed)) $feed = $item->feed (true); + if ($feed == null) { + $feed = $item->feed(true); + if ($feed == null) { + $feed = FreshRSS_Feed::example(); + } + } ?>
  • ✇ name(); ?>
  • title (); ?>
  • date (); ?> 
  • -- cgit v1.2.3 From ea99ac1259083ff0a9eb6131d777454b54045626 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 19 Aug 2014 21:55:49 +0200 Subject: Syntax 581 #581 --- app/Controllers/statsController.php | 2 +- app/views/stats/repartition.phtml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 934b076a5..98f46f0d2 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -62,7 +62,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { $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->categories = $categoryDAO->listCategories(); $this->view->feed = $feedDAO->searchById($id); $this->view->days = $statsDAO->getDays(); $this->view->months = $statsDAO->getMonths(); diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml index 3dc319731..1f920a7ae 100644 --- a/app/views/stats/repartition.phtml +++ b/app/views/stats/repartition.phtml @@ -6,16 +6,16 @@

    conf->display_categories ? ' checked="checked"' : ''; ?> /> + + + +
    +
    +
    +
    +
    diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 7144c519a..2144f1576 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -4,7 +4,8 @@ echo '"use strict";', "\n"; $mark = $this->conf->mark_when; echo 'var ', - 'hide_posts=', ($this->conf->display_posts || Minz_Request::param('output') === 'reader') ? 'false' : 'true', + 'help_url="', FRESHRSS_WIKI, '"', + ',hide_posts=', ($this->conf->display_posts || Minz_Request::param('output') === 'reader') ? 'false' : 'true', ',display_order="', Minz_Request::param('order', $this->conf->sort_order), '"', ',auto_mark_article=', $mark['article'] ? 'true' : 'false', ',auto_mark_site=', $mark['site'] ? 'true' : 'false', @@ -25,7 +26,9 @@ echo ',shortcuts={', 'collapse_entry:"', $s['collapse_entry'], '",', 'load_more:"', $s['load_more'], '",', 'auto_share:"', $s['auto_share'], '",', - 'focus_search:"', $s['focus_search'], '"', + 'focus_search:"', $s['focus_search'], '",', + 'user_filter:"', $s['user_filter'], '",', + 'help:"', $s['help'], '"', "},\n"; if (Minz_Request::param ('output') === 'global') { diff --git a/constants.php b/constants.php index e32b8cbc3..483989371 100644 --- a/constants.php +++ b/constants.php @@ -1,6 +1,7 @@ Date: Sun, 24 Aug 2014 11:51:23 -0400 Subject: Fix category CSS Before, when the category is closed by default, the active CSS class wasn't applied. Thus breaking the shortcuts for navigation. Now it works the way it is supposed. --- app/layout/aside_flux.phtml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 432d6fdb7..357aa1cd3 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -42,21 +42,19 @@ $feeds = $cat->feeds (); if (!empty ($feeds)) { $c_active = false; - if ($this->conf->display_categories) { - if ($this->get_c == $cat->id () && $this->get_f) { - $c_active = true; - } - } else { - if ($this->get_c == $cat->id ()) { - $c_active = true; + $c_show = false; + if ($this->get_c == $cat->id ()) { + $c_active = true; + if (!$this->conf->display_categories || $this->get_f) { + $c_show = true; } } ?>
  • >
        id (); $nbEntries = $feed->nbEntries (); -- cgit v1.2.3 From f8a522d0c1f3b26c44e566506d6079fabefc8972 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 24 Aug 2014 12:46:40 -0400 Subject: Change wiki url --- constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants.php b/constants.php index 483989371..90c7a38e4 100644 --- a/constants.php +++ b/constants.php @@ -1,7 +1,7 @@ Date: Mon, 25 Aug 2014 17:32:51 -0400 Subject: Add a link to filter categories In the category configuration page, I added a filter link on each category. It works the same way than the "filter" link on the feed configuration page. See #514 --- app/views/configure/categorize.phtml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 9bae99b39..2f0e554ca 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -18,6 +18,9 @@ nbFeed () > 0) { ?> + + +
  • -- cgit v1.2.3 From 80acd3a0070fb309d57898c14ccd3a3a5658e236 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 27 Aug 2014 21:02:24 -0400 Subject: Add configuration for help configuration --- app/Controllers/configureController.php | 2 +- app/i18n/en.php | 1 + app/i18n/fr.php | 1 + app/views/configure/shortcut.phtml | 7 +++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 461cbceda..bb96bfae3 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -240,7 +240,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { 'm', 'n', 'o', 'p', 'page_down', 'page_up', 'q', 'r', 'return', 'right', 's', 'space', 't', 'tab', 'u', 'up', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', - '9', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', + '9', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12'); $this->view->list_keys = $list_keys; diff --git a/app/i18n/en.php b/app/i18n/en.php index 76da5d182..bcd7a3da5 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -182,6 +182,7 @@ return array ( 'focus_search' => 'Access search box', 'user_filter' => 'Access user filters', 'user_filter_help' => 'If there is only one user filter, it is used. Else filters are accessible by their number.', + 'help' => 'Display documentation', 'file_to_import' => 'File to import
    (OPML, Json or Zip)', 'file_to_import_no_zip' => 'File to import
    (OPML or Json)', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index a8f7a3a98..395f2b5d2 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -182,6 +182,7 @@ return array ( 'focus_search' => 'Accéder à la recherche', 'user_filter' => 'Accéder aux filtres utilisateur', 'user_filter_help' => 'S’il n’y a qu’un filtre utilisateur, celui ci est utilisé automatiquement. Sinon ils sont accessibles par leur numéro.', + 'help' => 'Afficher la documentation', 'file_to_import' => 'Fichier à importer
    (OPML, Json ou Zip)', 'file_to_import_no_zip' => 'Fichier à importer
    (OPML ou Json)', diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtml index 73ad0ebb8..a4029b676 100644 --- a/app/views/configure/shortcut.phtml +++ b/app/views/configure/shortcut.phtml @@ -111,6 +111,13 @@
    +
    + +
    + +
    +
    +
    -- cgit v1.2.3 From 366550057db8f5f86afd64c99f3a399016c97a36 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 27 Aug 2014 21:07:47 -0400 Subject: Fix Screwdriver theme Before, it wasn't possible to hide categories when they had no articles to read. I applied the same rule than the one described in here (https://github.com/marienfressinaud/FreshRSS/commit/d19824b919289ad63743f27da7861f2422da5baa). Now, the categories are hidden when they have no articles to read. See #594 --- p/themes/Screwdriver/template.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/p/themes/Screwdriver/template.css b/p/themes/Screwdriver/template.css index bf421e322..ddb3f376f 100644 --- a/p/themes/Screwdriver/template.css +++ b/p/themes/Screwdriver/template.css @@ -309,6 +309,9 @@ a.btn { list-style: none; margin: 0; } +.state_unread li:not(.active)[data-unread="0"] { + display: none; +} .category { display: block; overflow: hidden; -- cgit v1.2.3 From a126d99b3c87c12d6da86a32f0615ad36ec99d60 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 30 Aug 2014 18:31:50 +0200 Subject: Bug referer for systems with non-standard HTTP port Now tests also for the scheme and port, which must be identical to the ones in the referer. https://github.com/marienfressinaud/FreshRSS/issues/565#issuecomment-53916915 https://github.com/marienfressinaud/FreshRSS/issues/554 --- app/FreshRSS.php | 3 +-- lib/Minz/Request.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 30f711e20..cf6390f68 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -6,8 +6,7 @@ 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))) { + if (Minz_Request::isPost() && !Minz_Request::isRefererFromSameDomain()) { $loginOk = false; //Basic protection against XSRF attacks Minz_Error::error( 403, diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 52f53012f..ec4e25a6b 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -84,6 +84,20 @@ class Minz_Request { return $_SERVER['HTTP_HOST']; } + public static function isRefererFromSameDomain() { + if (empty($_SERVER['HTTP_REFERER'])) { + return false; + } + $host = parse_url(((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https://' : 'http://') . + (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'])); + $referer = parse_url($_SERVER['HTTP_REFERER']); + if (empty($host['scheme']) || empty($referer['scheme']) || $host['scheme'] !== $referer['scheme'] || + empty($host['host']) || empty($referer['host']) || $host['host'] !== $referer['host']) { + return false; + } + return (isset($host['port']) ? $host['port'] : 0) === (isset($referer['port']) ? $referer['port'] : 0); + } + /** * Détermine la base de l'url * @return la base de l'url -- cgit v1.2.3 From f002dbe4ceb8505b237bd67b66365d636bddd4b2 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Mon, 1 Sep 2014 20:58:05 -0400 Subject: Add average on repartition charts. It needs some verification on the value used to calculate the averages. --- app/Controllers/statsController.php | 3 ++ app/Models/StatsDAO.php | 62 +++++++++++++++++++++++++++++++++++++ app/views/stats/repartition.phtml | 48 ++++++++++++++++++++++++---- 3 files changed, 107 insertions(+), 6 deletions(-) diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 98f46f0d2..000b41dd2 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -67,8 +67,11 @@ class FreshRSS_stats_Controller extends Minz_ActionController { $this->view->days = $statsDAO->getDays(); $this->view->months = $statsDAO->getMonths(); $this->view->repartitionHour = $statsDAO->calculateEntryRepartitionPerFeedPerHour($id); + $this->view->averageHour = $statsDAO->calculateEntryAveragePerFeedPerHour($id); $this->view->repartitionDayOfWeek = $statsDAO->calculateEntryRepartitionPerFeedPerDayOfWeek($id); + $this->view->averageDayOfWeek = $statsDAO->calculateEntryAveragePerFeedPerDayOfWeek($id); $this->view->repartitionMonth = $statsDAO->calculateEntryRepartitionPerFeedPerMonth($id); + $this->view->averageMonth = $statsDAO->calculateEntryAveragePerFeedPerMonth($id); } public function firstAction() { diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index 89be76a26..bd4271ba8 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -151,6 +151,68 @@ SQL; return $this->convertToSerie($repartition); } + /** + * Calculates the average number of article per hour per feed + * + * @param integer $feed id + * @return integer + */ + public function calculateEntryAveragePerFeedPerHour($feed = null) { + return $this->calculateEntryAveragePerFeedPerPeriod(1/24, $feed); + } + + /** + * Calculates the average number of article per day of week per feed + * + * @param integer $feed id + * @return integer + */ + public function calculateEntryAveragePerFeedPerDayOfWeek($feed = null) { + return $this->calculateEntryAveragePerFeedPerPeriod(7, $feed); + } + + /** + * Calculates the average number of article per month per feed + * + * @param integer $feed id + * @return integer + */ + public function calculateEntryAveragePerFeedPerMonth($feed = null) { + return $this->calculateEntryAveragePerFeedPerPeriod(30, $feed); + } + + /** + * Calculates the average number of article per feed + * + * @param float $period number used to divide the number of day in the period + * @param integer $feed id + * @return integer + */ + protected function calculateEntryAveragePerFeedPerPeriod($period, $feed = null) { + if ($feed) { + $restrict = "WHERE e.id_feed = {$feed}"; + } else { + $restrict = ''; + } + $sql = <<prefix}entry AS e +{$restrict} +SQL; + $stm = $this->bd->prepare($sql); + $stm->execute(); + $res = $stm->fetch(PDO::FETCH_NAMED); + $date_min = new \DateTime(); + $date_min->setTimestamp($res['date_min']); + $date_max = new \DateTime(); + $date_max->setTimestamp($res['date_max']); + $interval = $date_max->diff($date_min, true); + + return round($res['count'] / ($interval->format('%a') / ($period)), 2); + } + /** * Initialize an array for statistics depending on a range * diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml index 9d2eb28e4..2331db78c 100644 --- a/app/views/stats/repartition.phtml +++ b/app/views/stats/repartition.phtml @@ -56,11 +56,22 @@ function initStats() { return; } // Entry per hour + var avg_h = []; + for (var i = -1; i <= 24; i++) { + avg_h.push([i, averageHour?>]); + } Flotr.draw(document.getElementById('statsEntryPerHour'), - [repartitionHour ?>], + [{ + data: repartitionHour ?>, + bars: {horizontal: false, show: true} + }, { + data: avg_h, + lines: {show: true}, + label: averageHour?>, + yaxis: 2 + }], { grid: {verticalLines: false}, - bars: {horizontal: false, show: true}, xaxis: {noTicks: 23, tickFormatter: function(x) { var x = parseInt(x); @@ -70,14 +81,26 @@ function initStats() { max: 23.9, tickDecimals: 0}, yaxis: {min: 0}, + y2axis: {showLabels: false}, mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}} }); // Entry per day of week + var avg_dow = []; + for (var i = -1; i <= 7; i++) { + avg_dow.push([i, averageDayOfWeek?>]); + } Flotr.draw(document.getElementById('statsEntryPerDayOfWeek'), - [repartitionDayOfWeek ?>], + [{ + data: repartitionDayOfWeek ?>, + bars: {horizontal: false, show: true} + }, { + data: avg_dow, + lines: {show: true}, + label: averageDayOfWeek?>, + yaxis: 2 + }], { grid: {verticalLines: false}, - bars: {horizontal: false, show: true}, xaxis: {noTicks: 6, tickFormatter: function(x) { var x = parseInt(x), @@ -88,14 +111,26 @@ function initStats() { max: 6.9, tickDecimals: 0}, yaxis: {min: 0}, + y2axis: {showLabels: false}, mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}} }); // Entry per month + var avg_m = []; + for (var i = 0; i <= 13; i++) { + avg_m.push([i, averageMonth?>]); + } Flotr.draw(document.getElementById('statsEntryPerMonth'), - [repartitionMonth ?>], + [{ + data: repartitionMonth ?>, + bars: {horizontal: false, show: true} + }, { + data: avg_m, + lines: {show: true}, + label: averageMonth?>, + yaxis: 2 + }], { grid: {verticalLines: false}, - bars: {horizontal: false, show: true}, xaxis: {noTicks: 12, tickFormatter: function(x) { var x = parseInt(x), @@ -106,6 +141,7 @@ function initStats() { max: 12.9, tickDecimals: 0}, yaxis: {min: 0}, + y2axis: {showLabels: false}, mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}} }); -- cgit v1.2.3 From a2ba5e2a21ad79e065925d7642f62c5cf4083212 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 2 Sep 2014 18:50:41 +0200 Subject: Add a first version of i18n for German All the strings are not completed yet, but it's a good start! --- app/Models/Configuration.php | 1 + app/i18n/de.php | 326 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 327 insertions(+) create mode 100644 app/i18n/de.php diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 4c804a9fb..e815561a9 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -61,6 +61,7 @@ class FreshRSS_Configuration { ); private $available_languages = array( + 'de' => 'Deutsch', 'en' => 'English', 'fr' => 'Français', ); diff --git a/app/i18n/de.php b/app/i18n/de.php new file mode 100644 index 000000000..4301a8b6d --- /dev/null +++ b/app/i18n/de.php @@ -0,0 +1,326 @@ + 'Login', + 'login_with_persona' => 'Login mit Persona', + 'logout' => 'Logout', + 'search' => 'Suche nach Worten oder #tags', + 'search_short' => 'Suche', + + 'configuration' => 'Konfiguration', + 'users' => 'Nutzer', + 'categories' => 'Kategorien', + 'category' => 'Kategorie', + 'feed' => 'Feed', + 'feeds' => 'Feeds', + 'shortcuts' => 'Shortcuts', + 'about' => 'Über', + 'stats' => 'Statistiken', + + 'your_rss_feeds' => 'Ihre RSS Feeds', + 'add_rss_feed' => 'RSS-Feed hinzufügen', + 'no_rss_feed' => 'Kein RSS Feed', + 'import_export_opml' => 'Import / Export (OPML)', + + 'subscription_management' => 'Abonnementsverwaltung', + 'main_stream' => 'Haupt-Nachrichtenfluß', + 'all_feeds' => 'Alle Feeds', + 'favorite_feeds' => 'Favoriten (%d)', + 'not_read' => '%d ungelesen', + 'not_reads' => '%d ungelesen', + + 'filter' => 'Filter', + 'see_website' => 'Website ansehen', + 'administration' => 'Verwaltung', + 'actualize' => 'Aktualisierung', + + 'mark_read' => 'Als gelesen markieren', + 'mark_favorite' => 'Als Favoriten markieren', + 'mark_all_read' => 'Alle als gelesen markieren', + 'mark_feed_read' => 'Feed als gelesen markieren', + 'mark_cat_read' => 'Kategorie als gelesen markieren', + 'before_one_day' => 'Vor einem Tag', + 'before_one_week' => 'Vor einer Woche', + 'display' => 'Anzeige', + 'normal_view' => 'Normale Anzeige', + 'reader_view' => 'Leseanzeige-Modus', + 'global_view' => 'Globale Anzeige', + 'rss_view' => 'RSS-Feed', + 'show_all_articles' => 'zeige alle Artikel', + 'show_not_reads' => 'zeige nicht gelesene', + 'show_read' => 'zeige nur gelesene', + 'show_favorite' => 'Favoriten anzeigen', + 'older_first' => 'Älteste zuerst', + 'newer_first' => 'Neuere zuerst', + + // Pagination + 'first' => 'Erste', + 'previous' => 'Vorherige', + 'next' => 'Nächste', + 'last' => 'Letzte', + + // CONTROLLERS + 'article_published_on' => 'Dieser Artikel erschien im Original bei %s', + 'article_published_on_author' => 'Dieser Artikel erschien im Original bei %s von %s', + + 'access_denied' => 'Sie haben nicht die Berechtigung, diese Seite aufzurufen', + 'page_not_found' => 'Sie suchen nach einer Seite, die es nicht gibt', + 'error_occurred' => 'Es gab einen Fehler', + 'error_occurred_update' => 'Es wurde nichts geändert', + + 'default_category' => 'Unkategorisiert', + 'categories_updated' => 'Kategorien wurden aktualisiert', + 'categories_management' => 'Kategorienverwaltung', + 'feed_updated' => 'Der Feed wurde aktualisiert', + 'rss_feed_management' => 'Verwaltung der RSS Feeds', + 'configuration_updated' => 'Die Konfiguration wurde aktualisiert', + 'sharing_management' => 'Verwaltung der Optionen für das Teilen', + 'bad_opml_file' => 'Ihre OPML-Datei ist ungültig', + 'shortcuts_updated' => 'Shortcuts wurden aktualisiert', + 'shortcuts_management' => 'Verwaltung der Shortcuts', + 'shortcuts_navigation' => 'Navigation', + 'shortcuts_navigation_help' => 'Mit der "Shift" Taste gelten die Navigations-Shortcuts für Feeds.
    Mit der "Alt" Taste gelten die Navigations-Shortcuts für Kategorien.', + 'shortcuts_article_action' => 'Artikelaktionen', + 'shortcuts_other_action' => 'Andere Aktionen', + 'feeds_marked_read' => 'Die Feeds wurden als gelesen markiert', + 'updated' => 'Die Änderungen wurden aktualisiert', + + 'already_subscribed' => 'Sie haben bereits %s abonniert', + 'feed_added' => 'Der RSS Feed %s wurde hinzugefügt', + 'feed_not_added' => '%s konnte nicht hinzugefügt werden', + 'internal_problem_feed' => 'Der RSS Feed konnte nicht hinzugefügt werden. überprüfen Sie die Protokolldateien von FressRSS für weitere Informationen.', + 'invalid_url' => 'URL %s ist ungültig', + 'feed_actualized' => '%s wurde aktualisiert', + 'n_feeds_actualized' => '%d Feeds wurden aktualisiert', + 'feeds_actualized' => 'RSS Feeds wurden aktualisiert', + 'no_feed_actualized' => 'Es wurden keine RSS Feeds aktualisiert', + 'n_entries_deleted' => '%d Artikel wurden gelöscht', + 'feeds_imported_with_errors' => 'Ihre Feeds wurden importiert, es gab aber einige Fehler', + 'feeds_imported' => 'Ihre Feeds wurden importiert und werden jetzt aktualisiert', + 'category_emptied' => 'Die Kategorie wurde geleert', + 'feed_deleted' => 'Der Feed wurde gelöscht', + 'feed_validator' => '&Üuml;berprüfen Sie die Gültigkeit des Feeds', + + 'optimization_complete' => 'Die Optimierung ist beendet', + + 'your_rss_feeds' => 'Ihre RSS Feeds', + 'your_favorites' => 'Ihre Favoriten', + 'public' => 'Öffentlich', + 'invalid_login' => 'Das Login ist ungültig', + + // VIEWS + 'save' => 'Speichern', + 'delete' => 'Löschen', + 'cancel' => 'Abbrechen', + + 'back_to_rss_feeds' => '← Zurück zu den RSS Feeds gehen', + 'feeds_moved_category_deleted' => 'Wenn Sie eine Kategorie löschen, werden deren Feeds automatisch in die Kategorie %s eingefügt.', + 'category_number' => 'Kategorie n°%d', + 'ask_empty' => 'Leeren?', + 'number_feeds' => '%d Feeds', + 'can_not_be_deleted' => 'Kann nicht gelöscht werden', + 'add_category' => 'Füge eine Kategorie hinzu', + 'new_category' => 'Neue Kategorie', + + 'javascript_for_shortcuts' => 'JavaScript muss ermöglicht werden, wenn Shortcuts verwendet werden sollen', + 'javascript_should_be_activated'=> 'JavaScript muss ermöglicht werden', + 'shift_for_all_read' => '+ shift um alle Artikel als gelesen zu markieren', + 'see_on_website' => 'Auf der Originalwebseite anschauen', + 'next_article' => 'Zum nächsten Artikel springen', + 'last_article' => 'Zum letzten Artikel springen', + 'previous_article' => 'Zum vorherigen Artikel springen', + 'first_article' => 'Zum ersten Artikel springen', + 'next_page' => 'Zur nächsten Seite springen', + 'previous_page' => 'Zur vorherigen Seite springen', + 'collapse_article' => 'Zusammenfalten', + 'auto_share' => 'Teilen', + 'auto_share_help' => 'Wenn es nur eine Option zum Teilen gibt, wird die verwendet. Ansonsten werden die Optionen über die Nummer ausgewählt.', + + 'file_to_import' => 'Datei zum importieren', + 'import' => 'Import', + 'export' => 'Export', + 'or' => 'oder', + + 'informations' => 'Information', + 'damn' => 'Verdammt!', + 'feed_in_error' => 'Dieser Feed hat ein Problem verursacht. Bitte stellen Sie sicher, dass er immer lesbar ist und aktualisieren Sie ihn dann.', + 'feed_empty' => 'Dieser Feed ist leer. Bitte stellen Sie sicher, dass er noch gepflegt wird.', + 'feed_description' => 'Beschreibung', + 'website_url' => 'Webseiten-Adresse URL', + 'feed_url' => 'Feed URL', + 'articles' => 'Artikel', + 'number_articles' => 'Anzahl der Artikel', + 'by_feed' => 'per Feed', + 'by_default' => 'Als Vorgabe', + 'keep_history' => 'Kleinste Anzahl der Artikel, die behalten werden', + 'categorize' => 'In einer Kategorie speichern', + 'truncate' => 'Alle Artikel löschen', + 'advanced' => 'Erweitert', + 'show_in_all_flux' => 'Im Hauptstrom anzeigen', + 'yes' => 'Ja', + 'no' => 'Nein', + 'css_path_on_website' => 'Pfad zur CSS-Datei des Artikels auf der Original Webseite', + 'retrieve_truncated_feeds' => 'Gekürzte RSS Feeds abrufen (Achtung, benötigt mehr Zeit!)', + 'http_authentication' => 'HTTP Authentifizierung', + 'http_username' => 'HTTP Nutzername', + 'http_password' => 'HTTP Passwort', + 'blank_to_disable' => 'Zum Ausschalten frei lassen', + 'not_yet_implemented' => 'Noch nicht implementiert', + 'access_protected_feeds' => 'Die Verbindung erlaubt Zugriff zu HTTP-geschützten RSS Feeds', + 'no_selected_feed' => 'Kein Feed ausgewählt.', + 'think_to_add' => 'Sie können Feeds hinzufügen.', + + 'current_user' => 'Aktuelle Nutzung', + 'default_user' => 'Nutzername des Standardnutzers (maximal 16 Zeichen - alphanumerisch)', + 'password_form' => 'Passwort
    (für die Anmeldemethode per Webformular)', + 'persona_connection_email' => 'Login E-Mail Adresse
    (für Mozilla Persona)', + 'allow_anonymous' => 'Anonymes lesen der Artikel des Standardnutzers (%s) wird erlaubt', + 'allow_anonymous_refresh' => 'Aktualisieren der Artikel wird anonymen Nutzern erlaubt', + 'auth_token' => 'Authentifizierungs-Token', + 'explain_token' => 'Erlaube den Zugriff auf die RSS-Ausgabe des Standardnutzers ohne Authentifizierung.
    %s?output=rss&token=%s', + 'login_configuration' => 'Login', + 'is_admin' => 'ist Administrator', + 'auth_type' => 'Authentifizierungsmethode', + 'auth_none' => 'Keine (gefährlich)', + 'auth_form' => 'Webformular (traditionell, JavaScript wird benötigt)', + 'http_auth' => 'HTTP (mit HTTPS für erfahrene Nutzer)', + 'auth_persona' => 'Mozilla Persona (modern, JavaScript wird benötigt)', + 'users_list' => 'Liste der Nutzer', + 'create_user' => 'Neuen Nutzer erstellen', + 'username' => 'Nutzername', + 'password' => 'Passwort', + 'create' => 'Erstellen', + 'user_created' => 'Nutzer %s wurde erstellt', + 'user_deleted' => 'Nutzer %s wurde gelöscht', + + 'language' => 'Sprache', + 'month' => 'Monate', + 'archiving_configuration' => 'Archivieren', + 'delete_articles_every' => 'Entfernen von Artikeln nach', + 'purge_now' => 'Jetzt bereinigen', + 'purge_completed' => 'Die Bereinigung ist abgeschlossen (%d Artikel wurden gelöscht)', + 'archiving_configuration_help' => 'Es gibt weitere Optionen bei den Einstellungen der individuellen Nachrichtenströme', + 'reading_configuration' => 'Lesen', + 'articles_per_page' => 'Anzahl der Artikel pro Seite', + 'default_view' => 'Standard-Ansicht', + 'sort_order' => 'Sortierreihenfolge', + 'auto_load_more' => 'Die nächsten Artikel am Seitenende laden', + 'display_articles_unfolded' => 'Die Artikel als Standard zusammen gefaltet anzeigen', + 'after_onread' => 'Nach “als gelesen markieren”', + 'jump_next' => 'springe zum nächsten ungelesenen Geschwisterelement (Feed oder Kategorie)', + 'reading_icons' => 'Lese Symbol', + 'top_line' => 'Kopfzeile', + 'bottom_line' => 'Fusszeile', + 'img_with_lazyload' => 'Verwende die "träge laden" Methode zum laden von Bildern', + 'auto_read_when' => 'Artikel als gelesen markieren…', + 'article_selected' => 'wenn der Artikel ausgewählt ist', + 'article_open_on_website' => 'wenn der Artikel auf der Originalwebseite geöffnet ist', + 'scroll' => 'während des Seiten-Scrollens', + 'upon_reception' => 'beim Empfang des Artikels', + 'your_shaarli' => 'Ihr Shaarli', + 'your_wallabag' => 'Ihr wallabag', + 'your_diaspora_pod' => 'Ihr Diaspora* pod', + 'sharing' => 'Teilen', + 'share' => 'teile', + 'by_email' => 'Per E-Mail', + 'optimize_bdd' => 'Datenbank optimieren', + 'optimize_todo_sometimes' => 'Sollte gelegentlich gemacht werden, um die Größe der Datenbank zu reduzieren', + 'theme' => 'Thema', + 'more_information' => 'Weitere Informationen', + 'activate_sharing' => 'Teilen aktivieren', + 'shaarli' => 'Shaarli', + 'wallabag' => 'wallabag', + 'diaspora' => 'Diaspora*', + 'twitter' => 'Twitter', + 'g+' => 'Google+', + 'facebook' => 'Facebook', + 'email' => 'E-Mail', + 'print' => 'Drucken', + + 'article' => 'Artikel', + 'title' => 'Titel', + 'author' => 'Autor', + 'publication_date' => 'Datum der Veröffentlichung', + 'by' => 'von', + + 'load_more' => 'Weitere Artikel laden', + 'nothing_to_load' => 'Es gibt keine weiteren Artikel', + + 'rss_feeds_of' => 'RSS Feed von %s', + + 'refresh' => 'Aktualisieren', + 'no_feed_to_refresh' => 'Es gibt keinen Feed zum aktualisieren', + + 'today' => 'Heute', + 'yesterday' => 'Gestern', + 'before_yesterday' => 'vor Gestern', + 'new_article' => 'Es gibt neue Artikel. Bitte klicken Sie hier, um die Seite erneut zu laden.', + 'by_author' => 'Von %s', + 'related_tags' => 'Verwandte tags', + 'no_feed_to_display' => 'Es gibt keinen Artikel zum anzeigen.', + + 'about_freshrss' => 'Über FreshRSS', + 'project_website' => 'Projekt Webseite', + 'lead_developer' => 'Hauptentwickler', + 'website' => 'Webseite', + 'bugs_reports' => 'Fehlerberichte', + 'github_or_email' => 'auf Github oder per Mail', + 'license' => 'Lizenz', + 'agpl3' => 'AGPL 3', + 'freshrss_description' => 'FreshRSS ist ein RSS Feedsaggregator zum selbst hosten wie zum Beispiel Kriss Feed oder Leed. Es ist leicht und einfach zu handhaben und gleichzeitig ein leistungsstark und konfigurierbares Werkzeug.', + 'credits' => 'Credits', + 'credits_content' => 'Einige Designelemente sind von Bootstrap obwohl FreshRSS dieses Framework nicht nutzt. Icons sind vom GNOME Projekt. Open Sans Font police wurde von Steve Matteson erstellt. Favicons wurden mit getFavicon API gesammelt. FreshRSS basiert auf Minz, einem PHP Framework.', + 'version' => 'Version', + + 'logs' => 'Protokolle', + 'logs_empty' => 'Die Protokolldatei ist leer', + 'clear_logs' => 'Protokolldateien leeren', + + 'forbidden_access' => 'Der Zugriff ist verboten!', + 'login_required' => 'Das Login ist nötig:', + + 'confirm_action' => 'Sind Sie sicher, dass Sie diese Aktion durchführen wollen? Die Aktion kann nicht abgebrochen werden!', + + // DATE + 'january' => 'januar', + 'february' => 'februar', + 'march' => 'märz', + 'april' => 'april', + 'may' => 'mai', + 'june' => 'juni', + 'july' => 'juli', + 'august' => 'august', + 'september' => 'september', + 'october' => 'oktober', + 'november' => 'november', + 'december' => 'dezember', + // special format for date() function + 'Jan' => '\J\a\n\u\a\r', + 'Feb' => '\F\e\b\r\u\a\r', + 'Mar' => '\M\a\e\r\z', + 'Apr' => '\A\p\r\i\l', + 'May' => '\M\a\i', + 'Jun' => '\J\u\n\i', + 'Jul' => '\J\u\l\i', + 'Aug' => '\A\u\g\u\s\t', + 'Sep' => '\S\e\p\t\e\m\b\e\r', + 'Oct' => '\O\k\t\o\b\e\r', + 'Nov' => '\N\o\v\e\m\b\e\r', + 'Dec' => '\D\e\z\e\m\b\e\r', + // format for date() function, %s allows to indicate month in letter + 'format_date' => 'd\.\ %s Y', + 'format_date_hour' => 'd\.\ %s Y \u\m H\:i', + + 'status_favorites' => 'Favoriten', + 'status_read' => 'Gelesen', + 'status_unread' => 'Ungelesen', + 'status_total' => 'Gesamt', + + 'stats_entry_repartition' => 'Verteilung der Einträge', + 'stats_entry_per_day' => 'Einträge pro Tag (während der letzten 30 Tage)', + 'stats_feed_per_category' => 'Feeds pro Kategorie', + 'stats_entry_per_category' => 'Einträge pro Kategorie', + 'stats_top_feed' => 'Top 10 Feeds', + 'stats_entry_count' => 'Zähler für Einträge', +); -- cgit v1.2.3 From 5d718b5c3bc183441b7629377367f23f8773045a Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 3 Sep 2014 21:33:29 -0400 Subject: Fix collapse shortcut behavior Before, the collapse shortcut was marking all articles as read when used. No matter what configuration you use. Now, the collapse shortcut marks articles only if the appropriate configuration is used (when article is viewed). --- p/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p/scripts/main.js b/p/scripts/main.js index c37f9f6f2..7bd746f75 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -373,7 +373,7 @@ function collapse_entry() { var flux_current = $(".flux.current"); flux_current.toggleClass("active"); - if (isCollapsed) { + if (isCollapsed && auto_mark_article) { mark_read(flux_current, true); } } -- cgit v1.2.3 From 657b1ffe278c2bbd1c23ae906786810ce9c609f4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 4 Sep 2014 20:30:15 +0200 Subject: Bug HTML stats Categories containing a space were not displayed properly https://github.com/marienfressinaud/FreshRSS/issues/547 --- app/views/stats/repartition.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml index 2331db78c..d9dc4c89d 100644 --- a/app/views/stats/repartition.phtml +++ b/app/views/stats/repartition.phtml @@ -10,12 +10,12 @@ categories as $category) { $feeds = $category->feeds(); if (!empty($feeds)) { - echo ''; + echo ''; foreach ($feeds as $feed) { if ($this->feed && $feed->id() == $this->feed->id()){ - echo ''; + echo ''; } else { - echo ''; + echo ''; } } echo ''; -- cgit v1.2.3 From 88ec538ef5a444c65d0d34603d108257538b537d Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Thu, 4 Sep 2014 23:45:40 -0400 Subject: Fix navigation on hidden categories and feeds Before, when navigating with the keyboard, hidden categories and feeds where shown. Now, they stay hidden. See #604 --- p/scripts/main.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/p/scripts/main.js b/p/scripts/main.js index c37f9f6f2..ee95a1b98 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -297,7 +297,7 @@ function next_entry() { function prev_feed() { var active_feed = $("#aside_flux .feeds li.active"); if (active_feed.length > 0) { - active_feed.prev().find('a.feed').each(function(){this.click();}); + active_feed.prevAll(':visible:first').find('a.feed').each(function(){this.click();}); } else { last_feed(); } @@ -306,21 +306,21 @@ function prev_feed() { function next_feed() { var active_feed = $("#aside_flux .feeds li.active"); if (active_feed.length > 0) { - active_feed.next().find('a.feed').each(function(){this.click();}); + active_feed.nextAll(':visible:first').find('a.feed').each(function(){this.click();}); } else { first_feed(); } } function first_feed() { - var feed = $("#aside_flux .feeds.active li:first"); + var feed = $("#aside_flux .feeds.active li:visible:first"); if (feed.length > 0) { feed.find('a')[1].click(); } } function last_feed() { - var feed = $("#aside_flux .feeds.active li:last"); + var feed = $("#aside_flux .feeds.active li:visible:last"); if (feed.length > 0) { feed.find('a')[1].click(); } @@ -330,7 +330,7 @@ function prev_category() { var active_cat = $("#aside_flux .category.stick.active"); if (active_cat.length > 0) { - var prev_cat = active_cat.parent('li').prev().find('.category.stick a.btn'); + var prev_cat = active_cat.parent('li').prevAll(':visible:first').find('.category.stick a.btn'); if (prev_cat.length > 0) { prev_cat[0].click(); } @@ -344,7 +344,7 @@ function next_category() { var active_cat = $("#aside_flux .category.stick.active"); if (active_cat.length > 0) { - var next_cat = active_cat.parent('li').next().find('.category.stick a.btn'); + var next_cat = active_cat.parent('li').nextAll(':visible:first').find('.category.stick a.btn'); if (next_cat.length > 0) { next_cat[0].click(); } @@ -355,14 +355,14 @@ function next_category() { } function first_category() { - var cat = $("#aside_flux .category.stick:first"); + var cat = $("#aside_flux .category.stick:visible:first"); if (cat.length > 0) { cat.find('a.btn')[0].click(); } } function last_category() { - var cat = $("#aside_flux .category.stick:last"); + var cat = $("#aside_flux .category.stick:visible:last"); if (cat.length > 0) { cat.find('a.btn')[0].click(); } -- cgit v1.2.3 From c3fd8877c021b86180b3bea4d4260e6478f0558e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 6 Sep 2014 16:04:49 +0200 Subject: Bug warning in case of invalid CDATA --- lib/SimplePie/SimplePie/Parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SimplePie/SimplePie/Parser.php b/lib/SimplePie/SimplePie/Parser.php index 9300b4ba9..7fb7bd9be 100644 --- a/lib/SimplePie/SimplePie/Parser.php +++ b/lib/SimplePie/SimplePie/Parser.php @@ -142,7 +142,7 @@ class SimplePie_Parser $dom = new DOMDocument(); $dom->recover = true; $dom->strictErrorChecking = false; - $dom->loadXML($data); + @$dom->loadXML($data); $this->encoding = $encoding = $dom->encoding = 'UTF-8'; $data2 = $dom->saveXML(); if (function_exists('mb_convert_encoding')) -- cgit v1.2.3