From 97c3c7575a586382ea87f8faa1e9e78afb64710a Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 10 Nov 2013 19:45:48 +0100 Subject: Suppression des warnings liés à filemtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ajout de "@" pour éviter les warnings, touch.txt sera créé un peu plus tard --- public/index.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'public/index.php') diff --git a/public/index.php b/public/index.php index b5333c5c0..d3b752905 100755 --- a/public/index.php +++ b/public/index.php @@ -30,11 +30,13 @@ if (file_exists (PUBLIC_PATH . '/install.php')) { } else { session_cache_limiter(''); require (LIB_PATH . '/http-conditional.php'); - $dateLastModification = max(filemtime(PUBLIC_PATH . '/data/touch.txt'), + $dateLastModification = max( + @filemtime(PUBLIC_PATH . '/data/touch.txt'), @filemtime(LOG_PATH . '/application.log'), - filemtime(PUBLIC_PATH . '/data/Configuration.array.php'), - filemtime(APP_PATH . '/configuration/application.ini'), - time() - 14400); + @filemtime(PUBLIC_PATH . '/data/Configuration.array.php'), + @filemtime(APP_PATH . '/configuration/application.ini'), + time() - 14400 + ); if (httpConditional($dateLastModification, 0, 0, false, false, true)) { exit(); //No need to send anything } -- cgit v1.2.3 From 3bd4e808789b53ed6b338f4dbe42494b00ae1251 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 10 Nov 2013 20:19:41 +0100 Subject: Suppression limitateur de cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le cache semble bien fonctionner. Suppression de la limite de 4 heures utilisée pour la 0.6 --- public/index.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'public/index.php') diff --git a/public/index.php b/public/index.php index d3b752905..dc6da259d 100755 --- a/public/index.php +++ b/public/index.php @@ -34,8 +34,7 @@ if (file_exists (PUBLIC_PATH . '/install.php')) { @filemtime(PUBLIC_PATH . '/data/touch.txt'), @filemtime(LOG_PATH . '/application.log'), @filemtime(PUBLIC_PATH . '/data/Configuration.array.php'), - @filemtime(APP_PATH . '/configuration/application.ini'), - time() - 14400 + @filemtime(APP_PATH . '/configuration/application.ini') ); if (httpConditional($dateLastModification, 0, 0, false, false, true)) { exit(); //No need to send anything -- cgit v1.2.3 From 4a2b17d54ab3714c4f567a43a7a2e701cd9a7b49 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 16 Nov 2013 22:41:03 +0100 Subject: Minz : nouveau Minz_Log::DEBUG Nouveau niveau Minz_Log::DEBUG pour plus de finesse dans les messages --- app/controllers/configureController.php | 2 +- app/controllers/feedController.php | 12 ++++++------ app/controllers/indexController.php | 4 ++-- lib/minz/Minz_Log.php | 23 ++++++++++++++--------- public/index.php | 5 +++-- public/themes/default/freshrss.css | 4 ++++ public/themes/flat-design/freshrss.css | 12 ++++++++---- 7 files changed, 38 insertions(+), 24 deletions(-) (limited to 'public/index.php') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 815f3f5f4..2856bb89f 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -302,7 +302,7 @@ class configureController extends ActionController { Request::_param ('feeds', $feeds); Request::forward (array ('c' => 'feed', 'a' => 'massiveImport')); } catch (OpmlException $e) { - Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); + Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); $notif = array ( 'type' => 'bad', diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 0ba82631c..e54a2ac12 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -105,14 +105,14 @@ class feedController extends ActionController { $params['id'] = $feed->id (); } } catch (BadUrlException $e) { - Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); + Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); $notif = array ( 'type' => 'bad', 'content' => Translate::t ('invalid_url', $url) ); Session::_param ('notification', $notif); } catch (FeedException $e) { - Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); + Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); $notif = array ( 'type' => 'bad', 'content' => Translate::t ('internal_problem_feed') @@ -159,9 +159,9 @@ class feedController extends ActionController { $nb_month_old = $this->view->conf->oldEntries (); $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old); if (rand(0, 30) === 1) { - Minz_Log::record ('CleanOldEntries', Minz_Log::NOTICE); //TODO: Remove + Minz_Log::record ('CleanOldEntries', Minz_Log::DEBUG); if ($entryDAO->cleanOldEntries ($date_min) > 0) { - Minz_Log::record ('UpdateCachedValues', Minz_Log::NOTICE); //TODO: Remove + Minz_Log::record ('UpdateCachedValues', Minz_Log::DEBUG); $feedDAO->updateCachedValues (); } } @@ -196,7 +196,7 @@ class feedController extends ActionController { $feedDAO->commit (); $flux_update++; } catch (FeedException $e) { - Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); + Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); $feedDAO->updateLastUpdate ($feed->id (), 1); } @@ -298,7 +298,7 @@ class feedController extends ActionController { } } catch (FeedException $e) { $error = true; - Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); + Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); } } diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 10c29bc7b..224d6fb9e 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -123,7 +123,7 @@ class indexController extends ActionController { // Si on a récupéré aucun article "non lus" // on essaye de récupérer tous les articles if ($state === 'not_read' && $entries->isEmpty ()) { //TODO: Remove in v0.8 - Minz_Log::record ('Conflicting information about nbNotRead!', Minz_Log::NOTICE); //TODO: Consider adding a Minz_Log::DEBUG level + Minz_Log::record ('Conflicting information about nbNotRead!', Minz_Log::DEBUG); $this->view->state = 'all'; $getter->_state ('all'); $getter->execute (); @@ -131,7 +131,7 @@ class indexController extends ActionController { } $this->view->entryPaginator = $entries; - } catch(EntriesGetterException $e) { + } catch (EntriesGetterException $e) { Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); Error::error ( 404, diff --git a/lib/minz/Minz_Log.php b/lib/minz/Minz_Log.php index 153870435..e66cc040b 100644 --- a/lib/minz/Minz_Log.php +++ b/lib/minz/Minz_Log.php @@ -12,11 +12,13 @@ class Minz_Log { * Les différents niveau de log * ERROR erreurs bloquantes de l'application * WARNING erreurs pouvant géner le bon fonctionnement, mais non bloquantes - * NOTICE messages d'informations, affichés pour le déboggage + * NOTICE erreurs mineures ou messages d'informations + * DEBUG Informations affichées pour le déboggage */ - const ERROR = 0; - const WARNING = 10; - const NOTICE = 20; + const ERROR = 2; + const WARNING = 4; + const NOTICE = 8; + const DEBUG = 16; /** * Enregistre un message dans un fichier de log spécifique @@ -31,9 +33,9 @@ class Minz_Log { public static function record ($information, $level, $file_name = null) { $env = Configuration::environment (); - if (! ($env == Configuration::SILENT - || ($env == Configuration::PRODUCTION - && ($level == Minz_Log::WARNING || $level == Minz_Log::NOTICE)))) { + if (! ($env === Configuration::SILENT + || ($env === Configuration::PRODUCTION + && ($level <= Minz_Log::NOTICE)))) { if (is_null ($file_name)) { $file_name = LOG_PATH . '/application.log'; } @@ -48,6 +50,9 @@ class Minz_Log { case Minz_Log::NOTICE : $level_label = 'notice'; break; + case Minz_Log::DEBUG : + $level_label = 'debug'; + break; default : $level_label = 'unknown'; } @@ -83,7 +88,7 @@ class Minz_Log { $msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true)); $msg_post = str_replace("\n", '', '$_POST content : ' . print_r($_POST, true)); - self::record($msg_get, Minz_Log::NOTICE, $file_name); - self::record($msg_post, Minz_Log::NOTICE, $file_name); + self::record($msg_get, Minz_Log::DEBUG, $file_name); + self::record($msg_post, Minz_Log::DEBUG, $file_name); } } diff --git a/public/index.php b/public/index.php index dc6da259d..1a1651707 100755 --- a/public/index.php +++ b/public/index.php @@ -54,8 +54,9 @@ if (file_exists (PUBLIC_PATH . '/install.php')) { $front_controller = new App_FrontController (); $front_controller->init (); $front_controller->run (); - } catch (PDOConnectionException $e) { + } catch (Exception $e) { + echo '### Fatal error! ###
', "\n"; Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); - print '### Application problem ###
'."\n".'See logs files'; + echo 'See logs files.'; } } diff --git a/public/themes/default/freshrss.css b/public/themes/default/freshrss.css index 81ff6d196..c8231f93d 100644 --- a/public/themes/default/freshrss.css +++ b/public/themes/default/freshrss.css @@ -677,6 +677,10 @@ background: #f4f4f4; color: #aaa; } + .log.debug { + background: #111; + color: #eee; + } .form-group table { border-collapse:collapse; diff --git a/public/themes/flat-design/freshrss.css b/public/themes/flat-design/freshrss.css index 498a02c1e..ef59abb4d 100644 --- a/public/themes/flat-design/freshrss.css +++ b/public/themes/flat-design/freshrss.css @@ -658,21 +658,25 @@ body { color: #666; font-size: 90%; } - .log .date { + .log>.date { margin: 0 10px 0 0; padding: 5px 10px; border-radius: 20px; } - .log.error .date { + .log.error>.date { background: #e74c3c; color: #fff; } - .log.warning .date { + .log.warning>.date { background: #f39c12; } - .log.notice .date { + .log.notice>.date { background: #ecf0f1; } + .log.debug>.date { + background: #111; + color: #eee; + } .form-group table { border-collapse:collapse; -- cgit v1.2.3 From b8c4afadf4bff7ac282ac5933eedccb1c666d873 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 17 Nov 2013 01:35:06 +0100 Subject: Nouveau fichier constants.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit En particulier pour stocker le numéro de version de FreshRSS utilisé entre autres par https://github.com/marienfressinaud/FreshRSS/issues/174 et centraliser les constantes de chemins Implémente https://github.com/marienfressinaud/FreshRSS/issues/271 --- actualize_script.php | 8 +------- app/models/Feed.php | 2 +- app/views/index/about.phtml | 2 +- constants.php | 10 ++++++++++ public/index.php | 7 +------ 5 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 constants.php (limited to 'public/index.php') diff --git a/actualize_script.php b/actualize_script.php index 45b2938cb..65f9360a0 100755 --- a/actualize_script.php +++ b/actualize_script.php @@ -1,11 +1,5 @@ set_useragent(Translate::t ('freshrss') . '/' . '0.7' . ' (' . PHP_OS . '; http://marienfressinaud.github.io/FreshRSS/) ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); + $feed->set_useragent(Translate::t ('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); $url = str_replace ('&', '&', $this->url); if ($this->httpAuth != '') { $url = preg_replace ('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url); diff --git a/app/views/index/about.phtml b/app/views/index/about.phtml index ca1254053..fa799154b 100644 --- a/app/views/index/about.phtml +++ b/app/views/index/about.phtml @@ -5,7 +5,7 @@
-
http://marienfressinaud.github.io/FreshRSS/
+
Marien Fressinaud -
diff --git a/constants.php b/constants.php new file mode 100644 index 000000000..260f01986 --- /dev/null +++ b/constants.php @@ -0,0 +1,10 @@ + Date: Sun, 17 Nov 2013 02:56:30 +0100 Subject: Réorganisation des fichiers utilisateur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implémente https://github.com/marienfressinaud/FreshRSS/issues/248 --- README.md | 2 +- actualize_script.php | 2 +- app/configuration/.gitignore | 1 - app/controllers/entryController.php | 2 +- app/controllers/indexController.php | 4 +-- app/i18n/en.php | 2 +- app/i18n/fr.php | 2 +- app/layout/layout.phtml | 2 +- app/models/Feed.php | 2 +- app/models/RSSConfiguration.php | 2 +- cache/.gitignore | 1 - constants.php | 13 ++++++---- data/.gitignore | 6 +++++ lib/lib_rss.php | 6 ++--- lib/minz/Configuration.php | 10 ++++---- lib/minz/dao/Model_pdo.php | 6 ++--- log/.gitignore | 1 - public/data/.gitignore | 4 --- public/data/grey.gif | Bin 56 -> 0 bytes public/index.php | 8 +++--- public/install.php | 47 ++++++++++++++++++------------------ public/themes/icons/grey.gif | Bin 0 -> 56 bytes 22 files changed, 61 insertions(+), 62 deletions(-) delete mode 100644 app/configuration/.gitignore delete mode 100644 cache/.gitignore create mode 100644 data/.gitignore delete mode 100644 log/.gitignore delete mode 100644 public/data/.gitignore delete mode 100644 public/data/grey.gif create mode 100644 public/themes/icons/grey.gif (limited to 'public/index.php') diff --git a/README.md b/README.md index 00df693e6..fb0b9e61e 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Privilégiez pour cela des demandes sur GitHub # Sécurité et conseils 1. Pour une meilleure sécurité, faites en sorte que seul le répertoire `./public` soit accessible par le navigateur. Faites pointer un sous-domaine sur le répertoire `./public` par exemple -2. Dans tous les cas, assurez-vous que `./app/configuration/application.ini` ne puisse pas être téléchargé ! +2. Dans tous les cas, assurez-vous que `./data/application.ini` ne puisse pas être téléchargé ! 3. Le fichier de log peut être utile à lire si vous avez des soucis 4. Le fichier `./public/index.php` défini les chemins d'accès aux répertoires clés de l'application. Si vous les bougez, tout se passe ici. 5. Vous pouvez ajouter une tâche CRON sur le script d'actualisation des flux. Il s'agit d'un script PHP à exécuter avec la commande `php`. Par exemple, pour exécuter le script toutes les heures : diff --git a/actualize_script.php b/actualize_script.php index 65f9360a0..bc1d108bd 100755 --- a/actualize_script.php +++ b/actualize_script.php @@ -20,4 +20,4 @@ $front_controller = new App_FrontController (); $front_controller->init (); Session::_param('mail', true); // permet de se passer de la phase de connexion $front_controller->run (); -touch(PUBLIC_PATH . '/data/touch.txt'); +touch(DATA_PATH . '/touch.txt'); diff --git a/app/configuration/.gitignore b/app/configuration/.gitignore deleted file mode 100644 index 72e8ffc0d..000000000 --- a/app/configuration/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index 4d2d92c1b..8016d719f 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -84,7 +84,7 @@ class entryController extends ActionController { $entryDAO = new EntryDAO(); $entryDAO->optimizeTable(); - touch(PUBLIC_PATH . '/data/touch.txt'); + touch(DATA_PATH . '/touch.txt'); $notif = array ( 'type' => 'good', diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 224d6fb9e..392abd3e1 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -277,7 +277,7 @@ class indexController extends ActionController { $res = json_decode ($result, true); if ($res['status'] == 'okay' && $res['email'] == $this->view->conf->mailLogin ()) { Session::_param ('mail', $res['email']); - touch(PUBLIC_PATH . '/data/touch.txt'); + touch(DATA_PATH . '/touch.txt'); } else { $res = array (); $res['status'] = 'failure'; @@ -290,6 +290,6 @@ class indexController extends ActionController { public function logoutAction () { $this->view->_useLayout (false); Session::_param ('mail'); - touch(PUBLIC_PATH . '/data/touch.txt'); + touch(DATA_PATH . '/touch.txt'); } } diff --git a/app/i18n/en.php b/app/i18n/en.php index eca1dd6d5..8243756bd 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -283,7 +283,7 @@ return array ( 'dom_is_nok' => 'You haven’t the necessary to browse the DOM (php-xml package can be useful)', 'cache_is_ok' => 'Permissions on cache directory are good', 'log_is_ok' => 'Permissions on logs directory are good', - 'conf_is_ok' => 'Permissions on configuration directory are good', + 'favicons_is_ok' => 'Permissions on favicons directory are good', 'data_is_ok' => 'Permissions on data directory are good', 'file_is_nok' => 'Check permissions on %s directory. HTTP server must have rights to write into', 'fix_errors_before' => 'Fix errors before skip to the next step.', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 2cddd4083..8040a6a44 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -283,7 +283,7 @@ return array ( 'dom_is_nok' => 'Vous ne disposez pas du nécessaire pour parcourir le DOM (voir du côté du paquet php-xml ?)', 'cache_is_ok' => 'Les droits sur le répertoire de cache sont bons', 'log_is_ok' => 'Les droits sur le répertoire des logs sont bons', - 'conf_is_ok' => 'Les droits sur le répertoire de configuration sont bons', + 'favicons_is_ok' => 'Les droits sur le répertoire des favicons sont bons', 'data_is_ok' => 'Les droits sur le répertoire de data sont bons', 'file_is_nok' => 'Veuillez vérifier les droits sur le répertoire %s. Le serveur HTTP doit être capable d’écrire dedans', 'fix_errors_before' => 'Veuillez corriger les erreurs avant de passer à l’étape suivante.', diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index ba4df4834..4232b714d 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -32,7 +32,7 @@ notification)) { - touch(PUBLIC_PATH . '/data/touch.txt', time() + 1); + touch(DATA_PATH . '/touch.txt', time() + 1); ?>
notification['content']; ?> diff --git a/app/models/Feed.php b/app/models/Feed.php index 2618d023f..adc8e1677 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -100,7 +100,7 @@ class Feed extends Model { return $this->nbNotRead; } public function favicon () { - $file = '/data/favicons/' . $this->id () . '.ico'; + $file = '/favicons/' . $this->id () . '.ico'; $favicon_url = Url::display ($file); if (!file_exists (PUBLIC_PATH . $file)) { diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index e79fd933b..f8379a625 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -348,7 +348,7 @@ class RSSConfigurationDAO extends Model_array { public $bottomline_link = 'yes'; public function __construct () { - parent::__construct (PUBLIC_PATH . '/data/Configuration.array.php'); + parent::__construct (DATA_PATH . '/Configuration.array.php'); // TODO : simplifier ce code, une boucle for() devrait suffir ! if (isset ($this->array['language'])) { diff --git a/cache/.gitignore b/cache/.gitignore deleted file mode 100644 index 72e8ffc0d..000000000 --- a/cache/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/constants.php b/constants.php index 260f01986..05d60b242 100644 --- a/constants.php +++ b/constants.php @@ -3,8 +3,11 @@ define('FRESHRSS_VERSION', '0.7-dev'); define('FRESHRSS_WEBSITE', 'http://marienfressinaud.github.io/FreshRSS/'); // Constantes de chemins -define ('PUBLIC_PATH', realpath (dirname (__FILE__) . '/public')); -define ('LIB_PATH', realpath (dirname (__FILE__) . '/lib')); -define ('APP_PATH', realpath (dirname (__FILE__) . '/app')); -define ('LOG_PATH', realpath (dirname (__FILE__) . '/log')); -define ('CACHE_PATH', realpath (dirname (__FILE__) . '/cache')); +define ('FRESHRSS_PATH', realpath (dirname (__FILE__))); +define ('PUBLIC_PATH', FRESHRSS_PATH . '/public'); +define ('DATA_PATH', FRESHRSS_PATH . '/data'); +define ('LIB_PATH', FRESHRSS_PATH . '/lib'); +define ('APP_PATH', FRESHRSS_PATH . '/app'); + +define ('LOG_PATH', DATA_PATH . '/log'); +define ('CACHE_PATH', DATA_PATH . '/cache'); diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 000000000..0e407f099 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1,6 @@ +cache +log +application.ini +Configuration.array.php +*.sqlite +touch.txt \ No newline at end of file diff --git a/lib/lib_rss.php b/lib/lib_rss.php index e4518ab4b..33f8641e1 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -168,9 +168,9 @@ function get_content_by_parsing ($url, $path) { /* Télécharge le favicon d'un site, le place sur le serveur et retourne l'URL */ function dowload_favicon ($website, $id) { $url = 'http://g.etfv.co/' . $website; - $favicons_dir = PUBLIC_PATH . '/data/favicons'; + $favicons_dir = PUBLIC_PATH . '/favicons'; $dest = $favicons_dir . '/' . $id . '.ico'; - $favicon_url = '/data/favicons/' . $id . '.ico'; + $favicon_url = '/favicons/' . $id . '.ico'; if (!is_dir ($favicons_dir)) { if (!mkdir ($favicons_dir, 0755, true)) { @@ -211,7 +211,7 @@ function dowload_favicon ($website, $id) { function lazyimg($content) { return preg_replace( '/]+?)src=[\'"]([^"\']+)[\'"]([^>]*)>/i', - '', + '', $content ); } diff --git a/lib/minz/Configuration.php b/lib/minz/Configuration.php index b296ec378..bdd6af0fb 100755 --- a/lib/minz/Configuration.php +++ b/lib/minz/Configuration.php @@ -8,7 +8,7 @@ * La classe Configuration permet de gérer la configuration de l'application */ class Configuration { - const CONF_PATH_NAME = '/configuration/application.ini'; + const CONF_PATH_NAME = '/application.ini'; /** * VERSION est la version actuelle de MINZ @@ -111,21 +111,21 @@ class Configuration { * @exception BadConfigurationException si CONF_PATH_NAME mal formaté */ private static function parseFile () { - if (!file_exists (APP_PATH . self::CONF_PATH_NAME)) { + if (!file_exists (DATA_PATH . self::CONF_PATH_NAME)) { throw new FileNotExistException ( - APP_PATH . self::CONF_PATH_NAME, + DATA_PATH . self::CONF_PATH_NAME, MinzException::ERROR ); } $ini_array = parse_ini_file ( - APP_PATH . self::CONF_PATH_NAME, + DATA_PATH . self::CONF_PATH_NAME, true ); if (!$ini_array) { throw new PermissionDeniedException ( - APP_PATH . self::CONF_PATH_NAME, + DATA_PATH . self::CONF_PATH_NAME, MinzException::ERROR ); } diff --git a/lib/minz/dao/Model_pdo.php b/lib/minz/dao/Model_pdo.php index dd75153be..beeb65ea8 100755 --- a/lib/minz/dao/Model_pdo.php +++ b/lib/minz/dao/Model_pdo.php @@ -49,9 +49,7 @@ class Model_pdo { PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' ); } elseif($type == 'sqlite') { - $string = $type - . ':/' . PUBLIC_PATH - . '/data/' . $db['base'] . '.sqlite'; //TODO: DEBUG UTF-8 http://www.siteduzero.com/forum/sujet/sqlite-connexion-utf-8-18797 + $string = $type . ':/' . DATA_PATH . $db['base'] . '.sqlite'; //TODO: DEBUG UTF-8 http://www.siteduzero.com/forum/sujet/sqlite-connexion-utf-8-18797 } $this->bd = new FreshPDO ( @@ -86,7 +84,7 @@ class Model_pdo { class FreshPDO extends PDO { private static function check($statement) { if (preg_match('/^(?:UPDATE|INSERT|DELETE)/i', $statement)) { - touch(PUBLIC_PATH . '/data/touch.txt'); + touch(DATA_PATH . '/touch.txt'); } } diff --git a/log/.gitignore b/log/.gitignore deleted file mode 100644 index 72e8ffc0d..000000000 --- a/log/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/public/data/.gitignore b/public/data/.gitignore deleted file mode 100644 index 8498bc17e..000000000 --- a/public/data/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -favicons -Configuration.array.php -*.sqlite -touch.txt \ No newline at end of file diff --git a/public/data/grey.gif b/public/data/grey.gif deleted file mode 100644 index c7212bc1f..000000000 Binary files a/public/data/grey.gif and /dev/null differ diff --git a/public/index.php b/public/index.php index bda585592..d989bc11d 100755 --- a/public/index.php +++ b/public/index.php @@ -20,16 +20,16 @@ require('../constants.php'); -if (file_exists (PUBLIC_PATH . '/install.php')) { +if (file_exists ('install.php')) { include ('install.php'); } else { session_cache_limiter(''); require (LIB_PATH . '/http-conditional.php'); $dateLastModification = max( - @filemtime(PUBLIC_PATH . '/data/touch.txt'), + @filemtime(DATA_PATH . '/touch.txt'), @filemtime(LOG_PATH . '/application.log'), - @filemtime(PUBLIC_PATH . '/data/Configuration.array.php'), - @filemtime(APP_PATH . '/configuration/application.ini') + @filemtime(DATA_PATH . '/Configuration.array.php'), + @filemtime(DATA_PATH . '/application.ini') ); if (httpConditional($dateLastModification, 0, 0, false, false, true)) { exit(); //No need to send anything diff --git a/public/install.php b/public/install.php index 4c0da0ce5..085a412ff 100644 --- a/public/install.php +++ b/public/install.php @@ -166,7 +166,7 @@ function saveStep2 () { . small_hash ($_SESSION['base_url'] . $_SESSION['sel']); } - $file_data = PUBLIC_PATH . '/data/Configuration.array.php'; + $file_data = DATA_PATH . '/Configuration.array.php'; $f = fopen ($file_data, 'w'); writeLine ($f, ' $php ? 'ok' : 'ko', @@ -276,11 +276,11 @@ function checkStep1 () { 'curl' => $curl ? 'ok' : 'ko', 'pdo-mysql' => $pdo ? 'ok' : 'ko', 'dom' => $dom ? 'ok' : 'ko', + 'data' => $data ? 'ok' : 'ko', 'cache' => $cache ? 'ok' : 'ko', 'log' => $log ? 'ok' : 'ko', - 'configuration' => $conf ? 'ok' : 'ko', - 'data' => $data ? 'ok' : 'ko', - 'all' => $php && $minz && $curl && $pdo && $dom && $cache && $log && $conf && $data ? 'ok' : 'ko' + 'favicons' => $favicons ? 'ok' : 'ko', + 'all' => $php && $minz && $curl && $pdo && $dom && $data && $cache && $log && $favicons ? 'ok' : 'ko' ); } function checkStep2 () { @@ -289,7 +289,7 @@ function checkStep2 () { isset ($_SESSION['title']) && isset ($_SESSION['old_entries']) && isset ($_SESSION['mail_login']); - $data = file_exists (PUBLIC_PATH . '/data/Configuration.array.php'); + $data = file_exists (DATA_PATH . '/Configuration.array.php'); return array ( 'conf' => $conf ? 'ok' : 'ko', @@ -298,7 +298,7 @@ function checkStep2 () { ); } function checkStep3 () { - $conf = file_exists (APP_PATH . '/configuration/application.ini'); + $conf = file_exists (DATA_PATH . '/application.ini'); $bd = isset ($_SESSION['bd_type']) && isset ($_SESSION['bd_host']) && isset ($_SESSION['bd_user']) && @@ -337,8 +337,7 @@ function checkBD () { // on écrase la précédente connexion en sélectionnant la nouvelle BDD $str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_name']; } elseif($_SESSION['bd_type'] == 'sqlite') { - $str = 'sqlite:' . PUBLIC_PATH - . '/data/' . $_SESSION['bd_name'] . '.sqlite'; + $str = 'sqlite:' . DATA_PATH . $_SESSION['bd_name'] . '.sqlite'; } $c = new PDO ($str, @@ -370,8 +369,8 @@ function checkBD () { $error = true; } - if ($error && file_exists (APP_PATH . '/configuration/application.ini')) { - unlink (APP_PATH . '/configuration/application.ini'); + if ($error && file_exists (DATA_PATH . '/application.ini')) { + unlink (DATA_PATH . '/application.ini'); } return !$error; @@ -448,28 +447,28 @@ function printStep1 () {

+ +

+ +

+ +

-

+

-

- - - -

- -

+

- -

+ +

-

+

diff --git a/public/themes/icons/grey.gif b/public/themes/icons/grey.gif new file mode 100644 index 000000000..c7212bc1f Binary files /dev/null and b/public/themes/icons/grey.gif differ -- cgit v1.2.3 From 9ec13c6c32ad0f8fb50f100e6ae127abe1535ccc Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 17 Nov 2013 15:24:30 +0100 Subject: Début de multi-utilisateurs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Préparation de https://github.com/marienfressinaud/FreshRSS/issues/126 Suite de https://github.com/marienfressinaud/FreshRSS/issues/248 Nécessite un script de mise à jour https://github.com/marienfressinaud/FreshRSS/issues/255 Install.php n'est pas encore testé https://github.com/marienfressinaud/FreshRSS/issues/273 --- app/i18n/en.php | 3 ++- app/i18n/fr.php | 3 ++- app/models/Entry.php | 8 ++++---- app/models/Feed.php | 4 ++-- app/models/RSSConfiguration.php | 3 ++- data/.gitignore | 2 +- lib/minz/Configuration.php | 12 ++++++++++++ lib/minz/dao/Model_pdo.php | 3 ++- public/index.php | 1 - public/install.php | 20 +++++++++++++++----- 10 files changed, 42 insertions(+), 17 deletions(-) (limited to 'public/index.php') diff --git a/app/i18n/en.php b/app/i18n/en.php index 8243756bd..e5aec3bc1 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -151,7 +151,8 @@ return array ( 'language' => 'Language', 'delete_articles_every' => 'Remove articles every', 'month' => 'months', - 'persona_connection_email' => 'Login mail address (use Persona)', + 'default_user' => 'Username of the default user (maximum 16 alphanumeric characters)', + 'persona_connection_email' => 'Login mail address (use Mozilla Persona)', 'allow_anonymous' => 'Allow anonymous reading', 'auth_token' => 'Authentication token', 'explain_token' => 'Allows to access RSS output without authentication.
%s?token=%s', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 8040a6a44..8bffd5287 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -151,7 +151,8 @@ return array ( 'language' => 'Langue', 'delete_articles_every' => 'Supprimer les articles tous les', 'month' => 'mois', - 'persona_connection_email' => 'Adresse courriel de connexion (utilise Persona)', + 'default_user' => 'Nom de l’utilisateur par défaut (16 caractères alphanumériques maximum)', + 'persona_connection_email' => 'Adresse courriel de connexion (utilise Mozilla Persona)', 'allow_anonymous' => 'Autoriser la lecture anonyme', 'auth_token' => 'Jeton d’identification', 'explain_token' => 'Permet d’accéder à la sortie RSS sans besoin de s’authentifier.
%s?output=rss&token=%s', diff --git a/app/models/Entry.php b/app/models/Entry.php index 8b817cc14..c4856af8b 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -311,11 +311,11 @@ class EntryDAO extends Model_pdo { $affected = $stm->rowCount(); if ($affected > 0) { - $sql = 'UPDATE freshrss_feed f ' + $sql = 'UPDATE ' . $this->prefix . 'feed f ' . 'LEFT OUTER JOIN (' . 'SELECT e.id_feed, ' . 'COUNT(*) AS nbUnreads ' - . 'FROM freshrss_entry e ' + . 'FROM ' . $this->prefix . 'entry e ' . 'WHERE e.is_read = 0 ' . 'GROUP BY e.id_feed' . ') x ON x.id_feed=f.id ' @@ -364,11 +364,11 @@ class EntryDAO extends Model_pdo { $affected = $stm->rowCount(); if ($affected > 0) { - $sql = 'UPDATE freshrss_feed f ' + $sql = 'UPDATE ' . $this->prefix . 'feed f ' . 'LEFT OUTER JOIN (' . 'SELECT e.id_feed, ' . 'COUNT(*) AS nbUnreads ' - . 'FROM freshrss_entry e ' + . 'FROM ' . $this->prefix . 'entry e ' . 'WHERE e.is_read = 0 ' . 'GROUP BY e.id_feed' . ') x ON x.id_feed=f.id ' diff --git a/app/models/Feed.php b/app/models/Feed.php index adc8e1677..549603664 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -530,12 +530,12 @@ class FeedDAO extends Model_pdo { return $res[0]['count']; } public function updateCachedValues () { //For one single feed, call updateLastUpdate($id) - $sql = 'UPDATE freshrss_feed f ' + $sql = 'UPDATE ' . $this->prefix . 'feed f ' . 'INNER JOIN (' . 'SELECT e.id_feed, ' . 'COUNT(CASE WHEN e.is_read = 0 THEN 1 END) AS nbUnreads, ' . 'COUNT(e.id) AS nbEntries ' - . 'FROM freshrss_entry e ' + . 'FROM ' . $this->prefix . 'entry e ' . 'GROUP BY e.id_feed' . ') x ON x.id_feed=f.id ' . 'SET f.cache_nbEntries=x.nbEntries, f.cache_nbUnreads=x.nbUnreads'; diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index f8379a625..9604bee1d 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -348,7 +348,7 @@ class RSSConfigurationDAO extends Model_array { public $bottomline_link = 'yes'; public function __construct () { - parent::__construct (DATA_PATH . '/Configuration.array.php'); + parent::__construct (DATA_PATH . Configuration::currentUser () . '_user.php'); // TODO : simplifier ce code, une boucle for() devrait suffir ! if (isset ($this->array['language'])) { @@ -441,5 +441,6 @@ class RSSConfigurationDAO extends Model_array { } $this->writeFile($this->array); + touch(DATA_PATH . '/touch.txt'); } } diff --git a/data/.gitignore b/data/.gitignore index 0e407f099..9c60990ac 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,6 +1,6 @@ cache log application.ini -Configuration.array.php +*_user.php *.sqlite touch.txt \ No newline at end of file diff --git a/lib/minz/Configuration.php b/lib/minz/Configuration.php index bdd6af0fb..5be2ea63d 100755 --- a/lib/minz/Configuration.php +++ b/lib/minz/Configuration.php @@ -50,6 +50,8 @@ class Configuration { private static $language = 'en'; private static $cache_enabled = false; private static $delay_cache = 3600; + private static $default_user = ''; + private static $current_user = ''; private static $db = array ( 'host' => false, @@ -88,6 +90,12 @@ class Configuration { public static function dataBase () { return self::$db; } + public static function defaultUser () { + return self::$default_user; + } + public static function currentUser () { + return self::$current_user; + } /** * Initialise les variables de configuration @@ -193,6 +201,10 @@ class Configuration { if (isset ($general['delay_cache'])) { self::$delay_cache = $general['delay_cache']; } + if (isset ($general['default_user'])) { + self::$default_user = $general['default_user']; + self::$current_user = self::$default_user; + } // Base de données $db = false; diff --git a/lib/minz/dao/Model_pdo.php b/lib/minz/dao/Model_pdo.php index beeb65ea8..810e69847 100755 --- a/lib/minz/dao/Model_pdo.php +++ b/lib/minz/dao/Model_pdo.php @@ -60,7 +60,8 @@ class Model_pdo { ); self::$sharedBd = $this->bd; - $this->prefix = $db['prefix']; + $userPrefix = Configuration::currentUser (); + $this->prefix = $db['prefix'] . (empty($userPrefix) ? '' : ($userPrefix . '_')); self::$sharedPrefix = $this->prefix; } catch (Exception $e) { throw new PDOConnectionException ( diff --git a/public/index.php b/public/index.php index d989bc11d..108853fb7 100755 --- a/public/index.php +++ b/public/index.php @@ -28,7 +28,6 @@ if (file_exists ('install.php')) { $dateLastModification = max( @filemtime(DATA_PATH . '/touch.txt'), @filemtime(LOG_PATH . '/application.log'), - @filemtime(DATA_PATH . '/Configuration.array.php'), @filemtime(DATA_PATH . '/application.ini') ); if (httpConditional($dateLastModification, 0, 0, false, false, true)) { diff --git a/public/install.php b/public/install.php index 085a412ff..42f2d2651 100644 --- a/public/install.php +++ b/public/install.php @@ -159,6 +159,7 @@ function saveStep2 () { $_SESSION['old_entries'] = 3; } $_SESSION['mail_login'] = addslashes ($_POST['mail_login']); + $_SESSION['default_user'] = substr(0, 16, preg_replace ('/[^a-zA-Z0-9]/', '', $_POST['default_user'])); $token = ''; if ($_SESSION['mail_login']) { @@ -166,7 +167,7 @@ function saveStep2 () { . small_hash ($_SESSION['base_url'] . $_SESSION['sel']); } - $file_data = DATA_PATH . '/Configuration.array.php'; + $file_data = DATA_PATH . '/' . $_SESSION['default_user'] . '_user.php'; $f = fopen ($file_data, 'w'); writeLine ($f, ' $conf ? 'ok' : 'ko', @@ -512,6 +515,13 @@ function printStep2 () {
+
+ +
+ +
+
+
@@ -586,14 +596,14 @@ function printStep3 () {
- +
- +
-- cgit v1.2.3 From 50f3b27eb9d15369c6e64ac5140db1b0a90e681d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 21 Nov 2013 12:26:32 +0100 Subject: install.php comme point d'entrée possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Permet d'appeler install.php directement plutôt que index.php (qui reste possible). --- public/index.php | 6 +++--- public/install.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'public/index.php') diff --git a/public/index.php b/public/index.php index 108853fb7..5728d981b 100755 --- a/public/index.php +++ b/public/index.php @@ -18,11 +18,11 @@ # # ***** END LICENSE BLOCK ***** -require('../constants.php'); - if (file_exists ('install.php')) { - include ('install.php'); + require('install.php'); } else { + require('../constants.php'); + session_cache_limiter(''); require (LIB_PATH . '/http-conditional.php'); $dateLastModification = max( diff --git a/public/install.php b/public/install.php index ed7c5e3bb..dbe79e774 100644 --- a/public/install.php +++ b/public/install.php @@ -1,4 +1,5 @@ Date: Thu, 28 Nov 2013 10:46:11 +0100 Subject: Touch plus standard Corrige https://github.com/marienfressinaud/FreshRSS/issues/296 --- app/layout/layout.phtml | 2 +- public/index.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'public/index.php') diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index ac0031355..c53b28841 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -32,7 +32,7 @@ notification)) { - touch(DATA_PATH . '/touch.txt', time() + 1); + touch(DATA_PATH . '/touch.txt'); ?>
notification['content']; ?> diff --git a/public/index.php b/public/index.php index 5728d981b..9d1ee711c 100755 --- a/public/index.php +++ b/public/index.php @@ -26,9 +26,9 @@ if (file_exists ('install.php')) { session_cache_limiter(''); require (LIB_PATH . '/http-conditional.php'); $dateLastModification = max( - @filemtime(DATA_PATH . '/touch.txt'), - @filemtime(LOG_PATH . '/application.log'), - @filemtime(DATA_PATH . '/application.ini') + @filemtime(DATA_PATH . '/touch.txt') - 1, + @filemtime(LOG_PATH . '/application.log') - 1, + @filemtime(DATA_PATH . '/application.ini') - 1 ); if (httpConditional($dateLastModification, 0, 0, false, false, true)) { exit(); //No need to send anything -- cgit v1.2.3 From dc2e1dc0817f0818943647d6b005ea35683c9c1b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 28 Nov 2013 16:37:27 +0100 Subject: Annulation du cache via no-cache.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La présence du fichier DATA_PATH/no-cache.txt permet de désactiver le cache. Ce fichier n'est pas présent par défaut Corrige #297 --- data/.gitignore | 3 ++- public/index.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'public/index.php') diff --git a/data/.gitignore b/data/.gitignore index 5d36792ba..677c8f58c 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,4 +1,5 @@ application.ini *_user.php *.sqlite -touch.txt \ No newline at end of file +touch.txt +no-cache.txt \ No newline at end of file diff --git a/public/index.php b/public/index.php index 9d1ee711c..9bf4fc073 100755 --- a/public/index.php +++ b/public/index.php @@ -24,14 +24,16 @@ if (file_exists ('install.php')) { require('../constants.php'); session_cache_limiter(''); - require (LIB_PATH . '/http-conditional.php'); - $dateLastModification = max( - @filemtime(DATA_PATH . '/touch.txt') - 1, - @filemtime(LOG_PATH . '/application.log') - 1, - @filemtime(DATA_PATH . '/application.ini') - 1 - ); - if (httpConditional($dateLastModification, 0, 0, false, false, true)) { - exit(); //No need to send anything + if (!file_exists(DATA_PATH . '/no-cache.txt')) { + require (LIB_PATH . '/http-conditional.php'); + $dateLastModification = max( + @filemtime(DATA_PATH . '/touch.txt') - 1, + @filemtime(LOG_PATH . '/application.log') - 1, + @filemtime(DATA_PATH . '/application.ini') - 1 + ); + if (httpConditional($dateLastModification, 0, 0, false, false, true)) { + exit(); //No need to send anything + } } set_include_path (get_include_path () -- cgit v1.2.3 From 7cdc477c45a84bde56f5253ce34924f164e6ca0a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 28 Nov 2013 20:59:31 +0100 Subject: touch en microsecondes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passage en microsecondes pour le touch (gestion du cache) pour éviter les problèmes en particulier dans le cas de requêtes de moins d'une seconde. Nouvelle fonction invalidateHttpCache() pour plus facilement changer de méthode de contrôle de fraîcheur de cache. Devrait résoudre https://github.com/marienfressinaud/FreshRSS/issues/296 --- actualize_script.php | 2 +- app/controllers/entryController.php | 2 +- app/controllers/indexController.php | 4 ++-- app/layout/layout.phtml | 2 +- app/models/RSSConfiguration.php | 2 +- lib/lib_rss.php | 4 ++++ lib/minz/dao/Model_pdo.php | 2 +- public/index.php | 7 ++++--- 8 files changed, 15 insertions(+), 10 deletions(-) (limited to 'public/index.php') diff --git a/actualize_script.php b/actualize_script.php index bc1d108bd..942070ccc 100755 --- a/actualize_script.php +++ b/actualize_script.php @@ -20,4 +20,4 @@ $front_controller = new App_FrontController (); $front_controller->init (); Session::_param('mail', true); // permet de se passer de la phase de connexion $front_controller->run (); -touch(DATA_PATH . '/touch.txt'); +invalidateHttpCache(); diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index fa34ad429..d92eb0ed3 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -84,7 +84,7 @@ class entryController extends ActionController { $entryDAO = new EntryDAO(); $entryDAO->optimizeTable(); - touch(DATA_PATH . '/touch.txt'); + invalidateHttpCache(); $notif = array ( 'type' => 'good', diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index e4462e543..8e6abd682 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -272,7 +272,7 @@ class indexController extends ActionController { $res = json_decode ($result, true); if ($res['status'] == 'okay' && $res['email'] == $this->view->conf->mailLogin ()) { Session::_param ('mail', $res['email']); - touch(DATA_PATH . '/touch.txt'); + invalidateHttpCache(); } else { $res = array (); $res['status'] = 'failure'; @@ -285,6 +285,6 @@ class indexController extends ActionController { public function logoutAction () { $this->view->_useLayout (false); Session::_param ('mail'); - touch(DATA_PATH . '/touch.txt'); + invalidateHttpCache(); } } diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index c53b28841..9b502275c 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -32,7 +32,7 @@ notification)) { - touch(DATA_PATH . '/touch.txt'); + invalidateHttpCache(); ?>
notification['content']; ?> diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index c36548e6f..fe6cd48d3 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -473,6 +473,6 @@ class RSSConfigurationDAO extends Model_array { } $this->writeFile($this->array); - touch(DATA_PATH . '/touch.txt'); + invalidateHttpCache(); } } diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 3c03f4281..5a74bfd0a 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -230,3 +230,7 @@ function lazyimg($content) { $content ); } + +function invalidateHttpCache() { + file_put_contents(DATA_PATH . '/touch.txt', microtime(true)); +} diff --git a/lib/minz/dao/Model_pdo.php b/lib/minz/dao/Model_pdo.php index 545f59e81..48c81d082 100755 --- a/lib/minz/dao/Model_pdo.php +++ b/lib/minz/dao/Model_pdo.php @@ -85,7 +85,7 @@ class Model_pdo { class FreshPDO extends PDO { private static function check($statement) { if (preg_match('/^(?:UPDATE|INSERT|DELETE)/i', $statement)) { - touch(DATA_PATH . '/touch.txt'); + invalidateHttpCache(); } } diff --git a/public/index.php b/public/index.php index 9bf4fc073..cabd836d5 100755 --- a/public/index.php +++ b/public/index.php @@ -27,10 +27,11 @@ if (file_exists ('install.php')) { if (!file_exists(DATA_PATH . '/no-cache.txt')) { require (LIB_PATH . '/http-conditional.php'); $dateLastModification = max( - @filemtime(DATA_PATH . '/touch.txt') - 1, - @filemtime(LOG_PATH . '/application.log') - 1, - @filemtime(DATA_PATH . '/application.ini') - 1 + @filemtime(DATA_PATH . '/touch.txt'), + @filemtime(LOG_PATH . '/application.log'), + @filemtime(DATA_PATH . '/application.ini') ); + $_SERVER['QUERY_STRING'] .= '&utime=' . file_get_contents(DATA_PATH . '/touch.txt'); if (httpConditional($dateLastModification, 0, 0, false, false, true)) { exit(); //No need to send anything } -- cgit v1.2.3 From 2a798e544b93d112bad5d1622b06a8f7bfc525cd Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 28 Nov 2013 21:49:55 +0100 Subject: Commentaire ETag --- public/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'public/index.php') diff --git a/public/index.php b/public/index.php index cabd836d5..3a2bcd3ae 100755 --- a/public/index.php +++ b/public/index.php @@ -31,7 +31,7 @@ if (file_exists ('install.php')) { @filemtime(LOG_PATH . '/application.log'), @filemtime(DATA_PATH . '/application.ini') ); - $_SERVER['QUERY_STRING'] .= '&utime=' . file_get_contents(DATA_PATH . '/touch.txt'); + $_SERVER['QUERY_STRING'] .= '&utime=' . file_get_contents(DATA_PATH . '/touch.txt'); //For ETag if (httpConditional($dateLastModification, 0, 0, false, false, true)) { exit(); //No need to send anything } -- cgit v1.2.3 From 878e96202e8a22e4857b98e29b0a1fce68eccbc9 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 15 Dec 2013 03:30:24 +0100 Subject: Grosse refactorisation pour permettre le chargement automatique des classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C'est parti de changements pour https://github.com/marienfressinaud/FreshRSS/issues/255 et finalement j'ai continué la refactorisation... Ajout de préfixes FreshRSS_ et Minz_ sur le modèle de SimplePie_. Toutes les classes sont maintenant en chargement automatique (devrait améliorer les performances en évitant de charger plein de classes inutilisées, et faciliter la maintenance). Suppression de set_include_path(). Si souhaité, certaines classes de Minz pourraient être déplacées dans un sous-répertoire, par exemple les exceptions. Tests et relecture nécessaires. --- app/App_FrontController.php | 84 ---- app/Exceptions/BadUrlException.php | 6 + app/Exceptions/EntriesGetterException.php | 7 + app/Exceptions/FeedException.php | 6 + app/Exceptions/OpmlException.php | 6 + app/FreshRSS.php | 58 +++ app/Models/CategoryDAO.php | 252 +++++++++++ app/Models/Configuration.php | 326 ++++++++++++++ app/Models/ConfigurationDAO.php | 156 +++++++ app/Models/EntryDAO.php | 425 ++++++++++++++++++ app/Models/FeedDAO.php | 341 +++++++++++++++ app/Models/Log.php | 26 ++ app/Models/LogDAO.php | 20 + app/Models/Themes.php | 88 ++++ app/controllers/configureController.php | 234 +++++----- app/controllers/entryController.php | 44 +- app/controllers/errorController.php | 8 +- app/controllers/feedController.php | 142 +++--- app/controllers/indexController.php | 78 ++-- app/controllers/javascriptController.php | 4 +- app/layout/aside_configure.phtml | 14 +- app/layout/aside_feed.phtml | 28 +- app/layout/aside_flux.phtml | 30 +- app/layout/header.phtml | 38 +- app/layout/layout.phtml | 18 +- app/layout/nav_entries.phtml | 6 +- app/layout/nav_menu.phtml | 68 +-- app/models/Category.php | 260 +---------- app/models/Days.php | 2 +- app/models/Entry.php | 438 +------------------ app/models/Exception/EntriesGetterException.php | 7 - app/models/Exception/FeedException.php | 19 - app/models/Feed.php | 362 +--------------- app/models/Log_Model.php | 46 -- app/models/RSSConfiguration.php | 480 --------------------- app/models/RSSThemes.php | 88 ---- app/views/configure/categorize.phtml | 22 +- app/views/configure/display.phtml | 106 ++--- app/views/configure/feed.phtml | 54 +-- app/views/configure/importExport.phtml | 18 +- app/views/configure/sharing.phtml | 30 +- app/views/configure/shortcut.phtml | 30 +- app/views/entry/bookmark.phtml | 16 +- app/views/entry/read.phtml | 16 +- app/views/error/index.phtml | 4 +- app/views/helpers/javascript_vars.phtml | 20 +- app/views/helpers/logs_pagination.phtml | 16 +- app/views/helpers/pagination.phtml | 18 +- app/views/helpers/view/global_view.phtml | 2 +- app/views/helpers/view/normal_view.phtml | 53 ++- app/views/helpers/view/reader_view.phtml | 4 +- app/views/helpers/view/rss_view.phtml | 6 +- app/views/index/about.phtml | 24 +- app/views/index/index.phtml | 10 +- app/views/index/logs.phtml | 8 +- app/views/javascript/actualize.phtml | 4 +- lib/Minz/ActionException.php | 9 + lib/Minz/BadConfigurationException.php | 9 + lib/Minz/Cache.php | 116 +++++ .../ControllerNotActionControllerException.php | 9 + lib/Minz/ControllerNotExistException.php | 9 + lib/Minz/CurrentPagePaginationException.php | 8 + lib/Minz/Exception.php | 16 + lib/Minz/FileNotExistException.php | 8 + lib/Minz/Log.php | 94 ++++ lib/Minz/ModelArray.php | 122 ++++++ lib/Minz/ModelPdo.php | 111 +++++ lib/Minz/ModelTxt.php | 84 ++++ lib/Minz/PDOConnectionException.php | 9 + lib/Minz/PermissionDeniedException.php | 8 + lib/Minz/RouteNotFoundException.php | 16 + lib/SimplePie_autoloader.php | 86 ---- lib/lib_rss.php | 45 +- lib/minz/ActionController.php | 4 +- lib/minz/Configuration.php | 60 +-- lib/minz/Dispatcher.php | 54 +-- lib/minz/Error.php | 40 +- lib/minz/FrontController.php | 80 ++-- lib/minz/Helper.php | 2 +- lib/minz/Minz_Cache.php | 116 ----- lib/minz/Minz_Log.php | 94 ---- lib/minz/Model.php | 2 +- lib/minz/Paginator.php | 2 +- lib/minz/Request.php | 16 +- lib/minz/Response.php | 2 +- lib/minz/Router.php | 34 +- lib/minz/Session.php | 6 +- lib/minz/Translate.php | 6 +- lib/minz/Url.php | 18 +- lib/minz/View.php | 10 +- lib/minz/dao/Model_array.php | 122 ------ lib/minz/dao/Model_pdo.php | 111 ----- lib/minz/dao/Model_txt.php | 84 ---- lib/minz/exceptions/MinzException.php | 94 ---- public/index.php | 12 +- 95 files changed, 3134 insertions(+), 3270 deletions(-) delete mode 100644 app/App_FrontController.php create mode 100644 app/Exceptions/BadUrlException.php create mode 100644 app/Exceptions/EntriesGetterException.php create mode 100644 app/Exceptions/FeedException.php create mode 100644 app/Exceptions/OpmlException.php create mode 100644 app/FreshRSS.php create mode 100644 app/Models/CategoryDAO.php create mode 100644 app/Models/Configuration.php create mode 100644 app/Models/ConfigurationDAO.php create mode 100644 app/Models/EntryDAO.php create mode 100644 app/Models/FeedDAO.php create mode 100644 app/Models/Log.php create mode 100644 app/Models/LogDAO.php create mode 100644 app/Models/Themes.php delete mode 100644 app/models/Exception/EntriesGetterException.php delete mode 100644 app/models/Exception/FeedException.php delete mode 100644 app/models/Log_Model.php delete mode 100755 app/models/RSSConfiguration.php delete mode 100644 app/models/RSSThemes.php create mode 100644 lib/Minz/ActionException.php create mode 100644 lib/Minz/BadConfigurationException.php create mode 100644 lib/Minz/Cache.php create mode 100644 lib/Minz/ControllerNotActionControllerException.php create mode 100644 lib/Minz/ControllerNotExistException.php create mode 100644 lib/Minz/CurrentPagePaginationException.php create mode 100644 lib/Minz/Exception.php create mode 100644 lib/Minz/FileNotExistException.php create mode 100644 lib/Minz/Log.php create mode 100644 lib/Minz/ModelArray.php create mode 100644 lib/Minz/ModelPdo.php create mode 100644 lib/Minz/ModelTxt.php create mode 100644 lib/Minz/PDOConnectionException.php create mode 100644 lib/Minz/PermissionDeniedException.php create mode 100644 lib/Minz/RouteNotFoundException.php delete mode 100644 lib/SimplePie_autoloader.php delete mode 100644 lib/minz/Minz_Cache.php delete mode 100644 lib/minz/Minz_Log.php delete mode 100755 lib/minz/dao/Model_array.php delete mode 100755 lib/minz/dao/Model_pdo.php delete mode 100755 lib/minz/dao/Model_txt.php delete mode 100644 lib/minz/exceptions/MinzException.php (limited to 'public/index.php') diff --git a/app/App_FrontController.php b/app/App_FrontController.php deleted file mode 100644 index 0721dba45..000000000 --- a/app/App_FrontController.php +++ /dev/null @@ -1,84 +0,0 @@ - -*/ -require ('FrontController.php'); - -class App_FrontController extends FrontController { - public function init () { - $this->loadLibs (); - $this->loadModels (); - - Session::init (); - Translate::init (); - - $this->loadParamsView (); - $this->loadStylesAndScripts (); - $this->loadNotifications (); - } - - private function loadLibs () { - require (LIB_PATH . '/lib_rss.php'); - require (LIB_PATH . '/SimplePie_autoloader.php'); - } - - private function loadModels () { - include (APP_PATH . '/models/Exception/FeedException.php'); - include (APP_PATH . '/models/Exception/EntriesGetterException.php'); - include (APP_PATH . '/models/RSSConfiguration.php'); - include (APP_PATH . '/models/RSSThemes.php'); - include (APP_PATH . '/models/Days.php'); - include (APP_PATH . '/models/Category.php'); - include (APP_PATH . '/models/Feed.php'); - include (APP_PATH . '/models/Entry.php'); - include (APP_PATH . '/models/Log_Model.php'); - } - - private function loadParamsView () { - try { - $this->conf = Session::param ('conf', new RSSConfiguration ()); - } catch(MinzException $e) { - // Permission denied or conf file does not exist - // it's critical! - print $e->getMessage(); - exit(); - } - - View::_param ('conf', $this->conf); - Session::_param ('language', $this->conf->language ()); - - $output = Request::param ('output'); - if(!$output) { - $output = $this->conf->viewMode(); - Request::_param ('output', $output); - } - } - - private function loadStylesAndScripts () { - $theme = RSSThemes::get_infos($this->conf->theme()); - if ($theme) { - foreach($theme["files"] as $file) { - View::appendStyle (Url::display ('/themes/' . $theme['path'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file))); - } - } - - if (login_is_conf ($this->conf)) { - View::appendScript ('https://login.persona.org/include.js'); - } - $includeLazyLoad = $this->conf->lazyload () === 'yes' && ($this->conf->displayPosts () === 'yes' || Request::param ('output') === 'reader'); - View::appendScript (Url::display ('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')), false, !$includeLazyLoad, !$includeLazyLoad); - if ($includeLazyLoad) { - View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js'))); - } - View::appendScript (Url::display ('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); - } - - private function loadNotifications () { - $notif = Session::param ('notification'); - if ($notif) { - View::_param ('notification', $notif); - Session::_param ('notification'); - } - } -} diff --git a/app/Exceptions/BadUrlException.php b/app/Exceptions/BadUrlException.php new file mode 100644 index 000000000..7d1fe110e --- /dev/null +++ b/app/Exceptions/BadUrlException.php @@ -0,0 +1,6 @@ +loadParamsView (); + $this->loadStylesAndScripts (); + $this->loadNotifications (); + } + + private function loadParamsView () { + try { + $this->conf = Minz_Session::param ('conf', new FreshRSS_Configuration ()); + } catch (Minz_Exception $e) { + // Permission denied or conf file does not exist + // it's critical! + print $e->getMessage(); + exit(); + } + + Minz_View::_param ('conf', $this->conf); + Minz_Session::_param ('language', $this->conf->language ()); + + $output = Minz_Request::param ('output'); + if(!$output) { + $output = $this->conf->viewMode(); + Minz_Request::_param ('output', $output); + } + } + + private function loadStylesAndScripts () { + $theme = FreshRSS_Themes::get_infos($this->conf->theme()); + if ($theme) { + foreach($theme["files"] as $file) { + Minz_View::appendStyle (Minz_Url::display ('/themes/' . $theme['path'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file))); + } + } + + if (login_is_conf ($this->conf)) { + Minz_View::appendScript ('https://login.persona.org/include.js'); + } + $includeLazyLoad = $this->conf->lazyload () === 'yes' && ($this->conf->displayPosts () === 'yes' || Minz_Request::param ('output') === 'reader'); + Minz_View::appendScript (Minz_Url::display ('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')), false, !$includeLazyLoad, !$includeLazyLoad); + if ($includeLazyLoad) { + Minz_View::appendScript (Minz_Url::display ('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js'))); + } + Minz_View::appendScript (Minz_Url::display ('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); + } + + private function loadNotifications () { + $notif = Minz_Session::param ('notification'); + if ($notif) { + Minz_View::_param ('notification', $notif); + Minz_Session::_param ('notification'); + } + } +} diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php new file mode 100644 index 000000000..793e593c3 --- /dev/null +++ b/app/Models/CategoryDAO.php @@ -0,0 +1,252 @@ +prefix . 'category` (name, color) VALUES(?, ?)'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + substr($valuesTmp['name'], 0, 255), + substr($valuesTmp['color'], 0, 7), + ); + + if ($stm && $stm->execute ($values)) { + return $this->bd->lastInsertId(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + public function updateCategory ($id, $valuesTmp) { + $sql = 'UPDATE `' . $this->prefix . 'category` SET name=?, color=? WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $valuesTmp['name'], + $valuesTmp['color'], + $id + ); + + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + public function deleteCategory ($id) { + $sql = 'DELETE FROM `' . $this->prefix . 'category` WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + public function searchById ($id) { + $sql = 'SELECT * FROM `' . $this->prefix . 'category` WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $cat = HelperCategory::daoToCategory ($res); + + if (isset ($cat[0])) { + return $cat[0]; + } else { + return false; + } + } + public function searchByName ($name) { + $sql = 'SELECT * FROM `' . $this->prefix . 'category` WHERE name=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($name); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $cat = HelperCategory::daoToCategory ($res); + + if (isset ($cat[0])) { + return $cat[0]; + } else { + return false; + } + } + + 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.website, f.priority, f.error, f.cache_nbEntries, f.cache_nbUnreads ') + . 'FROM `' . $this->prefix . 'category` c ' + . 'LEFT OUTER JOIN `' . $this->prefix . 'feed` f ON f.category = c.id ' + . 'GROUP BY f.id ' + . 'ORDER BY c.name, f.name'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + return HelperCategory::daoToCategoryPrepopulated ($stm->fetchAll (PDO::FETCH_ASSOC)); + } else { + $sql = 'SELECT * FROM `' . $this->prefix . 'category` ORDER BY name'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + return HelperCategory::daoToCategory ($stm->fetchAll (PDO::FETCH_ASSOC)); + } + } + + public function getDefault () { + $sql = 'SELECT * FROM `' . $this->prefix . 'category` WHERE id=1'; + $stm = $this->bd->prepare ($sql); + + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $cat = HelperCategory::daoToCategory ($res); + + if (isset ($cat[0])) { + return $cat[0]; + } else { + return false; + } + } + public function checkDefault () { + $def_cat = $this->searchById (1); + + if ($def_cat === false) { + $cat = new FreshRSS_Category (Minz_Translate::t ('default_category')); + $cat->_id (1); + + $values = array ( + 'id' => $cat->id (), + 'name' => $cat->name (), + 'color' => $cat->color () + ); + + $this->addCategory ($values); + } + } + + public function count () { + $sql = 'SELECT COUNT(*) AS count FROM `' . $this->prefix . 'category`'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + + return $res[0]['count']; + } + + public function countFeed ($id) { + $sql = 'SELECT COUNT(*) AS count FROM `' . $this->prefix . 'feed` WHERE category=?'; + $stm = $this->bd->prepare ($sql); + $values = array ($id); + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + + return $res[0]['count']; + } + + public function countNotRead ($id) { + $sql = 'SELECT COUNT(*) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id WHERE category=? AND e.is_read=0'; + $stm = $this->bd->prepare ($sql); + $values = array ($id); + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + + return $res[0]['count']; + } +} + +class HelperCategory { + public static function findFeed($categories, $feed_id) { + foreach ($categories as $category) { + foreach ($category->feeds () as $feed) { + if ($feed->id () === $feed_id) { + return $feed; + } + } + } + return null; + } + + public static function CountUnreads($categories, $minPriority = 0) { + $n = 0; + foreach ($categories as $category) { + foreach ($category->feeds () as $feed) { + if ($feed->priority () >= $minPriority) { + $n += $feed->nbNotRead(); + } + } + } + return $n; + } + + public static function daoToCategoryPrepopulated ($listDAO) { + $list = array (); + + if (!is_array ($listDAO)) { + $listDAO = array ($listDAO); + } + + $previousLine = null; + $feedsDao = array(); + foreach ($listDAO as $line) { + if ($previousLine['c_id'] != null && $line['c_id'] !== $previousLine['c_id']) { + // 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'] : '', + HelperFeed::daoToFeed ($feedsDao, $previousLine['c_id']) + ); + $cat->_id ($previousLine['c_id']); + $list[$previousLine['c_id']] = $cat; + + $feedsDao = array(); //Prepare for next category + } + + $previousLine = $line; + $feedsDao[] = $line; + } + + // add the last category + if ($previousLine != null) { + $cat = new FreshRSS_Category ( + $previousLine['c_name'], + isset($previousLine['c_color']) ? $previousLine['c_color'] : '', + HelperFeed::daoToFeed ($feedsDao, $previousLine['c_id']) + ); + $cat->_id ($previousLine['c_id']); + $list[$previousLine['c_id']] = $cat; + } + + return $list; + } + + public static function daoToCategory ($listDAO) { + $list = array (); + + if (!is_array ($listDAO)) { + $listDAO = array ($listDAO); + } + + foreach ($listDAO as $key => $dao) { + $cat = new FreshRSS_Category ( + $dao['name'], + $dao['color'] + ); + $cat->_id ($dao['id']); + $list[$key] = $cat; + } + + return $list; + } +} diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php new file mode 100644 index 000000000..7ef76b522 --- /dev/null +++ b/app/Models/Configuration.php @@ -0,0 +1,326 @@ + 'English', + 'fr' => 'Français', + ); + private $language; + private $posts_per_page; + private $view_mode; + private $default_view; + private $display_posts; + private $onread_jump_next; + private $lazyload; + private $sort_order; + private $old_entries; + private $shortcuts = array (); + private $mail_login = ''; + private $mark_when = array (); + private $sharing = array (); + private $theme; + private $anon_access; + private $token; + private $auto_load_more; + private $topline_read; + private $topline_favorite; + private $topline_date; + private $topline_link; + private $bottomline_read; + private $bottomline_favorite; + private $bottomline_sharing; + private $bottomline_tags; + private $bottomline_date; + private $bottomline_link; + + public function __construct () { + $confDAO = new FreshRSS_ConfigurationDAO (); + $this->_language ($confDAO->language); + $this->_postsPerPage ($confDAO->posts_per_page); + $this->_viewMode ($confDAO->view_mode); + $this->_defaultView ($confDAO->default_view); + $this->_displayPosts ($confDAO->display_posts); + $this->_onread_jump_next ($confDAO->onread_jump_next); + $this->_lazyload ($confDAO->lazyload); + $this->_sortOrder ($confDAO->sort_order); + $this->_oldEntries ($confDAO->old_entries); + $this->_shortcuts ($confDAO->shortcuts); + $this->_mailLogin ($confDAO->mail_login); + $this->_markWhen ($confDAO->mark_when); + $this->_sharing ($confDAO->sharing); + $this->_theme ($confDAO->theme); + FreshRSS_Themes::setThemeId ($confDAO->theme); + $this->_anonAccess ($confDAO->anon_access); + $this->_token ($confDAO->token); + $this->_autoLoadMore ($confDAO->auto_load_more); + $this->_topline_read ($confDAO->topline_read); + $this->_topline_favorite ($confDAO->topline_favorite); + $this->_topline_date ($confDAO->topline_date); + $this->_topline_link ($confDAO->topline_link); + $this->_bottomline_read ($confDAO->bottomline_read); + $this->_bottomline_favorite ($confDAO->bottomline_favorite); + $this->_bottomline_sharing ($confDAO->bottomline_sharing); + $this->_bottomline_tags ($confDAO->bottomline_tags); + $this->_bottomline_date ($confDAO->bottomline_date); + $this->_bottomline_link ($confDAO->bottomline_link); + } + + public function availableLanguages () { + return $this->available_languages; + } + public function language () { + return $this->language; + } + public function postsPerPage () { + return $this->posts_per_page; + } + public function viewMode () { + return $this->view_mode; + } + public function defaultView () { + return $this->default_view; + } + public function displayPosts () { + return $this->display_posts; + } + public function onread_jump_next () { + return $this->onread_jump_next; + } + public function lazyload () { + return $this->lazyload; + } + public function sortOrder () { + return $this->sort_order; + } + public function oldEntries () { + return $this->old_entries; + } + public function shortcuts () { + return $this->shortcuts; + } + public function mailLogin () { + return $this->mail_login; + } + public function markWhen () { + return $this->mark_when; + } + public function markWhenArticle () { + return $this->mark_when['article']; + } + public function markWhenSite () { + return $this->mark_when['site']; + } + public function markWhenScroll () { + return $this->mark_when['scroll']; + } + public function markUponReception () { + return $this->mark_when['reception']; + } + public function sharing ($key = false) { + if ($key === false) { + return $this->sharing; + } elseif (isset ($this->sharing[$key])) { + return $this->sharing[$key]; + } + return false; + } + public function theme () { + return $this->theme; + } + public function anonAccess () { + return $this->anon_access; + } + public function token () { + return $this->token; + } + public function autoLoadMore () { + return $this->auto_load_more; + } + public function toplineRead () { + return $this->topline_read; + } + public function toplineFavorite () { + return $this->topline_favorite; + } + public function toplineDate () { + return $this->topline_date; + } + public function toplineLink () { + return $this->topline_link; + } + public function bottomlineRead () { + return $this->bottomline_read; + } + public function bottomlineFavorite () { + return $this->bottomline_favorite; + } + public function bottomlineSharing () { + return $this->bottomline_sharing; + } + public function bottomlineTags () { + return $this->bottomline_tags; + } + public function bottomlineDate () { + return $this->bottomline_date; + } + public function bottomlineLink () { + return $this->bottomline_link; + } + + public function _language ($value) { + if (!isset ($this->available_languages[$value])) { + $value = 'en'; + } + $this->language = $value; + } + public function _postsPerPage ($value) { + $value = intval($value); + $this->posts_per_page = $value > 0 ? $value : 10; + } + public function _viewMode ($value) { + if ($value == 'global' || $value == 'reader') { + $this->view_mode = $value; + } else { + $this->view_mode = 'normal'; + } + } + public function _defaultView ($value) { + if ($value == 'not_read') { + $this->default_view = 'not_read'; + } else { + $this->default_view = 'all'; + } + } + public function _displayPosts ($value) { + if ($value == 'yes') { + $this->display_posts = 'yes'; + } else { + $this->display_posts = 'no'; + } + } + public function _onread_jump_next ($value) { + if ($value == 'no') { + $this->onread_jump_next = 'no'; + } else { + $this->onread_jump_next = 'yes'; + } + } + public function _lazyload ($value) { + if ($value == 'no') { + $this->lazyload = 'no'; + } else { + $this->lazyload = 'yes'; + } + } + public function _sortOrder ($value) { + $this->sort_order = $value === 'ASC' ? 'ASC' : 'DESC'; + } + public function _oldEntries ($value) { + if (ctype_digit ($value) && $value > 0) { + $this->old_entries = $value; + } else { + $this->old_entries = 3; + } + } + public function _shortcuts ($values) { + foreach ($values as $key => $value) { + $this->shortcuts[$key] = $value; + } + } + public function _mailLogin ($value) { + if (filter_var ($value, FILTER_VALIDATE_EMAIL)) { + $this->mail_login = $value; + } elseif ($value == false) { + $this->mail_login = false; + } + } + public function _markWhen ($values) { + if(!isset($values['article'])) { + $values['article'] = 'yes'; + } + if(!isset($values['site'])) { + $values['site'] = 'yes'; + } + if(!isset($values['scroll'])) { + $values['scroll'] = 'yes'; + } + if(!isset($values['reception'])) { + $values['reception'] = 'no'; + } + + $this->mark_when['article'] = $values['article']; + $this->mark_when['site'] = $values['site']; + $this->mark_when['scroll'] = $values['scroll']; + $this->mark_when['reception'] = $values['reception']; + } + public function _sharing ($values) { + $are_url = array ('shaarli', 'poche', 'diaspora'); + foreach ($values as $key => $value) { + if (in_array($key, $are_url)) { + $is_url = ( + filter_var ($value, FILTER_VALIDATE_URL) || + (version_compare(PHP_VERSION, '5.3.3', '<') && + (strpos($value, '-') > 0) && + ($value === filter_var($value, FILTER_SANITIZE_URL))) + ); //PHP bug #51192 + + if (!$is_url) { + $value = ''; + } + } elseif(!is_bool ($value)) { + $value = true; + } + + $this->sharing[$key] = $value; + } + } + public function _theme ($value) { + $this->theme = $value; + } + public function _anonAccess ($value) { + if ($value == 'yes') { + $this->anon_access = 'yes'; + } else { + $this->anon_access = 'no'; + } + } + public function _token ($value) { + $this->token = $value; + } + public function _autoLoadMore ($value) { + if ($value == 'yes') { + $this->auto_load_more = 'yes'; + } else { + $this->auto_load_more = 'no'; + } + } + public function _topline_read ($value) { + $this->topline_read = $value === 'yes'; + } + public function _topline_favorite ($value) { + $this->topline_favorite = $value === 'yes'; + } + public function _topline_date ($value) { + $this->topline_date = $value === 'yes'; + } + public function _topline_link ($value) { + $this->topline_link = $value === 'yes'; + } + public function _bottomline_read ($value) { + $this->bottomline_read = $value === 'yes'; + } + public function _bottomline_favorite ($value) { + $this->bottomline_favorite = $value === 'yes'; + } + public function _bottomline_sharing ($value) { + $this->bottomline_sharing = $value === 'yes'; + } + public function _bottomline_tags ($value) { + $this->bottomline_tags = $value === 'yes'; + } + public function _bottomline_date ($value) { + $this->bottomline_date = $value === 'yes'; + } + public function _bottomline_link ($value) { + $this->bottomline_link = $value === 'yes'; + } +} diff --git a/app/Models/ConfigurationDAO.php b/app/Models/ConfigurationDAO.php new file mode 100644 index 000000000..fec58d234 --- /dev/null +++ b/app/Models/ConfigurationDAO.php @@ -0,0 +1,156 @@ + 'r', + 'mark_favorite' => 'f', + 'go_website' => 'space', + 'next_entry' => 'j', + 'prev_entry' => 'k', + 'collapse_entry' => 'c', + 'load_more' => 'm' + ); + public $mail_login = ''; + public $mark_when = array ( + 'article' => 'yes', + 'site' => 'yes', + 'scroll' => 'no', + 'reception' => 'no' + ); + public $sharing = array ( + 'shaarli' => '', + 'poche' => '', + 'diaspora' => '', + 'twitter' => true, + 'g+' => true, + 'facebook' => true, + 'email' => true, + 'print' => true + ); + public $theme = 'default'; + public $anon_access = 'no'; + public $token = ''; + public $auto_load_more = 'no'; + public $topline_read = 'yes'; + public $topline_favorite = 'yes'; + public $topline_date = 'yes'; + public $topline_link = 'yes'; + public $bottomline_read = 'yes'; + public $bottomline_favorite = 'yes'; + public $bottomline_sharing = 'yes'; + public $bottomline_tags = 'yes'; + public $bottomline_date = 'yes'; + public $bottomline_link = 'yes'; + + public function __construct ($nameFile = '') { + if (empty($nameFile)) { + $nameFile = DATA_PATH . '/' . Minz_Configuration::currentUser () . '_user.php'; + } + parent::__construct ($nameFile); + + // TODO : simplifier ce code, une boucle for() devrait suffire ! + if (isset ($this->array['language'])) { + $this->language = $this->array['language']; + } + if (isset ($this->array['posts_per_page'])) { + $this->posts_per_page = $this->array['posts_per_page']; + } + if (isset ($this->array['view_mode'])) { + $this->view_mode = $this->array['view_mode']; + } + if (isset ($this->array['default_view'])) { + $this->default_view = $this->array['default_view']; + } + if (isset ($this->array['display_posts'])) { + $this->display_posts = $this->array['display_posts']; + } + if (isset ($this->array['onread_jump_next'])) { + $this->onread_jump_next = $this->array['onread_jump_next']; + } + if (isset ($this->array['lazyload'])) { + $this->lazyload = $this->array['lazyload']; + } + if (isset ($this->array['sort_order'])) { + $this->sort_order = $this->array['sort_order']; + } + if (isset ($this->array['old_entries'])) { + $this->old_entries = $this->array['old_entries']; + } + if (isset ($this->array['shortcuts'])) { + $this->shortcuts = array_merge ( + $this->shortcuts, $this->array['shortcuts'] + ); + } + if (isset ($this->array['mail_login'])) { + $this->mail_login = $this->array['mail_login']; + } + if (isset ($this->array['mark_when'])) { + $this->mark_when = $this->array['mark_when']; + } + if (isset ($this->array['sharing'])) { + $this->sharing = array_merge ( + $this->sharing, $this->array['sharing'] + ); + } + if (isset ($this->array['theme'])) { + $this->theme = $this->array['theme']; + } + if (isset ($this->array['anon_access'])) { + $this->anon_access = $this->array['anon_access']; + } + if (isset ($this->array['token'])) { + $this->token = $this->array['token']; + } + if (isset ($this->array['auto_load_more'])) { + $this->auto_load_more = $this->array['auto_load_more']; + } + + if (isset ($this->array['topline_read'])) { + $this->topline_read = $this->array['topline_read']; + } + if (isset ($this->array['topline_favorite'])) { + $this->topline_favorite = $this->array['topline_favorite']; + } + if (isset ($this->array['topline_date'])) { + $this->topline_date = $this->array['topline_date']; + } + if (isset ($this->array['topline_link'])) { + $this->topline_link = $this->array['topline_link']; + } + if (isset ($this->array['bottomline_read'])) { + $this->bottomline_read = $this->array['bottomline_read']; + } + if (isset ($this->array['bottomline_favorite'])) { + $this->bottomline_favorite = $this->array['bottomline_favorite']; + } + if (isset ($this->array['bottomline_sharing'])) { + $this->bottomline_sharing = $this->array['bottomline_sharing']; + } + if (isset ($this->array['bottomline_tags'])) { + $this->bottomline_tags = $this->array['bottomline_tags']; + } + if (isset ($this->array['bottomline_date'])) { + $this->bottomline_date = $this->array['bottomline_date']; + } + if (isset ($this->array['bottomline_link'])) { + $this->bottomline_link = $this->array['bottomline_link']; + } + } + + public function update ($values) { + foreach ($values as $key => $value) { + $this->array[$key] = $value; + } + + $this->writeFile($this->array); + invalidateHttpCache(); + } +} diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php new file mode 100644 index 000000000..8c18150b6 --- /dev/null +++ b/app/Models/EntryDAO.php @@ -0,0 +1,425 @@ +prefix . 'entry`(id, guid, title, author, content_bin, link, date, is_read, is_favorite, id_feed, tags) ' + . 'VALUES(?, ?, ?, ?, COMPRESS(?), ?, ?, ?, ?, ?, ?)'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $valuesTmp['id'], + substr($valuesTmp['guid'], 0, 760), + substr($valuesTmp['title'], 0, 255), + substr($valuesTmp['author'], 0, 255), + $valuesTmp['content'], + substr($valuesTmp['link'], 0, 1023), + $valuesTmp['date'], + $valuesTmp['is_read'], + $valuesTmp['is_favorite'], + $valuesTmp['id_feed'], + substr($valuesTmp['tags'], 0, 1023), + ); + + if ($stm && $stm->execute ($values)) { + return $this->bd->lastInsertId(); + } else { + $info = $stm->errorInfo(); + if ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries + Minz_Log::record ('SQL error ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] + . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title'], Minz_Log::ERROR); + } /*else { + Minz_Log::record ('SQL error ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] + . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title'], Minz_Log::DEBUG); + }*/ + return false; + } + } + + public function markFavorite ($id, $is_favorite = true) { + $sql = 'UPDATE `' . $this->prefix . 'entry` e ' + . 'SET e.is_favorite = ? ' + . 'WHERE e.id=?'; + $values = array ($is_favorite ? 1 : 0, $id); + $stm = $this->bd->prepare ($sql); + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + public function markRead ($id, $is_read = true) { + $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' + . 'SET e.is_read = ?,' + . 'f.cache_nbUnreads=f.cache_nbUnreads' . ($is_read ? '-' : '+') . '1 ' + . 'WHERE e.id=?'; + $values = array ($is_read ? 1 : 0, $id); + $stm = $this->bd->prepare ($sql); + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + public function markReadEntries ($idMax = 0, $favorites = false) { + if ($idMax === 0) { + $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' + . 'SET e.is_read = 1, f.cache_nbUnreads=0 ' + . 'WHERE e.is_read = 0 AND '; + if ($favorites) { + $sql .= 'e.is_favorite = 1'; + } else { + $sql .= 'f.priority > 0'; + } + $stm = $this->bd->prepare ($sql); + if ($stm && $stm->execute ()) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } else { + $this->bd->beginTransaction (); + + $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' + . 'SET e.is_read = 1 ' + . 'WHERE e.is_read = 0 AND e.id <= ? AND '; + if ($favorites) { + $sql .= 'e.is_favorite = 1'; + } else { + $sql .= 'f.priority > 0'; + } + $values = array ($idMax); + $stm = $this->bd->prepare ($sql); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + $this->bd->rollBack (); + return false; + } + $affected = $stm->rowCount(); + + if ($affected > 0) { + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' + . 'LEFT OUTER JOIN (' + . 'SELECT e.id_feed, ' + . 'COUNT(*) AS nbUnreads ' + . 'FROM `' . $this->prefix . 'entry` e ' + . 'WHERE e.is_read = 0 ' + . 'GROUP BY e.id_feed' + . ') x ON x.id_feed=f.id ' + . 'SET f.cache_nbUnreads=COALESCE(x.nbUnreads, 0)'; + $stm = $this->bd->prepare ($sql); + if (!($stm && $stm->execute ())) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + $this->bd->rollBack (); + return false; + } + } + + $this->bd->commit (); + return $affected; + } + } + public function markReadCat ($id, $idMax = 0) { + if ($idMax === 0) { + $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' + . 'SET e.is_read = 1, f.cache_nbUnreads=0 ' + . 'WHERE f.category = ? AND e.is_read = 0'; + $values = array ($id); + $stm = $this->bd->prepare ($sql); + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } else { + $this->bd->beginTransaction (); + + $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' + . 'SET e.is_read = 1 ' + . 'WHERE f.category = ? AND e.is_read = 0 AND e.id <= ?'; + $values = array ($id, $idMax); + $stm = $this->bd->prepare ($sql); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + $this->bd->rollBack (); + return false; + } + $affected = $stm->rowCount(); + + if ($affected > 0) { + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' + . 'LEFT OUTER JOIN (' + . 'SELECT e.id_feed, ' + . 'COUNT(*) AS nbUnreads ' + . 'FROM `' . $this->prefix . 'entry` e ' + . 'WHERE e.is_read = 0 ' + . 'GROUP BY e.id_feed' + . ') x ON x.id_feed=f.id ' + . 'SET f.cache_nbUnreads=COALESCE(x.nbUnreads, 0) ' + . 'WHERE f.category = ?'; + $values = array ($id); + $stm = $this->bd->prepare ($sql); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + $this->bd->rollBack (); + return false; + } + } + + $this->bd->commit (); + return $affected; + } + } + public function markReadFeed ($id, $idMax = 0) { + if ($idMax === 0) { + $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' + . 'SET e.is_read = 1, f.cache_nbUnreads=0 ' + . 'WHERE f.id=? AND e.is_read = 0'; + $values = array ($id); + $stm = $this->bd->prepare ($sql); + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } else { + $this->bd->beginTransaction (); + + $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' + . 'SET e.is_read = 1 ' + . 'WHERE f.id=? AND e.is_read = 0 AND e.id <= ?'; + $values = array ($id, $idMax); + $stm = $this->bd->prepare ($sql); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + $this->bd->rollBack (); + return false; + } + $affected = $stm->rowCount(); + + if ($affected > 0) { + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' + . 'SET f.cache_nbUnreads=f.cache_nbUnreads-' . $affected + . ' WHERE f.id=?'; + $values = array ($id); + $stm = $this->bd->prepare ($sql); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + $this->bd->rollBack (); + return false; + } + } + + $this->bd->commit (); + return $affected; + } + } + + public function searchByGuid ($feed_id, $id) { + // un guid est unique pour un flux donné + $sql = 'SELECT id, guid, title, author, UNCOMPRESS(content_bin) AS content, link, date, is_read, is_favorite, id_feed, tags ' + . 'FROM `' . $this->prefix . 'entry` WHERE id_feed=? AND guid=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $feed_id, + $id + ); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $entries = HelperEntry::daoToEntry ($res); + return isset ($entries[0]) ? $entries[0] : false; + } + + public function searchById ($id) { + $sql = 'SELECT id, guid, title, author, UNCOMPRESS(content_bin) AS content, link, date, is_read, is_favorite, id_feed, tags ' + . 'FROM `' . $this->prefix . 'entry` WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $entries = HelperEntry::daoToEntry ($res); + return isset ($entries[0]) ? $entries[0] : false; + } + + public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = -1, $filter = '') { + $where = ''; + $values = array(); + switch ($type) { + case 'a': + $where .= 'priority > 0 '; + break; + case 's': + $where .= 'is_favorite = 1 '; + break; + case 'c': + $where .= 'category = ? '; + $values[] = intval($id); + break; + case 'f': + $where .= 'id_feed = ? '; + $values[] = intval($id); + break; + default: + throw new FreshRSS_EntriesGetter_Exception ('Bad type in Entry->listByType: [' . $type . ']!'); + } + switch ($state) { + case 'all': + break; + case 'not_read': + $where .= 'AND is_read = 0 '; + break; + case 'read': + $where .= 'AND is_read = 1 '; + break; + default: + throw new FreshRSS_EntriesGetter_Exception ('Bad state in Entry->listByType: [' . $state . ']!'); + } + switch ($order) { + case 'DESC': + case 'ASC': + break; + default: + throw new FreshRSS_EntriesGetter_Exception ('Bad order in Entry->listByType: [' . $order . ']!'); + } + if ($firstId > 0) { + $where .= 'AND e.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' '; + } + $terms = array_unique(explode(' ', trim($filter))); + sort($terms); //Put #tags first + $having = ''; + foreach ($terms as $word) { + if (!empty($word)) { + if ($word[0] === '#' && isset($word[1])) { + $having .= 'AND tags LIKE ? '; + $values[] = '%' . $word .'%'; + } elseif (!empty($word)) { + $having .= 'AND (e.title LIKE ? OR content LIKE ?) '; + $values[] = '%' . $word .'%'; + $values[] = '%' . $word .'%'; + } + } + } + + $sql = 'SELECT e.id, e.guid, e.title, e.author, UNCOMPRESS(e.content_bin) AS content, e.link, e.date, e.is_read, e.is_favorite, e.id_feed, e.tags ' + . 'FROM `' . $this->prefix . 'entry` e ' + . 'INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id WHERE ' . $where + . (empty($having) ? '' : 'HAVING' . substr($having, 3)) + . 'ORDER BY e.id ' . $order; + + if ($limit > 0) { + $sql .= ' LIMIT ' . $limit; //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/ + } + + $stm = $this->bd->prepare ($sql); + $stm->execute ($values); + + return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); + } + + public function listLastGuidsByFeed($id, $n) { + $sql = 'SELECT guid FROM `' . $this->prefix . 'entry` WHERE id_feed=? ORDER BY id DESC LIMIT ' . intval($n); + $stm = $this->bd->prepare ($sql); + $values = array ($id); + $stm->execute ($values); + return $stm->fetchAll (PDO::FETCH_COLUMN, 0); + } + + public function countUnreadRead () { + $sql = 'SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id WHERE priority > 0' + . ' UNION SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id WHERE priority > 0 AND is_read = 0'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_COLUMN, 0); + $all = empty($res[0]) ? 0 : $res[0]; + $unread = empty($res[1]) ? 0 : $res[1]; + return array('all' => $all, 'unread' => $unread, 'read' => $all - $unread); + } + public function count ($minPriority = null) { + $sql = 'SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id'; + if ($minPriority !== null) { + $sql = ' WHERE priority > ' . intval($minPriority); + } + $stm = $this->bd->prepare ($sql); + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_COLUMN, 0); + return $res[0]; + } + public function countNotRead ($minPriority = null) { + $sql = 'SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id WHERE is_read = 0'; + if ($minPriority !== null) { + $sql = ' AND priority > ' . intval($minPriority); + } + $stm = $this->bd->prepare ($sql); + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_COLUMN, 0); + return $res[0]; + } + + public function countUnreadReadFavorites () { + $sql = 'SELECT COUNT(id) FROM `' . $this->prefix . 'entry` WHERE is_favorite=1' + . ' UNION SELECT COUNT(id) FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 AND is_read = 0'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_COLUMN, 0); + $all = empty($res[0]) ? 0 : $res[0]; + $unread = empty($res[1]) ? 0 : $res[1]; + return array('all' => $all, 'unread' => $unread, 'read' => $all - $unread); + } + + public function optimizeTable() { + $sql = 'OPTIMIZE TABLE `' . $this->prefix . 'entry`'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + } +} + +class HelperEntry { + public static function daoToEntry ($listDAO) { + $list = array (); + + if (!is_array ($listDAO)) { + $listDAO = array ($listDAO); + } + + foreach ($listDAO as $key => $dao) { + $entry = new FreshRSS_Entry ( + $dao['id_feed'], + $dao['guid'], + $dao['title'], + $dao['author'], + $dao['content'], + $dao['link'], + $dao['date'], + $dao['is_read'], + $dao['is_favorite'], + $dao['tags'] + ); + if (isset ($dao['id'])) { + $entry->_id ($dao['id']); + } + $list[] = $entry; + } + + unset ($listDAO); + + return $list; + } +} diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php new file mode 100644 index 000000000..8f59b1c76 --- /dev/null +++ b/app/Models/FeedDAO.php @@ -0,0 +1,341 @@ +prefix . 'feed` (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, 0)'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + substr($valuesTmp['url'], 0, 511), + $valuesTmp['category'], + substr($valuesTmp['name'], 0, 255), + substr($valuesTmp['website'], 0, 255), + substr($valuesTmp['description'], 0, 1023), + $valuesTmp['lastUpdate'], + base64_encode ($valuesTmp['httpAuth']), + ); + + if ($stm && $stm->execute ($values)) { + return $this->bd->lastInsertId(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + public function updateFeed ($id, $valuesTmp) { + $set = ''; + foreach ($valuesTmp as $key => $v) { + $set .= $key . '=?, '; + + if ($key == 'httpAuth') { + $valuesTmp[$key] = base64_encode ($v); + } + } + $set = substr ($set, 0, -2); + + $sql = 'UPDATE `' . $this->prefix . 'feed` SET ' . $set . ' WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + foreach ($valuesTmp as $v) { + $values[] = $v; + } + $values[] = $id; + + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + 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); + + $values = array ( + time (), + $inError, + $id, + ); + + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + public function changeCategory ($idOldCat, $idNewCat) { + $catDAO = new FreshRSS_CategoryDAO (); + $newCat = $catDAO->searchById ($idNewCat); + if (!$newCat) { + $newCat = $catDAO->getDefault (); + } + + $sql = 'UPDATE `' . $this->prefix . 'feed` SET category=? WHERE category=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $newCat->id (), + $idOldCat + ); + + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + public function deleteFeed ($id) { + /*//For MYISAM (MySQL 5.5-) without FOREIGN KEY + $sql = 'DELETE FROM `' . $this->prefix . 'entry` WHERE id_feed=?'; + $stm = $this->bd->prepare ($sql); + $values = array ($id); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + }*/ + + $sql = 'DELETE FROM `' . $this->prefix . 'feed` WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + public function deleteFeedByCategory ($id) { + /*//For MYISAM (MySQL 5.5-) without FOREIGN KEY + $sql = 'DELETE FROM `' . $this->prefix . 'entry` e ' + . 'INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' + . 'WHERE f.category=?'; + $stm = $this->bd->prepare ($sql); + $values = array ($id); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + }*/ + + $sql = 'DELETE FROM `' . $this->prefix . 'feed` WHERE category=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + public function searchById ($id) { + $sql = 'SELECT * FROM `' . $this->prefix . 'feed` WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $feed = HelperFeed::daoToFeed ($res); + + if (isset ($feed[$id])) { + return $feed[$id]; + } else { + return false; + } + } + public function searchByUrl ($url) { + $sql = 'SELECT * FROM `' . $this->prefix . 'feed` WHERE url=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($url); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $feed = current (HelperFeed::daoToFeed ($res)); + + if (isset ($feed)) { + return $feed; + } else { + return false; + } + } + + public function listFeeds () { + $sql = 'SELECT * FROM `' . $this->prefix . 'feed` ORDER BY name'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + + return HelperFeed::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC)); + } + + public function listFeedsOrderUpdate () { + $sql = 'SELECT * FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + + return HelperFeed::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC)); + } + + public function listByCategory ($cat) { + $sql = 'SELECT * FROM `' . $this->prefix . 'feed` WHERE category=? ORDER BY name'; + $stm = $this->bd->prepare ($sql); + + $values = array ($cat); + + $stm->execute ($values); + + return HelperFeed::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC)); + } + + public function countEntries ($id) { + $sql = 'SELECT COUNT(*) AS count FROM `' . $this->prefix . 'entry` WHERE id_feed=?'; + $stm = $this->bd->prepare ($sql); + $values = array ($id); + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + + return $res[0]['count']; + } + public function countNotRead ($id) { + $sql = 'SELECT COUNT(*) AS count FROM `' . $this->prefix . 'entry` WHERE id_feed=? AND is_read=0'; + $stm = $this->bd->prepare ($sql); + $values = array ($id); + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + + return $res[0]['count']; + } + public function updateCachedValues () { //For one single feed, call updateLastUpdate($id) + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' + . 'INNER JOIN (' + . 'SELECT e.id_feed, ' + . 'COUNT(CASE WHEN e.is_read = 0 THEN 1 END) AS nbUnreads, ' + . 'COUNT(e.id) AS nbEntries ' + . 'FROM `' . $this->prefix . 'entry` e ' + . 'GROUP BY e.id_feed' + . ') x ON x.id_feed=f.id ' + . 'SET f.cache_nbEntries=x.nbEntries, f.cache_nbUnreads=x.nbUnreads'; + $stm = $this->bd->prepare ($sql); + + $values = array ($feed_id); + + if ($stm && $stm->execute ($values)) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } + + public function truncate ($id) { + $sql = 'DELETE e.* FROM `' . $this->prefix . 'entry` e WHERE e.id_feed=?'; + $stm = $this->bd->prepare($sql); + $values = array($id); + $this->bd->beginTransaction (); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + $this->bd->rollBack (); + return false; + } + $affected = $stm->rowCount(); + + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' + . 'SET f.cache_nbEntries=0, f.cache_nbUnreads=0 WHERE f.id=?'; + $values = array ($id); + $stm = $this->bd->prepare ($sql); + if (!($stm && $stm->execute ($values))) { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + $this->bd->rollBack (); + return false; + } + + $this->bd->commit (); + return $affected; + } + + public function cleanOldEntries ($id, $date_min, $keep = 15) { //Remember to call updateLastUpdate($id) just after + $sql = 'DELETE e.* FROM `' . $this->prefix . 'entry` e ' + . 'WHERE e.id_feed = :id_feed AND e.id <= :id_max AND e.is_favorite = 0 AND e.id NOT IN ' + . '(SELECT id FROM (SELECT e2.id FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed = :id_feed ORDER BY id DESC LIMIT :keep) keep)'; //Double select because of: MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' + $stm = $this->bd->prepare ($sql); + + $id_max = intval($date_min) . '000000'; + + $stm->bindParam(':id_feed', $id, PDO::PARAM_INT); + $stm->bindParam(':id_max', $id_max, PDO::PARAM_INT); + $stm->bindParam(':keep', $keep, PDO::PARAM_INT); + + if ($stm && $stm->execute ()) { + return $stm->rowCount(); + } else { + $info = $stm->errorInfo(); + Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + return false; + } + } +} + +class HelperFeed { + public static function daoToFeed ($listDAO, $catID = null) { + $list = array (); + + if (!is_array ($listDAO)) { + $listDAO = array ($listDAO); + } + + foreach ($listDAO as $key => $dao) { + if (!isset ($dao['name'])) { + continue; + } + if (isset ($dao['id'])) { + $key = $dao['id']; + } + + $myFeed = new FreshRSS_Feed (isset($dao['url']) ? $dao['url'] : '', false); + $myFeed->_category ($catID === null ? $dao['category'] : $catID); + $myFeed->_name ($dao['name']); + $myFeed->_website ($dao['website'], false); + $myFeed->_description (isset($dao['description']) ? $dao['description'] : ''); + $myFeed->_lastUpdate (isset($dao['lastUpdate']) ? $dao['lastUpdate'] : 0); + $myFeed->_priority ($dao['priority']); + $myFeed->_pathEntries (isset($dao['pathEntries']) ? $dao['pathEntries'] : ''); + $myFeed->_httpAuth (isset($dao['httpAuth']) ? base64_decode ($dao['httpAuth']) : ''); + $myFeed->_error ($dao['error']); + $myFeed->_keepHistory (isset($dao['keep_history']) ? $dao['keep_history'] : ''); + $myFeed->_nbNotRead ($dao['cache_nbUnreads']); + $myFeed->_nbEntries ($dao['cache_nbEntries']); + if (isset ($dao['id'])) { + $myFeed->_id ($dao['id']); + } + $list[$key] = $myFeed; + } + + return $list; + } +} diff --git a/app/Models/Log.php b/app/Models/Log.php new file mode 100644 index 000000000..d2794458b --- /dev/null +++ b/app/Models/Log.php @@ -0,0 +1,26 @@ +date; + } + public function level () { + return $this->level; + } + public function info () { + return $this->information; + } + public function _date ($date) { + $this->date = $date; + } + public function _level ($level) { + $this->level = $level; + } + public function _info ($information) { + $this->information = $information; + } +} diff --git a/app/Models/LogDAO.php b/app/Models/LogDAO.php new file mode 100644 index 000000000..bf043fd6d --- /dev/null +++ b/app/Models/LogDAO.php @@ -0,0 +1,20 @@ +readLine ()) !== false) { + if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) { + $myLog = new FreshRSS_Log (); + $myLog->_date ($matches[1]); + $myLog->_level ($matches[2]); + $myLog->_info ($matches[3]); + $logs[] = $myLog; + } + } + return $logs; + } +} diff --git a/app/Models/Themes.php b/app/Models/Themes.php new file mode 100644 index 000000000..a52812339 --- /dev/null +++ b/app/Models/Themes.php @@ -0,0 +1,88 @@ + '✚', + 'all' => '☰', + 'bookmark' => '★', + 'category' => '☷', + 'category-white' => '☷', + 'close' => '❌', + 'configure' => '⚙', + 'down' => '▽', + 'favorite' => '★', + 'help' => 'ⓘ', + 'link' => '↗', + 'login' => '🔒', + 'logout' => '🔓', + 'next' => '⏩', + 'non-starred' => '☆', + 'prev' => '⏪', + 'read' => '☑', + 'unread' => '☐', + 'refresh' => '🔃', //↻ + 'search' => '🔍', + 'share' => '♺', + 'starred' => '★', + 'tag' => '⚐', + 'up' => '△', + ); + if (!isset($alts[$name])) { + return ''; + } + + $url = $name . '.svg'; + $url = isset(self::$themeIcons[$url]) ? (self::$themeIconsUrl . $url) : + (self::$defaultIconsUrl . $url); + + return $urlOnly ? Minz_Url::display($url) : + '' . $alts[$name] . ''; + } +} diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index deec54a2b..0e7fbbdde 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -1,33 +1,33 @@ view->conf) && !is_logged ()) { - Error::error ( + Minz_Error::error ( 403, - array ('error' => array (Translate::t ('access_denied'))) + array ('error' => array (Minz_Translate::t ('access_denied'))) ); } - $catDAO = new CategoryDAO (); + $catDAO = new FreshRSS_CategoryDAO (); $catDAO->checkDefault (); } public function categorizeAction () { - $feedDAO = new FeedDAO (); - $catDAO = new CategoryDAO (); + $feedDAO = new FreshRSS_FeedDAO (); + $catDAO = new FreshRSS_CategoryDAO (); $catDAO->checkDefault (); $defaultCategory = $catDAO->getDefault (); $defaultId = $defaultCategory->id (); - if (Request::isPost ()) { - $cats = Request::param ('categories', array ()); - $ids = Request::param ('ids', array ()); - $newCat = trim (Request::param ('new_category', '')); + if (Minz_Request::isPost ()) { + $cats = Minz_Request::param ('categories', array ()); + $ids = Minz_Request::param ('ids', array ()); + $newCat = trim (Minz_Request::param ('new_category', '')); foreach ($cats as $key => $name) { if (strlen ($name) > 0) { - $cat = new Category ($name); + $cat = new FreshRSS_Category ($name); $values = array ( 'name' => $cat->name (), 'color' => $cat->color () @@ -40,7 +40,7 @@ class configureController extends ActionController { } if ($newCat != '') { - $cat = new Category ($newCat); + $cat = new FreshRSS_Category ($newCat); $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), @@ -55,11 +55,11 @@ class configureController extends ActionController { // notif $notif = array ( 'type' => 'good', - 'content' => Translate::t ('categories_updated') + 'content' => Minz_Translate::t ('categories_updated') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); - Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true); } $this->view->categories = $catDAO->listCategories (false); @@ -67,17 +67,17 @@ class configureController extends ActionController { $this->view->feeds = $feedDAO->listFeeds (); $this->view->flux = false; - View::prependTitle (Translate::t ('categories_management') . ' - '); + Minz_View::prependTitle (Minz_Translate::t ('categories_management') . ' - '); } public function feedAction () { - $catDAO = new CategoryDAO (); + $catDAO = new FreshRSS_CategoryDAO (); $this->view->categories = $catDAO->listCategories (false); - $feedDAO = new FeedDAO (); + $feedDAO = new FreshRSS_FeedDAO (); $this->view->feeds = $feedDAO->listFeeds (); - $id = Request::param ('id'); + $id = Minz_Request::param ('id'); if ($id == false && !empty ($this->view->feeds)) { $id = current ($this->view->feeds)->id (); } @@ -87,22 +87,22 @@ class configureController extends ActionController { $this->view->flux = $this->view->feeds[$id]; if (!$this->view->flux) { - Error::error ( + Minz_Error::error ( 404, - array ('error' => array (Translate::t ('page_not_found'))) + array ('error' => array (Minz_Translate::t ('page_not_found'))) ); } else { - if (Request::isPost () && $this->view->flux) { - $name = Request::param ('name', ''); - $description = Request::param('description', ''); - $website = Request::param('website', ''); - $url = Request::param('url', ''); - $hist = Request::param ('keep_history', 'no'); - $cat = Request::param ('category', 0); - $path = Request::param ('path_entries', ''); - $priority = Request::param ('priority', 0); - $user = Request::param ('http_user', ''); - $pass = Request::param ('http_pass', ''); + if (Minz_Request::isPost () && $this->view->flux) { + $name = Minz_Request::param ('name', ''); + $description = Minz_Request::param('description', ''); + $website = Minz_Request::param('website', ''); + $url = Minz_Request::param('url', ''); + $hist = Minz_Request::param ('keep_history', 'no'); + $cat = Minz_Request::param ('category', 0); + $path = Minz_Request::param ('path_entries', ''); + $priority = Minz_Request::param ('priority', 0); + $user = Minz_Request::param ('http_user', ''); + $pass = Minz_Request::param ('http_pass', ''); $keep_history = false; if ($hist == 'yes') { @@ -131,58 +131,58 @@ class configureController extends ActionController { $notif = array ( 'type' => 'good', - 'content' => Translate::t ('feed_updated') + 'content' => Minz_Translate::t ('feed_updated') ); } else { $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('error_occurred_update') + 'content' => Minz_Translate::t ('error_occurred_update') ); } - Session::_param ('notification', $notif); - Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $id)), true); + Minz_Session::_param ('notification', $notif); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $id)), true); } - View::prependTitle (Translate::t ('rss_feed_management') . ' - ' . $this->view->flux->name () . ' - '); + Minz_View::prependTitle (Minz_Translate::t ('rss_feed_management') . ' - ' . $this->view->flux->name () . ' - '); } } else { - View::prependTitle (Translate::t ('rss_feed_management') . ' - '); + Minz_View::prependTitle (Minz_Translate::t ('rss_feed_management') . ' - '); } } public function displayAction () { - if (Request::isPost ()) { + if (Minz_Request::isPost ()) { $current_token = $this->view->conf->token (); - $language = Request::param ('language', 'en'); - $nb = Request::param ('posts_per_page', 10); - $mode = Request::param ('view_mode', 'normal'); - $view = Request::param ('default_view', 'a'); - $auto_load_more = Request::param ('auto_load_more', 'no'); - $display = Request::param ('display_posts', 'no'); - $onread_jump_next = Request::param ('onread_jump_next', 'no'); - $lazyload = Request::param ('lazyload', 'no'); - $sort = Request::param ('sort_order', 'DESC'); - $old = Request::param ('old_entries', 3); - $mail = Request::param ('mail_login', false); - $anon = Request::param ('anon_access', 'no'); - $token = Request::param ('token', $current_token); - $openArticle = Request::param ('mark_open_article', 'no'); - $openSite = Request::param ('mark_open_site', 'no'); - $scroll = Request::param ('mark_scroll', 'no'); - $reception = Request::param ('mark_upon_reception', 'no'); - $theme = Request::param ('theme', 'default'); - $topline_read = Request::param ('topline_read', 'no'); - $topline_favorite = Request::param ('topline_favorite', 'no'); - $topline_date = Request::param ('topline_date', 'no'); - $topline_link = Request::param ('topline_link', 'no'); - $bottomline_read = Request::param ('bottomline_read', 'no'); - $bottomline_favorite = Request::param ('bottomline_favorite', 'no'); - $bottomline_sharing = Request::param ('bottomline_sharing', 'no'); - $bottomline_tags = Request::param ('bottomline_tags', 'no'); - $bottomline_date = Request::param ('bottomline_date', 'no'); - $bottomline_link = Request::param ('bottomline_link', 'no'); + $language = Minz_Request::param ('language', 'en'); + $nb = Minz_Request::param ('posts_per_page', 10); + $mode = Minz_Request::param ('view_mode', 'normal'); + $view = Minz_Request::param ('default_view', 'a'); + $auto_load_more = Minz_Request::param ('auto_load_more', 'no'); + $display = Minz_Request::param ('display_posts', 'no'); + $onread_jump_next = Minz_Request::param ('onread_jump_next', 'no'); + $lazyload = Minz_Request::param ('lazyload', 'no'); + $sort = Minz_Request::param ('sort_order', 'DESC'); + $old = Minz_Request::param ('old_entries', 3); + $mail = Minz_Request::param ('mail_login', false); + $anon = Minz_Request::param ('anon_access', 'no'); + $token = Minz_Request::param ('token', $current_token); + $openArticle = Minz_Request::param ('mark_open_article', 'no'); + $openSite = Minz_Request::param ('mark_open_site', 'no'); + $scroll = Minz_Request::param ('mark_scroll', 'no'); + $reception = Minz_Request::param ('mark_upon_reception', 'no'); + $theme = Minz_Request::param ('theme', 'default'); + $topline_read = Minz_Request::param ('topline_read', 'no'); + $topline_favorite = Minz_Request::param ('topline_favorite', 'no'); + $topline_date = Minz_Request::param ('topline_date', 'no'); + $topline_link = Minz_Request::param ('topline_link', 'no'); + $bottomline_read = Minz_Request::param ('bottomline_read', 'no'); + $bottomline_favorite = Minz_Request::param ('bottomline_favorite', 'no'); + $bottomline_sharing = Minz_Request::param ('bottomline_sharing', 'no'); + $bottomline_tags = Minz_Request::param ('bottomline_tags', 'no'); + $bottomline_date = Minz_Request::param ('bottomline_date', 'no'); + $bottomline_link = Minz_Request::param ('bottomline_link', 'no'); $this->view->conf->_language ($language); $this->view->conf->_postsPerPage (intval ($nb)); @@ -243,81 +243,81 @@ class configureController extends ActionController { 'bottomline_link' => $this->view->conf->bottomlineLink () ? 'yes' : 'no', ); - $confDAO = new RSSConfigurationDAO (); + $confDAO = new FreshRSS_ConfigurationDAO (); $confDAO->update ($values); - Session::_param ('conf', $this->view->conf); - Session::_param ('mail', $this->view->conf->mailLogin ()); + Minz_Session::_param ('conf', $this->view->conf); + Minz_Session::_param ('mail', $this->view->conf->mailLogin ()); - Session::_param ('language', $this->view->conf->language ()); + Minz_Session::_param ('language', $this->view->conf->language ()); Translate::reset (); // notif $notif = array ( 'type' => 'good', - 'content' => Translate::t ('configuration_updated') + 'content' => Minz_Translate::t ('configuration_updated') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); - Request::forward (array ('c' => 'configure', 'a' => 'display'), true); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'display'), true); } - $this->view->themes = RSSThemes::get(); + $this->view->themes = FreshRSS_Themes::get(); - View::prependTitle (Translate::t ('general_and_reading_management') . ' - '); + Minz_View::prependTitle (Minz_Translate::t ('general_and_reading_management') . ' - '); - $entryDAO = new EntryDAO (); + $entryDAO = new FreshRSS_EntryDAO (); $this->view->nb_total = $entryDAO->count (); $this->view->size_total = $entryDAO->size (); } public function sharingAction () { - if (Request::isPost ()) { + if (Minz_Request::isPost ()) { $this->view->conf->_sharing (array ( - 'shaarli' => Request::param ('shaarli', ''), - 'poche' => Request::param ('poche', ''), - 'diaspora' => Request::param ('diaspora', ''), - 'twitter' => Request::param ('twitter', 'no') === 'yes', - 'g+' => Request::param ('g+', 'no') === 'yes', - 'facebook' => Request::param ('facebook', 'no') === 'yes', - 'email' => Request::param ('email', 'no') === 'yes', - 'print' => Request::param ('print', 'no') === 'yes' + 'shaarli' => Minz_Request::param ('shaarli', ''), + 'poche' => Minz_Request::param ('poche', ''), + 'diaspora' => Minz_Request::param ('diaspora', ''), + 'twitter' => Minz_Request::param ('twitter', 'no') === 'yes', + 'g+' => Minz_Request::param ('g+', 'no') === 'yes', + 'facebook' => Minz_Request::param ('facebook', 'no') === 'yes', + 'email' => Minz_Request::param ('email', 'no') === 'yes', + 'print' => Minz_Request::param ('print', 'no') === 'yes' )); - $confDAO = new RSSConfigurationDAO (); + $confDAO = new FreshRSS_ConfigurationDAO (); $confDAO->update ($this->view->conf->sharing ()); - Session::_param ('conf', $this->view->conf); + Minz_Session::_param ('conf', $this->view->conf); // notif $notif = array ( 'type' => 'good', - 'content' => Translate::t ('configuration_updated') + 'content' => Minz_Translate::t ('configuration_updated') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); - Request::forward (array ('c' => 'configure', 'a' => 'sharing'), true); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'sharing'), true); } - View::prependTitle (Translate::t ('sharing_management') . ' - '); + Minz_View::prependTitle (Minz_Translate::t ('sharing_management') . ' - '); - $entryDAO = new EntryDAO (); + $entryDAO = new FreshRSS_EntryDAO (); $this->view->nb_total = $entryDAO->count (); } public function importExportAction () { - $catDAO = new CategoryDAO (); + $catDAO = new FreshRSS_CategoryDAO (); $this->view->categories = $catDAO->listCategories (); - $this->view->req = Request::param ('q'); + $this->view->req = Minz_Request::param ('q'); if ($this->view->req == 'export') { - View::_title ('freshrss_feeds.opml'); + Minz_View::_title ('freshrss_feeds.opml'); $this->view->_useLayout (false); header('Content-Type: application/xml; charset=utf-8'); header('Content-disposition: attachment; filename=freshrss_feeds.opml'); - $feedDAO = new FeedDAO (); - $catDAO = new CategoryDAO (); + $feedDAO = new FreshRSS_FeedDAO (); + $catDAO = new FreshRSS_CategoryDAO (); $list = array (); foreach ($catDAO->listCategories () as $key => $cat) { @@ -326,7 +326,7 @@ class configureController extends ActionController { } $this->view->categories = $list; - } elseif ($this->view->req == 'import' && Request::isPost ()) { + } elseif ($this->view->req == 'import' && Minz_Request::isPost ()) { if ($_FILES['file']['error'] == 0) { // on parse le fichier OPML pour récupérer les catégories et les flux associés try { @@ -336,20 +336,20 @@ class configureController extends ActionController { // On redirige vers le controller feed qui va se charger d'insérer les flux en BDD // les flux sont mis au préalable dans des variables de Request - Request::_param ('q', 'null'); - Request::_param ('categories', $categories); - Request::_param ('feeds', $feeds); - Request::forward (array ('c' => 'feed', 'a' => 'massiveImport')); - } catch (OpmlException $e) { + Minz_Request::_param ('q', 'null'); + Minz_Request::_param ('categories', $categories); + Minz_Request::_param ('feeds', $feeds); + Minz_Request::forward (array ('c' => 'feed', 'a' => 'massiveImport')); + } catch (FreshRSS_Opml_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('bad_opml_file') + 'content' => Minz_Translate::t ('bad_opml_file') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); - Request::forward (array ( + Minz_Request::forward (array ( 'c' => 'configure', 'a' => 'importExport' ), true); @@ -357,13 +357,13 @@ class configureController extends ActionController { } } - $feedDAO = new FeedDAO (); + $feedDAO = new FreshRSS_FeedDAO (); $this->view->feeds = $feedDAO->listFeeds (); // au niveau de la vue, permet de ne pas voir un flux sélectionné dans la liste $this->view->flux = false; - View::prependTitle (Translate::t ('import_export_opml') . ' - '); + Minz_View::prependTitle (Translate::t ('import_export_opml') . ' - '); } public function shortcutAction () { @@ -379,8 +379,8 @@ class configureController extends ActionController { 'prev_entry', 'next_page', 'prev_page', 'collapse_entry', 'load_more'); - if (Request::isPost ()) { - $shortcuts = Request::param ('shortcuts'); + if (Minz_Request::isPost ()) { + $shortcuts = Minz_Request::param ('shortcuts'); $shortcuts_ok = array (); foreach ($shortcuts as $key => $value) { @@ -396,20 +396,20 @@ class configureController extends ActionController { 'shortcuts' => $this->view->conf->shortcuts () ); - $confDAO = new RSSConfigurationDAO (); + $confDAO = new FreshRSS_ConfigurationDAO (); $confDAO->update ($values); - Session::_param ('conf', $this->view->conf); + Minz_Session::_param ('conf', $this->view->conf); // notif $notif = array ( 'type' => 'good', - 'content' => Translate::t ('shortcuts_updated') + 'content' => Minz_Translate::t ('shortcuts_updated') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); - Request::forward (array ('c' => 'configure', 'a' => 'shortcut'), true); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'shortcut'), true); } - View::prependTitle (Translate::t ('shortcuts_management') . ' - '); + Minz_View::prependTitle (Minz_Translate::t ('shortcuts_management') . ' - '); } } diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index c01139ba4..a332ca8a9 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -1,46 +1,46 @@ view->conf) && !is_logged ()) { - Error::error ( + Minz_Error::error ( 403, - array ('error' => array (Translate::t ('access_denied'))) + array ('error' => array (Minz_Translate::t ('access_denied'))) ); } $this->params = array (); $this->redirect = false; - $ajax = Request::param ('ajax'); + $ajax = Minz_Request::param ('ajax'); if ($ajax) { $this->view->_useLayout (false); } } public function lastAction () { - $ajax = Request::param ('ajax'); + $ajax = Minz_Request::param ('ajax'); if (!$ajax && $this->redirect) { - Request::forward (array ( + Minz_Request::forward (array ( 'c' => 'index', 'a' => 'index', 'params' => $this->params ), true); } else { - Request::_param ('ajax'); + Minz_Request::_param ('ajax'); } } public function readAction () { $this->redirect = true; - $id = Request::param ('id'); - $is_read = Request::param ('is_read'); - $get = Request::param ('get'); - $nextGet = Request::param ('nextGet', $get); - $idMax = Request::param ('idMax', 0); + $id = Minz_Request::param ('id'); + $is_read = Minz_Request::param ('is_read'); + $get = Minz_Request::param ('get'); + $nextGet = Minz_Request::param ('nextGet', $get); + $idMax = Minz_Request::param ('idMax', 0); $is_read = !!$is_read; - $entryDAO = new EntryDAO (); + $entryDAO = new FreshRSS_EntryDAO (); if ($id == false) { if (!$get) { $entryDAO->markReadEntries ($idMax); @@ -68,9 +68,9 @@ class entryController extends ActionController { $notif = array ( 'type' => 'good', - 'content' => Translate::t ('feeds_marked_read') + 'content' => Minz_Translate::t ('feeds_marked_read') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); } else { $entryDAO->markRead ($id, $is_read); } @@ -79,10 +79,10 @@ class entryController extends ActionController { public function bookmarkAction () { $this->redirect = true; - $id = Request::param ('id'); + $id = Minz_Request::param ('id'); if ($id) { - $entryDAO = new EntryDAO (); - $entryDAO->markFavorite ($id, Request::param ('is_favorite')); + $entryDAO = new FreshRSS_EntryDAO (); + $entryDAO->markFavorite ($id, Minz_Request::param ('is_favorite')); } } @@ -93,18 +93,18 @@ class entryController extends ActionController { // La table des entrées a tendance à grossir énormément // Cette action permet d'optimiser cette table permettant de grapiller un peu de place // Cette fonctionnalité n'est à appeler qu'occasionnellement - $entryDAO = new EntryDAO(); + $entryDAO = new FreshRSS_EntryDAO(); $entryDAO->optimizeTable(); invalidateHttpCache(); $notif = array ( 'type' => 'good', - 'content' => Translate::t ('optimization_complete') + 'content' => Minz_Translate::t ('optimization_complete') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); - Request::forward(array( + Minz_Request::forward(array( 'c' => 'configure', 'a' => 'display' ), true); diff --git a/app/controllers/errorController.php b/app/controllers/errorController.php index 092609280..d1c2f8fec 100644 --- a/app/controllers/errorController.php +++ b/app/controllers/errorController.php @@ -1,8 +1,8 @@ view->code = 'Error 403 - Forbidden'; break; @@ -19,8 +19,8 @@ class ErrorController extends ActionController { $this->view->code = 'Error 404 - Not found'; } - $this->view->logs = Request::param ('logs'); + $this->view->logs = Minz_Request::param ('logs'); - View::prependTitle ($this->view->code . ' - '); + Minz_View::prependTitle ($this->view->code . ' - '); } } diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 24b8627ff..e4014c326 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -1,22 +1,22 @@ view->conf->token(); - $token_param = Request::param ('token', ''); + $token_param = Minz_Request::param ('token', ''); $token_is_ok = ($token != '' && $token == $token_param); - $action = Request::actionName (); + $action = Minz_Request::actionName (); if (login_is_conf ($this->view->conf) && !is_logged () && !($token_is_ok && $action == 'actualize')) { - Error::error ( + Minz_Error::error ( 403, - array ('error' => array (Translate::t ('access_denied'))) + array ('error' => array (Minz_Translate::t ('access_denied'))) ); } - $this->catDAO = new CategoryDAO (); + $this->catDAO = new FreshRSS_CategoryDAO (); $this->catDAO->checkDefault (); } @@ -32,21 +32,21 @@ class feedController extends ActionController { public function addAction () { @set_time_limit(300); - if (Request::isPost ()) { - $url = Request::param ('url_rss'); - $cat = Request::param ('category', false); + if (Minz_Request::isPost ()) { + $url = Minz_Request::param ('url_rss'); + $cat = Minz_Request::param ('category', false); if ($cat === false) { $def_cat = $this->catDAO->getDefault (); $cat = $def_cat->id (); } - $user = Request::param ('username'); - $pass = Request::param ('password'); + $user = Minz_Request::param ('username'); + $pass = Minz_Request::param ('password'); $params = array (); $transactionStarted = false; try { - $feed = new Feed ($url); + $feed = new FreshRSS_Feed ($url); $feed->_category ($cat); $httpAuth = ''; @@ -57,7 +57,7 @@ class feedController extends ActionController { $feed->load (); - $feedDAO = new FeedDAO (); + $feedDAO = new FreshRSS_FeedDAO (); $values = array ( 'url' => $feed->url (), 'category' => $feed->category (), @@ -72,25 +72,25 @@ class feedController extends ActionController { // on est déjà abonné à ce flux $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('already_subscribed', $feed->name ()) + 'content' => Minz_Translate::t ('already_subscribed', $feed->name ()) ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); } else { $id = $feedDAO->addFeed ($values); if (!$id) { // problème au niveau de la base de données $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('feed_not_added', $feed->name ()) + 'content' => Minz_Translate::t ('feed_not_added', $feed->name ()) ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); } else { $feed->_id ($id); $feed->faviconPrepare(); $is_read = $this->view->conf->markUponReception() === 'yes' ? 1 : 0; - $entryDAO = new EntryDAO (); + $entryDAO = new FreshRSS_EntryDAO (); $entries = $feed->entries (); usort($entries, 'self::entryDateComparer'); @@ -118,68 +118,68 @@ class feedController extends ActionController { // ok, ajout terminé $notif = array ( 'type' => 'good', - 'content' => Translate::t ('feed_added', $feed->name ()) + 'content' => Minz_Translate::t ('feed_added', $feed->name ()) ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); // permet de rediriger vers la page de conf du flux $params['id'] = $feed->id (); } } - } catch (BadUrlException $e) { + } catch (FreshRSS_BadUrl_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('invalid_url', $url) + 'content' => Minz_Translate::t ('invalid_url', $url) ); - Session::_param ('notification', $notif); - } catch (FeedException $e) { + Minz_Session::_param ('notification', $notif); + } catch (FreshRSS_Feed_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('internal_problem_feed') + 'content' => Minz_Translate::t ('internal_problem_feed') ); - Session::_param ('notification', $notif); - } catch (FileNotExistException $e) { + Minz_Session::_param ('notification', $notif); + } catch (Minz_FileNotExistException $e) { // Répertoire de cache n'existe pas Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('internal_problem_feed') + 'content' => Minz_Translate::t ('internal_problem_feed') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); } if ($transactionStarted) { $feedDAO->rollBack (); } - Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => $params), true); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => $params), true); } } public function truncateAction () { - if (Request::isPost ()) { - $id = Request::param ('id'); - $feedDAO = new FeedDAO (); + if (Minz_Request::isPost ()) { + $id = Minz_Request::param ('id'); + $feedDAO = new FreshRSS_FeedDAO (); $n = $feedDAO->truncate($id); $notif = array( 'type' => $n === false ? 'bad' : 'good', - 'content' => Translate::t ('n_entries_deleted', $n) + 'content' => Minz_Translate::t ('n_entries_deleted', $n) ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); invalidateHttpCache(); - Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array('id' => $id)), true); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array('id' => $id)), true); } } public function actualizeAction () { @set_time_limit(300); - $feedDAO = new FeedDAO (); - $entryDAO = new EntryDAO (); + $feedDAO = new FreshRSS_FeedDAO (); + $entryDAO = new FreshRSS_EntryDAO (); - $id = Request::param ('id'); - $force = Request::param ('force', false); + $id = Minz_Request::param ('id'); + $force = Minz_Request::param ('force', false); // on créé la liste des flux à mettre à actualiser // si on veut mettre un flux à jour spécifiquement, on le met @@ -236,7 +236,7 @@ class feedController extends ActionController { $feedDAO->updateLastUpdate ($feed->id ()); $feedDAO->commit (); $flux_update++; - } catch (FeedException $e) { + } catch (FreshRSS_Feed_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); $feedDAO->updateLastUpdate ($feed->id (), 1); } @@ -254,19 +254,19 @@ class feedController extends ActionController { // on a mis un seul flux à jour $notif = array ( 'type' => 'good', - 'content' => Translate::t ('feed_actualized', $feed->name ()) + 'content' => Minz_Translate::t ('feed_actualized', $feed->name ()) ); } elseif ($flux_update > 1) { // plusieurs flux on été mis à jour $notif = array ( 'type' => 'good', - 'content' => Translate::t ('n_feeds_actualized', $flux_update) + 'content' => Minz_Translate::t ('n_feeds_actualized', $flux_update) ); } else { // aucun flux n'a été mis à jour, oups $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('no_feed_actualized') + 'content' => Minz_Translate::t ('no_feed_actualized') ); } @@ -277,9 +277,9 @@ class feedController extends ActionController { $url['params'] = array ('get' => 'f_' . $feed->id ()); } - if (Request::param ('ajax', 0) === 0) { - Session::_param ('notification', $notif); - Request::forward ($url, true); + if (Minz_Request::param ('ajax', 0) === 0) { + Minz_Session::_param ('notification', $notif); + Minz_Request::forward ($url, true); } else { // Une requête Ajax met un seul flux à jour. // Comme en principe plusieurs requêtes ont lieu, @@ -288,9 +288,9 @@ class feedController extends ActionController { // ressenti utilisateur $notif = array ( 'type' => 'good', - 'content' => Translate::t ('feeds_actualized') + 'content' => Minz_Translate::t ('feeds_actualized') ); - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); // et on désactive le layout car ne sert à rien $this->view->_useLayout (false); } @@ -299,11 +299,11 @@ class feedController extends ActionController { public function massiveImportAction () { @set_time_limit(300); - $entryDAO = new EntryDAO (); - $feedDAO = new FeedDAO (); + $entryDAO = new FreshRSS_EntryDAO (); + $feedDAO = new FreshRSS_FeedDAO (); - $categories = Request::param ('categories', array (), true); - $feeds = Request::param ('feeds', array (), true); + $categories = Minz_Request::param ('categories', array (), true); + $feeds = Minz_Request::param ('feeds', array (), true); // on ajoute les catégories en masse dans une fonction à part $this->addCategories ($categories); @@ -341,78 +341,78 @@ class feedController extends ActionController { $error = true; } } - } catch (FeedException $e) { + } catch (FreshRSS_Feed_Exception $e) { $error = true; Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); } } if ($error) { - $res = Translate::t ('feeds_imported_with_errors'); + $res = Minz_Translate::t ('feeds_imported_with_errors'); } else { - $res = Translate::t ('feeds_imported'); + $res = Minz_Translate::t ('feeds_imported'); } $notif = array ( 'type' => 'good', 'content' => $res ); - Session::_param ('notification', $notif); - Session::_param ('actualize_feeds', true); + Minz_Session::_param ('notification', $notif); + Minz_Session::_param ('actualize_feeds', true); // et on redirige vers la page d'accueil - Request::forward (array ( + Minz_Request::forward (array ( 'c' => 'index', 'a' => 'index' ), true); } public function deleteAction () { - if (Request::isPost ()) { - $type = Request::param ('type', 'feed'); - $id = Request::param ('id'); + if (Minz_Request::isPost ()) { + $type = Minz_Request::param ('type', 'feed'); + $id = Minz_Request::param ('id'); - $feedDAO = new FeedDAO (); + $feedDAO = new FreshRSS_FeedDAO (); if ($type == 'category') { if ($feedDAO->deleteFeedByCategory ($id)) { $notif = array ( 'type' => 'good', - 'content' => Translate::t ('category_emptied') + 'content' => Minz_Translate::t ('category_emptied') ); //TODO: Delete old favicons } else { $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('error_occured') + 'content' => Minz_Translate::t ('error_occured') ); } } else { if ($feedDAO->deleteFeed ($id)) { $notif = array ( 'type' => 'good', - 'content' => Translate::t ('feed_deleted') + 'content' => Minz_Translate::t ('feed_deleted') ); Feed::faviconDelete($id); } else { $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('error_occured') + 'content' => Minz_Translate::t ('error_occured') ); } } - Session::_param ('notification', $notif); + Minz_Session::_param ('notification', $notif); if ($type == 'category') { - Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true); } else { - Request::forward (array ('c' => 'configure', 'a' => 'feed'), true); + Minz_Request::forward (array ('c' => 'configure', 'a' => 'feed'), true); } } } private function addCategories ($categories) { - $catDAO = new CategoryDAO (); + $catDAO = new FreshRSS_CategoryDAO (); foreach ($categories as $cat) { if (!$catDAO->searchByName ($cat->name ())) { diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 9c1e18f0b..16a053ba3 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -1,6 +1,6 @@ entryDAO = new EntryDAO (); - $this->feedDAO = new FeedDAO (); - $this->catDAO = new CategoryDAO (); + $this->entryDAO = new FreshRSS_EntryDAO (); + $this->feedDAO = new FreshRSS_FeedDAO (); + $this->catDAO = new FreshRSS_CategoryDAO (); } public function indexAction () { - $output = Request::param ('output'); + $output = Minz_Request::param ('output'); $token = $this->view->conf->token(); - $token_param = Request::param ('token', ''); + $token_param = Minz_Request::param ('token', ''); $token_is_ok = ($token != '' && $token === $token_param); // check if user is log in @@ -30,7 +30,7 @@ class indexController extends ActionController { } // construction of RSS url of this feed - $params = Request::params (); + $params = Minz_Request::params (); $params['output'] = 'rss'; if (isset ($params['search'])) { $params['search'] = urlencode ($params['search']); @@ -51,10 +51,10 @@ class indexController extends ActionController { $this->view->_useLayout (false); header('Content-Type: application/rss+xml; charset=utf-8'); } else { - View::appendScript (Url::display ('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); + Minz_View::appendScript (Minz_Url::display ('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); if ($output === 'global') { - View::appendScript (Url::display ('/scripts/global_view.js?' . @filemtime(PUBLIC_PATH . '/scripts/global_view.js'))); + Minz_View::appendScript (Minz_Url::display ('/scripts/global_view.js?' . @filemtime(PUBLIC_PATH . '/scripts/global_view.js'))); } } @@ -65,14 +65,14 @@ class indexController extends ActionController { $this->view->get_c = ''; $this->view->get_f = ''; - $get = Request::param ('get', 'a'); + $get = Minz_Request::param ('get', 'a'); $getType = $get[0]; $getId = substr ($get, 2); if (!$this->checkAndProcessType ($getType, $getId)) { Minz_Log::record ('Not found [' . $getType . '][' . $getId . ']', Minz_Log::DEBUG); - Error::error ( + Minz_Error::error ( 404, - array ('error' => array (Translate::t ('page_not_found'))) + array ('error' => array (Minz_Translate::t ('page_not_found'))) ); return; } @@ -80,25 +80,25 @@ class indexController extends ActionController { $this->view->nb_not_read = HelperCategory::CountUnreads($this->view->cat_aside, 1); // mise à jour des titres - $this->view->rss_title = $this->view->currentName . ' | ' . View::title(); + $this->view->rss_title = $this->view->currentName . ' | ' . Minz_View::title(); if ($this->view->nb_not_read > 0) { - View::appendTitle (' (' . $this->view->nb_not_read . ')'); + Minz_View::appendTitle (' (' . $this->view->nb_not_read . ')'); } - View::prependTitle ( + Minz_View::prependTitle ( $this->view->currentName . ($this->nb_not_read_cat > 0 ? ' (' . $this->nb_not_read_cat . ')' : '') . ' - ' ); // On récupère les différents éléments de filtrage - $this->view->state = $state = Request::param ('state', $this->view->conf->defaultView ()); - $filter = Request::param ('search', ''); + $this->view->state = $state = Minz_Request::param ('state', $this->view->conf->defaultView ()); + $filter = Minz_Request::param ('search', ''); if (!empty($filter)) { $state = 'all'; //Search always in read and unread articles } - $this->view->order = $order = Request::param ('order', $this->view->conf->sortOrder ()); - $nb = Request::param ('nb', $this->view->conf->postsPerPage ()); - $first = Request::param ('next', ''); + $this->view->order = $order = Minz_Request::param ('order', $this->view->conf->sortOrder ()); + $nb = Minz_Request::param ('nb', $this->view->conf->postsPerPage ()); + $first = Minz_Request::param ('next', ''); if ($state === 'not_read') { //Any unread article in this category at all? switch ($getType) { @@ -143,11 +143,11 @@ class indexController extends ActionController { } $this->view->entries = $entries; - } catch (EntriesGetterException $e) { + } catch (FreshRSS_EntriesGetter_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); - Error::error ( + Minz_Error::error ( 404, - array ('error' => array (Translate::t ('page_not_found'))) + array ('error' => array (Minz_Translate::t ('page_not_found'))) ); } } @@ -160,11 +160,11 @@ class indexController extends ActionController { private function checkAndProcessType ($getType, $getId) { switch ($getType) { case 'a': - $this->view->currentName = Translate::t ('your_rss_feeds'); + $this->view->currentName = Minz_Translate::t ('your_rss_feeds'); $this->view->get_c = $getType; return true; case 's': - $this->view->currentName = Translate::t ('your_favorites'); + $this->view->currentName = Minz_Translate::t ('your_favorites'); $this->view->get_c = $getType; return true; case 'c': @@ -200,35 +200,35 @@ class indexController extends ActionController { } public function aboutAction () { - View::prependTitle (Translate::t ('about') . ' - '); + Minz_View::prependTitle (Minz_Translate::t ('about') . ' - '); } public function logsAction () { if (login_is_conf ($this->view->conf) && !is_logged ()) { - Error::error ( + Minz_Error::error ( 403, - array ('error' => array (Translate::t ('access_denied'))) + array ('error' => array (Minz_Translate::t ('access_denied'))) ); } - View::prependTitle (Translate::t ('logs') . ' - '); + Minz_View::prependTitle (Minz_Translate::t ('logs') . ' - '); - if (Request::isPost ()) { + if (Minz_Request::isPost ()) { file_put_contents(LOG_PATH . '/application.log', ''); } $logs = array(); try { - $logDAO = new LogDAO (); + $logDAO = new FreshRSS_LogDAO (); $logs = $logDAO->lister (); $logs = array_reverse ($logs); - } catch(FileNotExistException $e) { + } catch (Minz_FileNotExistException $e) { } //gestion pagination - $page = Request::param ('page', 1); - $this->view->logsPaginator = new Paginator ($logs); + $page = Minz_Request::param ('page', 1); + $this->view->logsPaginator = new Minz_Paginator ($logs); $this->view->logsPaginator->_nbItemsPerPage (50); $this->view->logsPaginator->_currentPage ($page); } @@ -237,9 +237,9 @@ class indexController extends ActionController { $this->view->_useLayout (false); $url = 'https://verifier.login.persona.org/verify'; - $assert = Request::param ('assertion'); + $assert = Minz_Request::param ('assertion'); $params = 'assertion=' . $assert . '&audience=' . - urlencode (Url::display (null, 'php', true)); + urlencode (Minz_Url::display (null, 'php', true)); $ch = curl_init (); $options = array ( CURLOPT_URL => $url, @@ -253,12 +253,12 @@ class indexController extends ActionController { $res = json_decode ($result, true); if ($res['status'] === 'okay' && $res['email'] === $this->view->conf->mailLogin ()) { - Session::_param ('mail', $res['email']); + Minz_Session::_param ('mail', $res['email']); invalidateHttpCache(); } else { $res = array (); $res['status'] = 'failure'; - $res['reason'] = Translate::t ('invalid_login'); + $res['reason'] = Minz_Translate::t ('invalid_login'); } header('Content-Type: application/json; charset=UTF-8'); @@ -267,7 +267,7 @@ class indexController extends ActionController { public function logoutAction () { $this->view->_useLayout (false); - Session::_param ('mail'); + Minz_Session::_param ('mail'); invalidateHttpCache(); } } diff --git a/app/controllers/javascriptController.php b/app/controllers/javascriptController.php index 291474130..e7e25f656 100755 --- a/app/controllers/javascriptController.php +++ b/app/controllers/javascriptController.php @@ -1,13 +1,13 @@ view->_useLayout (false); header('Content-type: text/javascript'); } public function actualizeAction () { - $feedDAO = new FeedDAO (); + $feedDAO = new FreshRSS_FeedDAO (); $this->view->feeds = $feedDAO->listFeeds (); } } diff --git a/app/layout/aside_configure.phtml b/app/layout/aside_configure.phtml index 7dbe445b2..aa46af95d 100644 --- a/app/layout/aside_configure.phtml +++ b/app/layout/aside_configure.phtml @@ -1,13 +1,13 @@ diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 2ce0b3ba4..7fbccce1e 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -1,17 +1,17 @@ diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index ce5ded230..9a6b16d58 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -1,23 +1,23 @@
- +
    conf) || is_logged ()) { ?>
  • - - + +
  • conf)) { ?> -
  • +
  • @@ -25,8 +25,8 @@
  • @@ -38,7 +38,7 @@ get_c == $cat->id ()) { $c_active = true; } ?>
      @@ -49,7 +49,7 @@
    • ✇ @@ -67,13 +67,13 @@ diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 12af6057a..6cb1380a3 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -1,9 +1,9 @@ conf)) { ?> @@ -12,8 +12,8 @@ @@ -24,25 +24,25 @@ $this->conf->anonAccess() == 'yes') { ?>
      - - + + - + - + - + - +
      @@ -53,19 +53,19 @@ @@ -74,7 +74,7 @@ if (login_is_conf ($this->conf) && !is_logged ()) { ?>
      - +
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index ac00e8fd0..b7c34f04e 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -11,19 +11,19 @@ //]]> nextId)) { - $params = Request::params (); + $params = Minz_Request::params (); $params['next'] = $this->nextId; ?> - + - + rss_url)) { ?> - + - - - - + + + + @@ -39,7 +39,7 @@ ?>
notification['content']; ?> - +
diff --git a/app/layout/nav_entries.phtml b/app/layout/nav_entries.phtml index 0811fe8fa..3141e92a0 100644 --- a/app/layout/nav_entries.phtml +++ b/app/layout/nav_entries.phtml @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index f3e985dc0..92a987aed 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -1,22 +1,22 @@