diff options
| author | 2014-02-19 20:19:11 +0100 | |
|---|---|---|
| committer | 2014-02-19 20:19:11 +0100 | |
| commit | 3aeea28ac7a1aa0bd07f23b1639c14985ff241ad (patch) | |
| tree | 48e391d1aee6db4797cc46bd23ffb4dce311f46b /app | |
| parent | 165eb57459a152b3cc6aa3fd15ca990c3d908829 (diff) | |
| parent | 04da549e2e52980ccc72689c32793222be76279d (diff) | |
Merge branch 'dev'
Diffstat (limited to 'app')
28 files changed, 357 insertions, 219 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 645f9eabf..ad8bc546a 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -29,7 +29,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $cat = new FreshRSS_Category ($name); $values = array ( 'name' => $cat->name (), - 'color' => $cat->color () ); $catDAO->updateCategory ($ids[$key], $values); } elseif ($ids[$key] != $defaultId) { @@ -43,7 +42,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), - 'color' => $cat->color () ); if ($catDAO->searchByName ($newCat) == false) { @@ -116,7 +114,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { if ($feedDAO->updateFeed ($id, $values)) { $this->view->flux->_category ($cat); - + $this->view->flux->faviconPrepare(); $notif = array ( 'type' => 'good', 'content' => Minz_Translate::t ('feed_updated') @@ -286,7 +284,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { public function shortcutAction () { $list_keys = array ('a', 'b', 'backspace', 'c', 'd', 'delete', 'down', 'e', 'end', 'enter', - 'escape', 'f', 'g', 'h', 'i', 'insert', 'j', 'k', 'l', 'left', + 'escape', 'f', 'g', 'h', 'home', 'i', 'insert', 'j', 'k', 'l', 'left', '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', diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index c40b3c400..c718fcd5c 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -3,26 +3,31 @@ class FreshRSS_feed_Controller extends Minz_ActionController { public function firstAction () { if (!$this->view->loginOk) { - $token = $this->view->conf->token; //TODO: check the token logic again, and if it is still needed + // Token is useful in the case that anonymous refresh is forbidden + // and CRON task cannot be used with php command so the user can + // set a CRON task to refresh his feeds by using token inside url + $token = $this->view->conf->token; $token_param = Minz_Request::param ('token', ''); $token_is_ok = ($token != '' && $token == $token_param); $action = Minz_Request::actionName (); - if (!($token_is_ok && $action === 'actualize')) { + if (!(($token_is_ok || Minz_Configuration::allowAnonymousRefresh()) && + $action === 'actualize') + ) { Minz_Error::error ( 403, array ('error' => array (Minz_Translate::t ('access_denied'))) ); } } - - $this->catDAO = new FreshRSS_CategoryDAO (); - $this->catDAO->checkDefault (); } public function addAction () { @set_time_limit(300); if (Minz_Request::isPost ()) { + $this->catDAO = new FreshRSS_CategoryDAO (); + $this->catDAO->checkDefault (); + $url = Minz_Request::param ('url_rss'); $cat = Minz_Request::param ('category', false); if ($cat === false) { @@ -189,38 +194,51 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $flux_update = 0; $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; foreach ($feeds as $feed) { + if (!$feed->lock()) { + Minz_Log::record('Feed already being actualized: ' . $feed->url(), Minz_Log::NOTICE); + continue; + } try { $url = $feed->url(); + $feedHistory = $feed->keepHistory(); + $feed->load(false); $entries = array_reverse($feed->entries()); //We want chronological order and SimplePie uses reverse order + $hasTransaction = false; - //For this feed, check last n entry GUIDs already in database - $existingGuids = array_fill_keys ($entryDAO->listLastGuidsByFeed ($feed->id (), count($entries) + 10), 1); - $useDeclaredDate = empty($existingGuids); + if (count($entries) > 0) { + //For this feed, check last n entry GUIDs already in database + $existingGuids = array_fill_keys ($entryDAO->listLastGuidsByFeed ($feed->id (), count($entries) + 10), 1); + $useDeclaredDate = empty($existingGuids); - $feedHistory = $feed->keepHistory(); - if ($feedHistory == -2) { //default - $feedHistory = $this->view->conf->keep_history_default; - } + if ($feedHistory == -2) { //default + $feedHistory = $this->view->conf->keep_history_default; + } + + $hasTransaction = true; + $feedDAO->beginTransaction(); - // On ne vérifie pas strictement que l'article n'est pas déjà en BDD - // La BDD refusera l'ajout car (id_feed, guid) doit être unique - $feedDAO->beginTransaction (); - foreach ($entries as $entry) { - $eDate = $entry->date (true); - if ((!isset ($existingGuids[$entry->guid ()])) && - (($feedHistory != 0) || ($eDate >= $date_min))) { - $values = $entry->toArray (); - //Use declared date at first import, otherwise use discovery date - $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? - min(time(), $eDate) . uSecString() : - uTimeString(); - $values['is_read'] = $is_read; - $entryDAO->addEntry ($values); + // On ne vérifie pas strictement que l'article n'est pas déjà en BDD + // La BDD refusera l'ajout car (id_feed, guid) doit être unique + foreach ($entries as $entry) { + $eDate = $entry->date (true); + if ((!isset ($existingGuids[$entry->guid ()])) && + (($feedHistory != 0) || ($eDate >= $date_min))) { + $values = $entry->toArray (); + //Use declared date at first import, otherwise use discovery date + $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? + min(time(), $eDate) . uSecString() : + uTimeString(); + $values['is_read'] = $is_read; + $entryDAO->addEntry ($values); + } } } if (($feedHistory >= 0) && (rand(0, 30) === 1)) { + if (!$hasTransaction) { + $feedDAO->beginTransaction(); + } $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, max($feedHistory, count($entries) + 10)); if ($nb > 0) { Minz_Log::record ($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG); @@ -228,18 +246,23 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } // on indique que le flux vient d'être mis à jour en BDD - $feedDAO->updateLastUpdate ($feed->id ()); - $feedDAO->commit (); + $feedDAO->updateLastUpdate ($feed->id (), 0, $hasTransaction); + if ($hasTransaction) { + $feedDAO->commit(); + } $flux_update++; if ($feed->url() !== $url) { //URL has changed (auto-discovery) $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } - $feed->faviconPrepare(); } catch (FreshRSS_Feed_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); $feedDAO->updateLastUpdate ($feed->id (), 1); } + $feed->faviconPrepare(); + $feed->unlock(); + unset($feed); + // On arrête à 10 flux pour ne pas surcharger le serveur // sauf si le paramètre $force est à vrai $i++; @@ -251,6 +274,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $url = array (); if ($flux_update === 1) { // on a mis un seul flux à jour + $feed = reset ($feeds); $notif = array ( 'type' => 'good', 'content' => Minz_Translate::t ('feed_actualized', $feed->name ()) @@ -264,8 +288,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } else { // aucun flux n'a été mis à jour, oups $notif = array ( - 'type' => 'bad', - 'content' => Minz_Translate::t ('no_feed_actualized') + 'type' => 'good', + 'content' => Minz_Translate::t ('no_feed_to_refresh') ); } @@ -298,6 +322,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { public function massiveImportAction () { @set_time_limit(300); + $this->catDAO = new FreshRSS_CategoryDAO (); + $this->catDAO->checkDefault (); + $entryDAO = new FreshRSS_EntryDAO (); $feedDAO = new FreshRSS_FeedDAO (); @@ -416,7 +443,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), - 'color' => $cat->color () ); $catDAO->addCategory ($values); } diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 986a322a1..38f4c0e7c 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -5,18 +5,24 @@ class FreshRSS_index_Controller extends Minz_ActionController { public function indexAction () { $output = Minz_Request::param ('output'); - $token = ''; + $token = $this->view->conf->token; // check if user is logged in - if (!$this->view->loginOk && !Minz_Configuration::allowAnonymous()) - { - $token = $this->view->conf->token; + if (!$this->view->loginOk && !Minz_Configuration::allowAnonymous()) { $token_param = Minz_Request::param ('token', ''); $token_is_ok = ($token != '' && $token === $token_param); - if (!($output === 'rss' && $token_is_ok)) { + if ($output === 'rss' && !$token_is_ok) { + Minz_Error::error ( + 403, + array ('error' => array (Minz_Translate::t ('access_denied'))) + ); + return; + } elseif ($output !== 'rss') { + // "hard" redirection is not required, just ask dispatcher to + // forward to the login form without 302 redirection + Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin')); return; } - $params['token'] = $token; } // construction of RSS url of this feed @@ -25,6 +31,9 @@ class FreshRSS_index_Controller extends Minz_ActionController { if (isset ($params['search'])) { $params['search'] = urlencode ($params['search']); } + if (!Minz_Configuration::allowAnonymous()) { + $params['token'] = $token; + } $this->view->rss_url = array ( 'c' => 'index', 'a' => 'index', @@ -342,6 +351,11 @@ class FreshRSS_index_Controller extends Minz_ActionController { } $this->view->_useLayout(false); Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); + } elseif (!Minz_Configuration::canLogIn()) { + Minz_Error::error ( + 403, + array ('error' => array (Minz_Translate::t ('access_denied'))) + ); } invalidateHttpCache(); } diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php index b879dcd6d..3d741e298 100755 --- a/app/Controllers/javascriptController.php +++ b/app/Controllers/javascriptController.php @@ -8,7 +8,7 @@ class FreshRSS_javascript_Controller extends Minz_ActionController { public function actualizeAction () { header('Content-Type: text/javascript; charset=UTF-8'); $feedDAO = new FreshRSS_FeedDAO (); - $this->view->feeds = $feedDAO->listFeeds (); + $this->view->feeds = $feedDAO->listFeedsOrderUpdate(); } public function nbUnreadsPerFeedAction() { diff --git a/app/Controllers/usersController.php b/app/Controllers/usersController.php index 8314b75fc..bb4f34c5e 100644 --- a/app/Controllers/usersController.php +++ b/app/Controllers/usersController.php @@ -54,11 +54,16 @@ class FreshRSS_users_Controller extends Minz_ActionController { $anon = Minz_Request::param('anon_access', false); $anon = ((bool)$anon) && ($anon !== 'no'); + $anon_refresh = Minz_Request::param('anon_refresh', false); + $anon_refresh = ((bool)$anon_refresh) && ($anon_refresh !== 'no'); $auth_type = Minz_Request::param('auth_type', 'none'); if ($anon != Minz_Configuration::allowAnonymous() || - $auth_type != Minz_Configuration::authType()) { + $auth_type != Minz_Configuration::authType() || + $anon_refresh != Minz_Configuration::allowAnonymousRefresh()) { + Minz_Configuration::_authType($auth_type); Minz_Configuration::_allowAnonymous($anon); + Minz_Configuration::_allowAnonymousRefresh($anon_refresh); $ok &= Minz_Configuration::writeFile(); } } diff --git a/app/FreshRSS.php b/app/FreshRSS.php index c51f91dec..84cf3429b 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -94,10 +94,6 @@ class FreshRSS extends Minz_FrontController { $loginOk = false; break; } - if ((!$loginOk) && (PHP_SAPI === 'cli') && (Minz_Request::actionName() === 'actualize')) { //Command line - Minz_Configuration::_authType('none'); - $loginOk = true; - } } Minz_View::_param ('loginOk', $loginOk); return $loginOk; diff --git a/app/Models/Category.php b/app/Models/Category.php index 8e1e44ef8..328bae799 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -3,14 +3,12 @@ class FreshRSS_Category extends Minz_Model { private $id = 0; private $name; - private $color; private $nbFeed = -1; private $nbNotRead = -1; private $feeds = null; - public function __construct ($name = '', $color = '#0062BE', $feeds = null) { + public function __construct ($name = '', $feeds = null) { $this->_name ($name); - $this->_color ($color); if (isset ($feeds)) { $this->_feeds ($feeds); $this->nbFeed = 0; @@ -28,9 +26,6 @@ class FreshRSS_Category extends Minz_Model { public function name () { return $this->name; } - public function color () { - return $this->color; - } public function nbFeed () { if ($this->nbFeed < 0) { $catDAO = new FreshRSS_CategoryDAO (); @@ -68,13 +63,6 @@ class FreshRSS_Category extends Minz_Model { public function _name ($value) { $this->name = $value; } - public function _color ($value) { - if (preg_match ('/^#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) { - $this->color = $value; - } else { - $this->color = '#0062BE'; - } - } public function _feeds ($values) { if (!is_array ($values)) { $values = array ($values); diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index 1cc616ac0..5355228a5 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -2,12 +2,11 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { public function addCategory ($valuesTmp) { - $sql = 'INSERT INTO `' . $this->prefix . 'category` (name, color) VALUES(?, ?)'; + $sql = 'INSERT INTO `' . $this->prefix . 'category` (name) VALUES(?)'; $stm = $this->bd->prepare ($sql); $values = array ( substr($valuesTmp['name'], 0, 255), - substr($valuesTmp['color'], 0, 7), ); if ($stm && $stm->execute ($values)) { @@ -20,12 +19,11 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { } public function updateCategory ($id, $valuesTmp) { - $sql = 'UPDATE `' . $this->prefix . 'category` SET name=?, color=? WHERE id=?'; + $sql = 'UPDATE `' . $this->prefix . 'category` SET name=? WHERE id=?'; $stm = $this->bd->prepare ($sql); $values = array ( $valuesTmp['name'], - $valuesTmp['color'], $id ); @@ -89,7 +87,6 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { public function listCategories ($prePopulateFeeds = true, $details = false) { if ($prePopulateFeeds) { $sql = 'SELECT c.id AS c_id, c.name AS c_name, ' - . ($details ? 'c.color AS c_color, ' : '') . ($details ? 'f.* ' : 'f.id, f.name, f.url, f.website, f.priority, f.error, f.cache_nbEntries, f.cache_nbUnreads ') . 'FROM `' . $this->prefix . 'category` c ' . 'LEFT OUTER JOIN `' . $this->prefix . 'feed` f ON f.category = c.id ' @@ -130,7 +127,6 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), - 'color' => $cat->color () ); $this->addCategory ($values); @@ -203,7 +199,6 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { // End of the current category, we add it to the $list $cat = new FreshRSS_Category ( $previousLine['c_name'], - isset($previousLine['c_color']) ? $previousLine['c_color'] : '', FreshRSS_FeedDAO::daoToFeed ($feedsDao, $previousLine['c_id']) ); $cat->_id ($previousLine['c_id']); @@ -220,7 +215,6 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { if ($previousLine != null) { $cat = new FreshRSS_Category ( $previousLine['c_name'], - isset($previousLine['c_color']) ? $previousLine['c_color'] : '', FreshRSS_FeedDAO::daoToFeed ($feedsDao, $previousLine['c_id']) ); $cat->_id ($previousLine['c_id']); @@ -239,8 +233,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { foreach ($listDAO as $key => $dao) { $cat = new FreshRSS_Category ( - $dao['name'], - $dao['color'] + $dao['name'] ); $cat->_id ($dao['id']); $list[$key] = $cat; diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 2a7fe95aa..2b719c370 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -32,6 +32,8 @@ class FreshRSS_Configuration { 'go_website' => 'space', 'next_entry' => 'j', 'prev_entry' => 'k', + 'first_entry' => 'home', + 'last_entry' => 'end', 'collapse_entry' => 'c', 'load_more' => 'm', 'auto_share' => 's', diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 22c019080..73f9c32fb 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -193,10 +193,10 @@ class FreshRSS_Feed extends Minz_Model { } $feed = customSimplePie(); $feed->set_feed_url ($url); - $feed->init (); + $mtime = $feed->init(); - if ($feed->error ()) { - throw new FreshRSS_Feed_Exception ($feed->error . ' [' . $url . ']'); + if ((!$mtime) || $feed->error()) { + throw new FreshRSS_Feed_Exception ($feed->error() . ' [' . $url . ']'); } // si on a utilisé l'auto-discover, notre url va avoir changé @@ -217,11 +217,20 @@ class FreshRSS_Feed extends Minz_Model { $this->_description(html_only_entity_decode($feed->get_description())); } - // et on charge les articles du flux - $this->loadEntries ($feed); + if (($mtime === true) || ($mtime > $this->lastUpdate)) { + syslog(LOG_DEBUG, 'FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $subscribe_url); + $this->loadEntries($feed); // et on charge les articles du flux + } else { + syslog(LOG_DEBUG, 'FreshRSS use cache for ' . $subscribe_url); + $this->entries = array(); + } + + $feed->__destruct(); //http://simplepie.org/wiki/faq/i_m_getting_memory_leaks + unset($feed); } } } + private function loadEntries ($feed) { $entries = array (); @@ -267,8 +276,27 @@ class FreshRSS_Feed extends Minz_Model { $entry->loadCompleteContent($this->pathEntries()); $entries[] = $entry; + unset($item); } $this->entries = $entries; } + + function lock() { + $lock = TMP_PATH . '/' . md5(Minz_Configuration::salt() . $this->url) . '.freshrss.lock'; + if (file_exists($lock) && ((time() - @filemtime($lock)) > 3600)) { + @unlink($lock); + } + if (($handle = @fopen($lock, 'x')) === false) { + return false; + } + //register_shutdown_function('unlink', $lock); + @fclose($handle); + return true; + } + + function unlock() { + $lock = TMP_PATH . '/' . md5(Minz_Configuration::salt() . $this->url) . '.freshrss.lock'; + @unlink($lock); + } } diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index e102da4ec..7ebe68d2b 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -52,21 +52,27 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { } } - public function updateLastUpdate ($id, $inError = 0) { - $sql = 'UPDATE `' . $this->prefix . 'feed` f ' //2 sub-requests with FOREIGN KEY(e.id_feed), INDEX(e.is_read) faster than 1 request with GROUP BY or CASE - . 'SET f.cache_nbEntries=(SELECT COUNT(e1.id) FROM `' . $this->prefix . 'entry` e1 WHERE e1.id_feed=f.id),' - . 'f.cache_nbUnreads=(SELECT COUNT(e2.id) FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed=f.id AND e2.is_read=0),' - . 'lastUpdate=?, error=? ' - . 'WHERE f.id=?'; - - $stm = $this->bd->prepare ($sql); + public function updateLastUpdate ($id, $inError = 0, $updateCache = true) { + if ($updateCache) { + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' //2 sub-requests with FOREIGN KEY(e.id_feed), INDEX(e.is_read) faster than 1 request with GROUP BY or CASE + . 'SET f.cache_nbEntries=(SELECT COUNT(e1.id) FROM `' . $this->prefix . 'entry` e1 WHERE e1.id_feed=f.id),' + . 'f.cache_nbUnreads=(SELECT COUNT(e2.id) FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed=f.id AND e2.is_read=0),' + . 'lastUpdate=?, error=? ' + . 'WHERE f.id=?'; + } else { + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' + . 'SET lastUpdate=?, error=? ' + . 'WHERE f.id=?'; + } $values = array ( - time (), + time(), $inError, $id, ); + $stm = $this->bd->prepare ($sql); + if ($stm && $stm->execute ($values)) { return $stm->rowCount(); } else { @@ -192,8 +198,11 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return self::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC)); } - public function listFeedsOrderUpdate () { - $sql = 'SELECT id, name, url, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; + public function listFeedsOrderUpdate ($cacheDuration = 1500) { + $sql = 'SELECT id, name, url, lastUpdate, pathEntries, httpAuth, keep_history ' + . 'FROM `' . $this->prefix . 'feed` ' + . 'WHERE lastUpdate < ' . (time() - intval($cacheDuration)) + . ' ORDER BY lastUpdate'; $stm = $this->bd->prepare ($sql); $stm->execute (); diff --git a/app/actualize_script.php b/app/actualize_script.php index 9ac80a852..8d81e0189 100755 --- a/app/actualize_script.php +++ b/app/actualize_script.php @@ -1,21 +1,5 @@ <?php require(dirname(__FILE__) . '/../constants.php'); - -//<Mutex> -$lock = DATA_PATH . '/actualize.lock.txt'; -if (file_exists($lock) && ((time() - @filemtime($lock)) > 3600)) { - @unlink($lock); -} -if (($handle = @fopen($lock, 'x')) === false) { - syslog(LOG_NOTICE, 'FreshRSS actualize already running?'); - fwrite(STDERR, 'FreshRSS actualize already running?' . "\n"); - return; -} -register_shutdown_function('unlink', $lock); -//Could use http://php.net/function.pcntl-signal.php to catch interruptions -@fclose($handle); -//</Mutex> - require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader session_cache_limiter(''); @@ -32,7 +16,9 @@ $users = array_unique($users); foreach ($users as $myUser) { syslog(LOG_INFO, 'FreshRSS actualize ' . $myUser); - fwrite(STDOUT, 'Actualize ' . $myUser . "...\n"); //Unbuffered + if (defined('STDOUT')) { + fwrite(STDOUT, 'Actualize ' . $myUser . "...\n"); //Unbuffered + } echo $myUser, ' '; //Buffered $_GET['c'] = 'feed'; @@ -44,16 +30,26 @@ foreach ($users as $myUser) { $freshRSS = new FreshRSS(); $freshRSS->_useOb(false); + Minz_Configuration::_authType('none'); + Minz_Session::init('FreshRSS'); Minz_Session::_param('currentUser', $myUser); $freshRSS->init(); $freshRSS->run(); - invalidateHttpCache(); + if (!invalidateHttpCache()) { + syslog(LOG_NOTICE, 'FreshRSS write access problem in ' . LOG_PATH . '/*.log!'); + if (defined('STDERR')) { + fwrite(STDERR, 'Write access problem in ' . LOG_PATH . '/*.log!' . "\n"); + } + } Minz_Session::unset_session(true); Minz_ModelPdo::clean(); } syslog(LOG_INFO, 'FreshRSS actualize done.'); +if (defined('STDOUT')) { + fwrite(STDOUT, 'Done.' . "\n"); +} +echo 'End.', "\n"; ob_end_flush(); -fwrite(STDOUT, 'Done.' . "\n"); diff --git a/app/i18n/en.php b/app/i18n/en.php index a2cc461c5..932513588 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -3,6 +3,7 @@ return array ( // LAYOUT 'login' => 'Login', + 'login_with_persona' => 'Login with Persona', 'logout' => 'Logout', 'search' => 'Search words or #tags', 'search_short' => 'Search', @@ -78,6 +79,10 @@ return array ( 'bad_opml_file' => 'Your OPML file is invalid', 'shortcuts_updated' => 'Shortcuts have been updated', 'shortcuts_management' => 'Shortcuts management', + 'shortcuts_navigation' => 'Navigation', + 'shortcuts_navigation_help' => 'With the "Shift" modifier, navigation shortcuts apply on feeds.<br/>With the "Alt" modifier, navigation shortcuts apply on categories.', + 'shortcuts_article_action' => 'Article actions', + 'shortcuts_other_action' => 'Other actions', 'feeds_marked_read' => 'Feeds have been marked as read', 'updated' => 'Modifications have been updated', @@ -121,15 +126,16 @@ return array ( 'javascript_for_shortcuts' => 'JavaScript must be enabled in order to use shortcuts', 'javascript_should_be_activated'=> 'JavaScript must be enabled', 'shift_for_all_read' => '+ <code>shift</code> to mark all articles as read', - 'see_on_website' => 'See article on its original website', + 'see_on_website' => 'See on original website', 'next_article' => 'Skip to the next article', - 'shift_for_last' => '+ <code>shift</code> to skip to the last article of page', + 'last_article' => 'Skip to the last article', 'previous_article' => 'Skip to the previous article', - 'shift_for_first' => '+ <code>shift</code> to skip to the first article of page', + 'first_article' => 'Skip to the first article', 'next_page' => 'Skip to the next page', 'previous_page' => 'Skip to the previous page', - 'collapse_article' => 'Collapse current article', - 'auto_share' => 'Share current article', + 'collapse_article' => 'Collapse', + 'auto_share' => 'Share', + 'auto_share_help' => 'If there is only one sharing mode, it is used. Else modes are accessible by their number.', 'file_to_import' => 'File to import', 'import' => 'Import', @@ -137,7 +143,9 @@ return array ( 'or' => 'or', 'informations' => 'Information', + 'damn' => 'Damn!', 'feed_in_error' => 'This feed has encountered a problem. Please verify that it is always reachable then actualize it.', + 'feed_empty' => 'This feed is empty. Please verify that it is still maintained.', 'feed_description' => 'Description', 'website_url' => 'Website URL', 'feed_url' => 'Feed URL', @@ -168,6 +176,7 @@ return array ( 'password_form' => 'Password<br /><small>(for the Web-form login method)</small>', 'persona_connection_email' => 'Login mail address<br /><small>(for <a href="https://persona.org/" rel="external">Mozilla Persona</a>)</small>', 'allow_anonymous' => 'Allow anonymous reading of the articles of the default user (%s)', + 'allow_anonymous_refresh' => 'Allow anonymous refresh of the articles', 'auth_token' => 'Authentication token', 'explain_token' => 'Allows to access RSS output of the default user without authentication.<br /><kbd>%s?output=rss&token=%s</kbd>', 'login_configuration' => 'Login', @@ -241,6 +250,7 @@ return array ( 'rss_feeds_of' => 'RSS feed of %s', 'refresh' => 'Refresh', + 'no_feed_to_refresh' => 'There is no feed to refresh…', 'today' => 'Today', 'yesterday' => 'Yesterday', @@ -267,7 +277,7 @@ return array ( 'logs_empty' => 'Log file is empty', 'clear_logs' => 'Clear the logs', - 'forbidden_access' => 'Access forbidden! (%s)', + 'forbidden_access' => 'Access is forbidden!', 'login_required' => 'Login required:', 'confirm_action' => 'Are you sure you want to perform this action? It cannot be cancelled!', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 9ab06ba26..ab7843d12 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -3,6 +3,7 @@ return array ( // LAYOUT 'login' => 'Connexion', + 'login_with_persona' => 'Connexion avec Persona', 'logout' => 'Déconnexion', 'search' => 'Rechercher des mots ou des #tags', 'search_short' => 'Rechercher', @@ -78,6 +79,10 @@ return array ( 'bad_opml_file' => 'Votre fichier OPML n’est pas valide', 'shortcuts_updated' => 'Les raccourcis ont été mis à jour', 'shortcuts_management' => 'Gestion des raccourcis', + 'shortcuts_navigation' => 'Navigation', + 'shortcuts_navigation_help' => 'Avec le modificateur "Shift", les raccourcis de navigation s’appliquent aux flux.<br/>Avec le modificateur "Alt", les raccourcis de navigation s’appliquent aux catégories.', + 'shortcuts_article_action' => 'Actions associées à l’article courant', + 'shortcuts_other_action' => 'Autres actions', 'feeds_marked_read' => 'Les flux ont été marqués comme lus', 'updated' => 'Modifications enregistrées', @@ -121,15 +126,16 @@ return array ( 'javascript_for_shortcuts' => 'Le JavaScript doit être activé pour pouvoir profiter des raccourcis', 'javascript_should_be_activated'=> 'Le JavaScript doit être activé', 'shift_for_all_read' => '+ <code>shift</code> pour marquer tous les articles comme lus', - 'see_on_website' => 'Voir l’article sur le site d’origine', + 'see_on_website' => 'Voir sur le site d’origine', 'next_article' => 'Passer à l’article suivant', - 'shift_for_last' => '+ <code>shift</code> pour passer au dernier article de la page', + 'last_article' => 'Passer au dernier article', 'previous_article' => 'Passer à l’article précédent', - 'shift_for_first' => '+ <code>shift</code> pour passer au premier article de la page', + 'first_article' => 'Passer au premier article', 'next_page' => 'Passer à la page suivante', 'previous_page' => 'Passer à la page précédente', - 'collapse_article' => 'Refermer l’article courant', - 'auto_share' => 'Partager l’article courant', + 'collapse_article' => 'Refermer', + 'auto_share' => 'Partager', + 'auto_share_help' => 'Si il n’y a qu’un mode de partage, celui ci est utilisé automatiquement. Sinon ils sont accessibles par leur numéro.', 'file_to_import' => 'Fichier à importer', 'import' => 'Importer', @@ -137,7 +143,9 @@ return array ( 'or' => 'ou', 'informations' => 'Informations', + 'damn' => 'Arf !', 'feed_in_error' => 'Ce flux a rencontré un problème. Veuillez vérifier qu’il est toujours accessible puis actualisez-le.', + 'feed_empty' => 'Ce flux est vide. Veuillez vérifier qu’il est toujours maintenu.', 'feed_description' => 'Description', 'website_url' => 'URL du site', 'feed_url' => 'URL du flux', @@ -168,6 +176,7 @@ return array ( 'default_user' => 'Nom de l’utilisateur par défaut <small>(16 caractères alphanumériques maximum)</small>', 'persona_connection_email' => 'Adresse courriel de connexion<br /><small>(pour <a href="https://persona.org/" rel="external">Mozilla Persona</a>)</small>', 'allow_anonymous' => 'Autoriser la lecture anonyme des articles de l’utilisateur par défaut (%s)', + 'allow_anonymous_refresh' => 'Autoriser le rafraîchissement anonyme des flux', 'auth_token' => 'Jeton d’identification', 'explain_token' => 'Permet d’accéder à la sortie RSS de l’utilisateur par défaut sans besoin de s’authentifier.<br /><kbd>%s?output=rss&token=%s</kbd>', 'login_configuration' => 'Identification', @@ -241,6 +250,7 @@ return array ( 'rss_feeds_of' => 'Flux RSS de %s', 'refresh' => 'Actualisation', + 'no_feed_to_refresh' => 'Il n’y a aucun flux à actualiser…', 'today' => 'Aujourd’hui', 'yesterday' => 'Hier', @@ -267,7 +277,7 @@ return array ( 'logs_empty' => 'Les logs sont vides', 'clear_logs' => 'Effacer les logs', - 'forbidden_access' => 'Accès interdit ! (%s)', + 'forbidden_access' => 'L’accès vous est interdit !', 'login_required' => 'Accès protégé par mot de passe :', 'confirm_action' => 'Êtes-vous sûr(e) de vouloir continuer ? Cette action ne peut être annulée !', diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 8454b4459..817dae676 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -20,7 +20,7 @@ } ?> <li> - <div class="category all"> + <div class="category all<?php echo $this->get_c == 'a' ? ' active' : ''; ?>"> <a data-unread="<?php echo formatNumber($this->nb_not_read); ?>" class="btn<?php echo $this->get_c == 'a' ? ' active' : ''; ?>" href="<?php echo Minz_Url::display($arUrl); ?>"> <?php echo FreshRSS_Themes::icon('all'); ?> <?php echo Minz_Translate::t ('main_stream'); ?> @@ -29,7 +29,7 @@ </li> <li> - <div class="category favorites"> + <div class="category favorites<?php echo $this->get_c == 's' ? ' active' : ''; ?>"> <a data-unread="<?php echo formatNumber($this->nb_favorites['unread']); ?>" class="btn<?php echo $this->get_c == 's' ? ' active' : ''; ?>" href="<?php $arUrl['params']['get'] = 's'; echo Minz_Url::display($arUrl); ?>"> <?php echo FreshRSS_Themes::icon('bookmark'); ?> <?php echo Minz_Translate::t('favorite_feeds', formatNumber($this->nb_favorites['all'])); ?> diff --git a/app/layout/header.phtml b/app/layout/header.phtml index eef53a3fd..d20f7487f 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -75,8 +75,8 @@ if (Minz_Configuration::canLogIn()) { <li class="item"><a href="<?php echo _url ('configure', 'users'); ?>"><?php echo Minz_Translate::t ('users'); ?></a></li> <li class="separator"></li> <li class="item"><a href="<?php echo _url ('index', 'stats'); ?>"><?php echo Minz_Translate::t ('stats'); ?></a></li> - <li class="item"><a href="<?php echo _url ('index', 'about'); ?>"><?php echo Minz_Translate::t ('about'); ?></a></li> <li class="item"><a href="<?php echo _url ('index', 'logs'); ?>"><?php echo Minz_Translate::t ('logs'); ?></a></li> + <li class="item"><a href="<?php echo _url ('index', 'about'); ?>"><?php echo Minz_Translate::t ('about'); ?></a></li> <?php if (Minz_Configuration::canLogIn()) { ?><li class="separator"></li><?php diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index d6a1737ee..1501df3c3 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -36,13 +36,18 @@ </div> <?php + $msg = ''; + $status = 'closed'; if (isset ($this->notification)) { + $msg = $this->notification['content']; + $status = $this->notification['type']; + invalidateHttpCache(); + } ?> -<div class="notification <?php echo $this->notification['type']; ?>"> - <?php echo $this->notification['content']; ?> +<div id="notification" class="<?php echo $status; ?>"> + <span class="msg"><?php echo $msg; ?></span> <a class="close" href=""><?php echo FreshRSS_Themes::icon('close'); ?></a> </div> -<?php } ?> </body> </html> diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index c807e6dd5..98064a6f7 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -6,9 +6,11 @@ <a class="btn toggle_aside" href="#aside_flux"><?php echo FreshRSS_Themes::icon('category'); ?></a> <?php } ?> - <?php if ($this->loginOk) { ?> + <?php if ($this->loginOk || Minz_Configuration::allowAnonymousRefresh()) { ?> <a id="actualize" class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><?php echo FreshRSS_Themes::icon('refresh'); ?></a> + <?php } ?> + <?php if ($this->loginOk) { ?> <?php $get = false; $string_mark = Minz_Translate::t ('mark_all_read'); diff --git a/app/sql.php b/app/sql.php index 1b43da30a..5cd7c52ed 100644 --- a/app/sql.php +++ b/app/sql.php @@ -3,7 +3,6 @@ define('SQL_CREATE_TABLES', ' CREATE TABLE IF NOT EXISTS `%1$scategory` ( `id` SMALLINT NOT NULL AUTO_INCREMENT, -- v0.7 `name` varchar(255) NOT NULL, - `color` char(7), PRIMARY KEY (`id`), UNIQUE KEY (`name`) -- v0.7 ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 138808a9f..2da04ac2d 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -7,8 +7,12 @@ <h1><?php echo $this->flux->name (); ?></h1> <?php echo $this->flux->description (); ?> + <?php $nbEntries = $this->flux->nbEntries (); ?> + <?php if ($this->flux->inError ()) { ?> <p class="alert alert-error"><span class="alert-head"><?php echo Minz_Translate::t ('damn'); ?></span> <?php echo Minz_Translate::t ('feed_in_error'); ?></p> + <?php } elseif ($nbEntries === 0) { ?> + <p class="alert alert-warn"><?php echo Minz_Translate::t ('feed_empty'); ?></p> <?php } ?> <form method="post" action="<?php echo _url ('configure', 'feed', 'id', $this->flux->id ()); ?>" autocomplete="off"> @@ -81,7 +85,7 @@ <div class="form-group"> <label class="group-name"><?php echo Minz_Translate::t ('number_articles'); ?></label> <div class="group-controls"> - <span class="control"><?php echo $this->flux->nbEntries (); ?></span> + <span class="control"><?php echo $nbEntries; ?></span> </div> </div> <div class="form-group"> diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtml index b0867f711..748a65d17 100644 --- a/app/views/configure/shortcut.phtml +++ b/app/views/configure/shortcut.phtml @@ -16,55 +16,59 @@ <noscript><p class="alert alert-error"><?php echo Minz_Translate::t ('javascript_for_shortcuts'); ?></p></noscript> + <legend><?php echo Minz_Translate::t ('shortcuts_navigation'); ?></legend> + <div class="form-group"> - <label class="group-name" for="mark_read"><?php echo Minz_Translate::t ('mark_read'); ?></label> + <label class="group-name" for="next_entry"><?php echo Minz_Translate::t ('next_article'); ?></label> <div class="group-controls"> - <input type="text" id="mark_read" name="shortcuts[mark_read]" list="keys" value="<?php echo $s['mark_read']; ?>" /> - <?php echo Minz_Translate::t ('shift_for_all_read'); ?> + <input type="text" id="next_entry" name="shortcuts[next_entry]" list="keys" value="<?php echo $s['next_entry']; ?>" /> </div> </div> <div class="form-group"> - <label class="group-name" for="mark_favorite"><?php echo Minz_Translate::t ('mark_favorite'); ?></label> + <label class="group-name" for="prev_entry"><?php echo Minz_Translate::t ('previous_article'); ?></label> <div class="group-controls"> - <input type="text" id="mark_favorite" name="shortcuts[mark_favorite]" list="keys" value="<?php echo $s['mark_favorite']; ?>" /> + <input type="text" id="prev_entry" name="shortcuts[prev_entry]" list="keys" value="<?php echo $s['prev_entry']; ?>" /> </div> </div> <div class="form-group"> - <label class="group-name" for="go_website"><?php echo Minz_Translate::t ('see_on_website'); ?></label> + <label class="group-name" for="first_entry"><?php echo Minz_Translate::t ('first_article'); ?></label> <div class="group-controls"> - <input type="text" id="go_website" name="shortcuts[go_website]" list="keys" value="<?php echo $s['go_website']; ?>" /> + <input type="text" id="first_entry" name="shortcuts[first_entry]" list="keys" value="<?php echo $s['first_entry']; ?>" /> </div> </div> <div class="form-group"> - <label class="group-name" for="next_entry"><?php echo Minz_Translate::t ('next_article'); ?></label> + <label class="group-name" for="last_entry"><?php echo Minz_Translate::t ('last_article'); ?></label> <div class="group-controls"> - <input type="text" id="next_entry" name="shortcuts[next_entry]" list="keys" value="<?php echo $s['next_entry']; ?>" /> - <?php echo Minz_Translate::t ('shift_for_last'); ?> + <input type="text" id="last_entry" name="shortcuts[last_entry]" list="keys" value="<?php echo $s['last_entry']; ?>" /> </div> </div> + <div><?php echo Minz_Translate::t ('shortcuts_navigation_help');?></div> + + <legend><?php echo Minz_Translate::t ('shortcuts_article_action');?></legend> + <div class="form-group"> - <label class="group-name" for="prev_entry"><?php echo Minz_Translate::t ('previous_article'); ?></label> + <label class="group-name" for="mark_read"><?php echo Minz_Translate::t ('mark_read'); ?></label> <div class="group-controls"> - <input type="text" id="prev_entry" name="shortcuts[prev_entry]" list="keys" value="<?php echo $s['prev_entry']; ?>" /> - <?php echo Minz_Translate::t ('shift_for_first'); ?> + <input type="text" id="mark_read" name="shortcuts[mark_read]" list="keys" value="<?php echo $s['mark_read']; ?>" /> + <?php echo Minz_Translate::t ('shift_for_all_read'); ?> </div> </div> <div class="form-group"> - <label class="group-name" for="collapse_entry"><?php echo Minz_Translate::t ('collapse_article'); ?></label> + <label class="group-name" for="mark_favorite"><?php echo Minz_Translate::t ('mark_favorite'); ?></label> <div class="group-controls"> - <input type="text" id="collapse_entry" name="shortcuts[collapse_entry]" list="keys" value="<?php echo $s['collapse_entry']; ?>" /> + <input type="text" id="mark_favorite" name="shortcuts[mark_favorite]" list="keys" value="<?php echo $s['mark_favorite']; ?>" /> </div> </div> <div class="form-group"> - <label class="group-name" for="load_more_shortcut"><?php echo Minz_Translate::t ('load_more'); ?></label> + <label class="group-name" for="go_website"><?php echo Minz_Translate::t ('see_on_website'); ?></label> <div class="group-controls"> - <input type="text" id="load_more_shortcut" name="shortcuts[load_more]" list="keys" value="<?php echo $s['load_more']; ?>" /> + <input type="text" id="go_website" name="shortcuts[go_website]" list="keys" value="<?php echo $s['go_website']; ?>" /> </div> </div> @@ -72,6 +76,23 @@ <label class="group-name" for="auto_share_shortcut"><?php echo Minz_Translate::t ('auto_share'); ?></label> <div class="group-controls"> <input type="text" id="auto_share_shortcut" name="shortcuts[auto_share]" list="keys" value="<?php echo $s['auto_share']; ?>" /> + <?php echo Minz_Translate::t ('auto_share_help'); ?> + </div> + </div> + + <div class="form-group"> + <label class="group-name" for="collapse_entry"><?php echo Minz_Translate::t ('collapse_article'); ?></label> + <div class="group-controls"> + <input type="text" id="collapse_entry" name="shortcuts[collapse_entry]" list="keys" value="<?php echo $s['collapse_entry']; ?>" /> + </div> + </div> + + <legend><?php echo Minz_Translate::t ('shortcuts_other_action');?></legend> + + <div class="form-group"> + <label class="group-name" for="load_more_shortcut"><?php echo Minz_Translate::t ('load_more'); ?></label> + <div class="group-controls"> + <input type="text" id="load_more_shortcut" name="shortcuts[load_more]" list="keys" value="<?php echo $s['load_more']; ?>" /> </div> </div> diff --git a/app/views/configure/users.phtml b/app/views/configure/users.phtml index 8ab4c04ba..1305feac9 100644 --- a/app/views/configure/users.phtml +++ b/app/views/configure/users.phtml @@ -20,7 +20,7 @@ <div class="form-group"> <label class="group-name" for="passwordPlain"><?php echo Minz_Translate::t('password_form'); ?></label> <div class="group-controls"> - <input type="password" id="passwordPlain" name="passwordPlain" pattern=".{7,}" /> + <input type="password" id="passwordPlain" name="passwordPlain" autocomplete="off" pattern=".{7,}" /> <noscript><b><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></b></noscript> </div> </div> @@ -29,7 +29,7 @@ <label class="group-name" for="mail_login"><?php echo Minz_Translate::t('persona_connection_email'); ?></label> <?php $mail = $this->conf->mail_login; ?> <div class="group-controls"> - <input type="email" id="mail_login" name="mail_login" class="extend" value="<?php echo $mail; ?>" <?php echo Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_')) ? '' : 'disabled="disabled"'; ?> placeholder="alice@example.net" /> + <input type="email" id="mail_login" name="mail_login" class="extend" autocomplete="off" value="<?php echo $mail; ?>" <?php echo Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_')) ? '' : 'disabled="disabled"'; ?> placeholder="alice@example.net" /> <noscript><b><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></b></noscript> </div> </div> @@ -70,6 +70,16 @@ </div> </div> + <div class="form-group"> + <div class="group-controls"> + <label class="checkbox" for="anon_refresh"> + <input type="checkbox" name="anon_refresh" id="anon_refresh" value="1"<?php echo Minz_Configuration::allowAnonymousRefresh() ? ' checked="checked"' : '', + Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> /> + <?php echo Minz_Translate::t('allow_anonymous_refresh'); ?> + </label> + </div> + </div> + <?php if (Minz_Configuration::canLogIn()) { ?> <div class="form-group"> <label class="group-name" for="token"><?php echo Minz_Translate::t('auth_token'); ?></label> @@ -129,14 +139,14 @@ <div class="form-group"> <label class="group-name" for="new_user_name"><?php echo Minz_Translate::t('username'); ?></label> <div class="group-controls"> - <input id="new_user_name" name="new_user_name" type="text" size="16" required="required" maxlength="16" pattern="[0-9a-zA-Z]{1,16}" placeholder="demo" /> + <input id="new_user_name" name="new_user_name" type="text" size="16" required="required" maxlength="16" autocomplete="off" pattern="[0-9a-zA-Z]{1,16}" placeholder="demo" /> </div> </div> <div class="form-group"> <label class="group-name" for="new_user_passwordPlain"><?php echo Minz_Translate::t('password_form'); ?></label> <div class="group-controls"> - <input type="password" id="new_user_passwordPlain" name="new_user_passwordPlain" pattern=".{7,}" /> + <input type="password" id="new_user_passwordPlain" name="new_user_passwordPlain" autocomplete="off" pattern=".{7,}" /> <noscript><b><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></b></noscript> </div> </div> @@ -145,7 +155,7 @@ <label class="group-name" for="new_user_email"><?php echo Minz_Translate::t('persona_connection_email'); ?></label> <?php $mail = $this->conf->mail_login; ?> <div class="group-controls"> - <input type="email" id="new_user_email" name="new_user_email" class="extend" placeholder="alice@example.net" /> + <input type="email" id="new_user_email" name="new_user_email" class="extend" autocomplete="off" placeholder="alice@example.net" /> </div> </div> diff --git a/app/views/error/index.phtml b/app/views/error/index.phtml index 36fcb56f9..6a09c3aa2 100644 --- a/app/views/error/index.phtml +++ b/app/views/error/index.phtml @@ -3,7 +3,15 @@ <h1 class="alert-head"><?php echo $this->code; ?></h1> <p> - <?php echo Minz_Translate::t ('page_not_found'); ?><br /> + <?php + switch(Minz_Request::param ('code')) { + case 403: + echo Minz_Translate::t ('forbidden_access'); + break; + case 404: + default: + echo Minz_Translate::t ('page_not_found'); + } ?><br /> <a href="<?php echo _url ('index', 'index'); ?>"><?php echo Minz_Translate::t ('back_to_rss_feeds'); ?></a> </p> </div> diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 0ecdc1bca..3d7c8a98f 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -19,6 +19,8 @@ echo ',shortcuts={', 'go_website:"', $s['go_website'], '",', 'prev_entry:"', $s['prev_entry'], '",', 'next_entry:"', $s['next_entry'], '",', + 'first_entry:"', $s['first_entry'], '",', + 'last_entry:"', $s['last_entry'], '",', 'collapse_entry:"', $s['collapse_entry'], '",', 'load_more:"', $s['load_more'], '",', 'auto_share:"', $s['auto_share'], '"', @@ -30,7 +32,13 @@ if (Minz_Request::param ('output') === 'global') { $authType = Minz_Configuration::authType(); if ($authType === 'persona') { - echo 'current_user_mail="' . Minz_Session::param ('mail', '') . '",'; + // If user is disconnected, current_user_mail MUST be null + $mail = Minz_Session::param ('mail', false); + if ($mail) { + echo 'current_user_mail="' . $mail . '",'; + } else { + echo 'current_user_mail=null,'; + } } echo 'authType="', $authType, '",', diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml index 7b7faccee..ae93b627c 100644 --- a/app/views/helpers/view/normal_view.phtml +++ b/app/views/helpers/view/normal_view.phtml @@ -147,49 +147,49 @@ if (!empty($this->entries)) { <ul class="dropdown-menu"> <li class="dropdown-close"><a href="#close">❌</a></li> <?php if ($shaarli) { ?> - <li class="item"> + <li class="item share"> <a target="_blank" href="<?php echo $shaarli . '?post=' . $link . '&title=' . $title . '&source=FreshRSS'; ?>"> <?php echo Minz_Translate::t ('shaarli'); ?> </a> </li> <?php } if ($wallabag) { ?> - <li class="item"> + <li class="item share"> <a target="_blank" href="<?php echo $wallabag . '?action=add&url=' . base64_encode (urldecode($link)); ?>"> <?php echo Minz_Translate::t ('wallabag'); ?> </a> </li> <?php } if ($diaspora) { ?> - <li class="item"> + <li class="item share"> <a target="_blank" href="<?php echo $diaspora . '/bookmarklet?url=' . $link . '&title=' . $title; ?>"> <?php echo Minz_Translate::t ('diaspora'); ?> </a> </li> <?php } if ($twitter) { ?> - <li class="item"> + <li class="item share"> <a target="_blank" href="https://twitter.com/share?url=<?php echo $link; ?>&text=<?php echo $title; ?>"> <?php echo Minz_Translate::t ('twitter'); ?> </a> </li> <?php } if ($google_plus) { ?> - <li class="item"> + <li class="item share"> <a target="_blank" href="https://plus.google.com/share?url=<?php echo $link; ?>"> <?php echo Minz_Translate::t ('g+'); ?> </a> </li> <?php } if ($facebook) { ?> - <li class="item"> + <li class="item share"> <a target="_blank" href="https://www.facebook.com/sharer.php?u=<?php echo $link; ?>&t=<?php echo $title; ?>"> <?php echo Minz_Translate::t ('facebook'); ?> </a> </li> <?php } if ($email) { ?> - <li class="item"> + <li class="item share"> <a href="mailto:?subject=<?php echo urldecode($title); ?>&body=<?php echo $link; ?>"> <?php echo Minz_Translate::t ('by_email'); ?> </a> </li> <?php } if ($print) { ?> - <li class="item"> + <li class="item share"> <a href="#" class="print-article"> <?php echo Minz_Translate::t ('print'); ?> </a> diff --git a/app/views/index/formLogin.phtml b/app/views/index/formLogin.phtml index e4560c1a0..cc925ea59 100644 --- a/app/views/index/formLogin.phtml +++ b/app/views/index/formLogin.phtml @@ -1,34 +1,32 @@ <div class="prompt"> -<?php -if (Minz_Configuration::canLogIn()) { - ?><h1><?php echo Minz_Translate::t('login'); ?></h1><?php - switch (Minz_Configuration::authType()) { + <h1><?php echo Minz_Translate::t('login'); ?></h1><?php - case 'form': - ?><form id="loginForm" method="post" action="<?php echo _url('index', 'formLogin'); ?>"> - <p> - <label for="username"><?php echo Minz_Translate::t('username'); ?></label> - <input type="text" id="username" name="username" size="16" required="required" maxlength="16" pattern="[0-9a-zA-Z]{1,16}" autofocus="autofocus" /> - </p><p> - <label for="passwordPlain"><?php echo Minz_Translate::t('password'); ?></label> - <input type="password" id="passwordPlain" required="required" /> - <input type="hidden" id="challenge" name="challenge" /><br /> - <noscript><strong><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></strong></noscript> - </p><p> - <button id="loginButton" type="submit" class="btn btn-important"><?php echo Minz_Translate::t('login'); ?></button> - </p> - </form><?php - break; + switch (Minz_Configuration::authType()) { + case 'form': + ?><form id="loginForm" method="post" action="<?php echo _url('index', 'formLogin'); ?>"> + <div> + <label for="username"><?php echo Minz_Translate::t('username'); ?></label> + <input type="text" id="username" name="username" size="16" required="required" maxlength="16" pattern="[0-9a-zA-Z]{1,16}" autofocus="autofocus" /> + </div> + <div> + <label for="passwordPlain"><?php echo Minz_Translate::t('password'); ?></label> + <input type="password" id="passwordPlain" required="required" /> + <input type="hidden" id="challenge" name="challenge" /><br /> + <noscript><strong><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></strong></noscript> + </div> + <div> + <button id="loginButton" type="submit" class="btn btn-important"><?php echo Minz_Translate::t('login'); ?></button> + </div> + </form><?php + break; - case 'persona': - ?><p><?php echo FreshRSS_Themes::icon('login'); ?> <a class="signin" href="#"><?php echo Minz_Translate::t('login'); ?></a></p><?php - break; - } -} else { - ?><h1>FreshRSS</h1> - <p><?php echo Minz_Translate::t('forbidden_access', Minz_Configuration::authType()); ?></p><?php -} -?> + case 'persona': + ?><p> + <?php echo FreshRSS_Themes::icon('login'); ?> + <a class="signin" href="#"><?php echo Minz_Translate::t('login_with_persona'); ?></a> + </p><?php + break; + } ?> -<p><a href="<?php echo _url('index', 'about'); ?>"><?php echo Minz_Translate::t('about_freshrss'); ?></a></p> + <p><a href="<?php echo _url('index', 'about'); ?>"><?php echo Minz_Translate::t('about_freshrss'); ?></a></p> </div> diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 4545a33e4..1ff36ca8e 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -5,26 +5,21 @@ $output = Minz_Request::param ('output', 'normal'); if ($this->loginOk || Minz_Configuration::allowAnonymous()) { if ($output === 'normal') { $this->renderHelper ('view/normal_view'); - } elseif ($output === 'rss') { - $this->renderHelper ('view/rss_view'); } elseif ($output === 'reader') { $this->renderHelper ('view/reader_view'); } elseif ($output === 'global') { $this->renderHelper ('view/global_view'); + } elseif ($output === 'rss') { + $this->renderHelper ('view/rss_view'); } else { Minz_Request::_param ('output', 'normal'); $output = 'normal'; $this->renderHelper ('view/normal_view'); } } elseif ($output === 'rss') { - $token = $this->conf->token; - $token_param = Minz_Request::param ('token', ''); - $token_is_ok = ($token != '' && $token == $token_param); - if ($token_is_ok) { - $this->renderHelper ('view/rss_view'); - } else { - Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin'), true); - } + // token has already been checked in the controller so we can show the view + $this->renderHelper ('view/rss_view'); } else { - Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin'), true); + // Normally, it should not happen, but log it anyway + Minz_Log::record ('Something is wrong in ' . __FILE__ . ' line ' . __LINE__, Minz_Log::ERROR); } diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml index 1f6072c29..3b12ad774 100644 --- a/app/views/javascript/actualize.phtml +++ b/app/views/javascript/actualize.phtml @@ -1,14 +1,17 @@ "use strict"; -var feeds = []; -<?php foreach ($this->feeds as $feed) { ?> -feeds.push("<?php echo Minz_Url::display (array ('c' => 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>"); -<?php } ?> +var feeds = [<?php + foreach ($this->feeds as $feed) { + echo "'", Minz_Url::display(array('c' => 'feed', 'a' => 'actualize', 'params' => array('id' => $feed->id(), 'ajax' => '1')), 'php'), "',\n"; + } + ?>], + feed_processed = 0, + feed_count = feeds.length; function initProgressBar(init) { if (init) { $("body").after("\<div id=\"actualizeProgress\" class=\"actualizeProgress\">\ - <?php echo Minz_Translate::t ('refresh'); ?> <span class=\"progress\">0 / " + feeds.length + "</span><br />\ - <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feeds.length + "\"></progress>\ + <?php echo Minz_Translate::t ('refresh'); ?> <span class=\"progress\">0 / " + feed_count + "</span><br />\ + <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feed_count + "\"></progress>\ </div>"); } else { window.location.reload(); @@ -16,27 +19,37 @@ function initProgressBar(init) { } function updateProgressBar(i) { $("#actualizeProgressBar").val(i); - $("#actualizeProgress .progress").html(i + " / " + feeds.length); + $("#actualizeProgress .progress").html(i + " / " + feed_count); } function updateFeeds() { - if (feeds.length === 0) { + if (feed_count === 0) { + openNotification("<?php echo Minz_Translate::t ('no_feed_to_refresh'); ?>", "good"); return; } initProgressBar(true); - var i = 0; - for (var f in feeds) { - $.ajax({ - type: 'POST', - url: feeds[f], - }).done(function (data) { - i++; - updateProgressBar(i); + for (var i = 0; i < 10; i++) { + updateFeed(); + } +} - if (i === feeds.length) { - initProgressBar(false); - } - }); +function updateFeed() { + var feed = feeds.pop(); + if (feed == undefined) { + return; } + $.ajax({ + type: 'POST', + url: feed, + }).complete(function (data) { + feed_processed++; + updateProgressBar(feed_processed); + + if (feed_processed === feed_count) { + initProgressBar(false); + } else { + updateFeed(); + } + }); } |
