From 9c5c023e36a24b58baeab108012cd9eb42ccda60 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite 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 --- data/.gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 data/.gitignore (limited to 'data') 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 -- cgit v1.2.3 From 2c02fcaa606813db0965a9e8a555fb3c75d18857 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 17 Nov 2013 12:31:51 +0100 Subject: Protection répertoire data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/.htaccess | 3 +++ data/index.html | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 data/.htaccess create mode 100644 data/index.html (limited to 'data') diff --git a/data/.htaccess b/data/.htaccess new file mode 100644 index 000000000..9e768397d --- /dev/null +++ b/data/.htaccess @@ -0,0 +1,3 @@ +Order Allow,Deny +Deny from all +Satisfy all diff --git a/data/index.html b/data/index.html new file mode 100644 index 000000000..2f3b51848 --- /dev/null +++ b/data/index.html @@ -0,0 +1,13 @@ + + + + + +Redirection + + + + +

Redirection

+ + -- 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 'data') 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 609a2f1c271382b72cc132bb5a685b9b8ac6be25 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 17 Nov 2013 17:16:06 +0100 Subject: Changements .gitignore dans ./data --- data/.gitignore | 2 -- data/cache/.gitignore | 1 + data/log/.gitignore | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 data/cache/.gitignore create mode 100644 data/log/.gitignore (limited to 'data') diff --git a/data/.gitignore b/data/.gitignore index 9c60990ac..5d36792ba 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,5 +1,3 @@ -cache -log application.ini *_user.php *.sqlite diff --git a/data/cache/.gitignore b/data/cache/.gitignore new file mode 100644 index 000000000..0307e6493 --- /dev/null +++ b/data/cache/.gitignore @@ -0,0 +1 @@ +*.spc \ No newline at end of file diff --git a/data/log/.gitignore b/data/log/.gitignore new file mode 100644 index 000000000..bf0824e59 --- /dev/null +++ b/data/log/.gitignore @@ -0,0 +1 @@ +*.log \ No newline at end of file -- 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 'data') 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 b0cbc6fe5da527aa2a4fedf4b138264ff983d159 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 1 Dec 2013 22:58:15 +0100 Subject: Favicons en parallèle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nouvelle méthode pour afficher les favicons à la demande et en parallèle. Déplacement du dossier des favicons sous /data/favicons/ Devrait permettre de fermer le problème d'import OPML https://github.com/marienfressinaud/FreshRSS/issues/228 Voir aussi https://github.com/marienfressinaud/FreshRSS/issues/290 --- app/models/Feed.php | 11 +++----- data/favicons/.gitignore | 2 ++ lib/lib_rss.php | 35 ------------------------ public/f.php | 67 ++++++++++++++++++++++++++++++++++++++++++++++ public/favicons/.gitignore | 1 - 5 files changed, 73 insertions(+), 43 deletions(-) create mode 100644 data/favicons/.gitignore create mode 100644 public/f.php delete mode 100644 public/favicons/.gitignore (limited to 'data') diff --git a/app/models/Feed.php b/app/models/Feed.php index f183b2aa7..41eb3df23 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -96,14 +96,11 @@ class Feed extends Model { return $this->nbNotRead; } public function favicon () { - $file = '/favicons/' . $this->id () . '.ico'; - - $favicon_url = Url::display ($file); - if (!file_exists (PUBLIC_PATH . $file)) { - download_favicon ($this->website (), $this->id ()); + $file = DATA_PATH . '/favicons/' . $this->id () . '.txt'; + if (!file_exists ($file)) { + file_put_contents($file, $this->website ()); } - - return $favicon_url; + return Url::display ('/f.php?' . $this->id ()); } public function _id ($value) { diff --git a/data/favicons/.gitignore b/data/favicons/.gitignore new file mode 100644 index 000000000..5ec725522 --- /dev/null +++ b/data/favicons/.gitignore @@ -0,0 +1,2 @@ +*.ico +*.txt \ No newline at end of file diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 46bf76d2c..c4ca03165 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -198,41 +198,6 @@ 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 download_favicon ($website, $id) { - $url = 'http://g.etfv.co/' . $website; - $favicons_dir = PUBLIC_PATH . '/favicons'; - $dest = $favicons_dir . '/' . $id . '.ico'; - - if (!is_dir ($favicons_dir)) { - if (!mkdir ($favicons_dir, 0755, true)) { - return $url; - } - } - - if (!file_exists ($dest)) { - $c = curl_init ($url); - curl_setopt ($c, CURLOPT_HEADER, false); - curl_setopt ($c, CURLOPT_RETURNTRANSFER, true); - curl_setopt ($c, CURLOPT_BINARYTRANSFER, true); - $imgRaw = curl_exec ($c); - - if (curl_getinfo ($c, CURLINFO_HTTP_CODE) == 200) { - $file = fopen ($dest, 'w'); - if ($file === false) { - return $url; - } - - fwrite ($file, $imgRaw); - fclose ($file); - } else { - return $url; - } - - curl_close ($c); - } -} - /** * Add support of image lazy loading * Move content from src attribute to data-original diff --git a/public/f.php b/public/f.php new file mode 100644 index 000000000..3be74776e --- /dev/null +++ b/public/f.php @@ -0,0 +1,67 @@ + $icoMTime)) { + if ($txtMTime == false) { + header('HTTP/1.1 404 Not Found'); + die(); + } + $url = file_get_contents($txt); + if (!download_favicon($url, $ico)) { + die(); + } +} + +header('Content-Type: image/x-icon'); +header('Content-Disposition: inline; filename="' . $id . '.ico"'); + +require(LIB_PATH . '/http-conditional.php'); +if (!httpConditional($icoMTime, 31557600, 2)) { + readfile($ico); +} diff --git a/public/favicons/.gitignore b/public/favicons/.gitignore deleted file mode 100644 index 29d1aae76..000000000 --- a/public/favicons/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.ico \ No newline at end of file -- cgit v1.2.3 From 415d7a5a716726759c30151af11bd588d52acbb2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 22 Dec 2013 16:08:24 +0100 Subject: config.php plutôt que application.ini MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implémente https://github.com/marienfressinaud/FreshRSS/issues/272 --- data/.gitignore | 1 + lib/Minz/Configuration.php | 8 ++--- public/index.php | 2 +- public/install.php | 80 +++++++++++++++++++++++++--------------------- 4 files changed, 48 insertions(+), 43 deletions(-) (limited to 'data') diff --git a/data/.gitignore b/data/.gitignore index 677c8f58c..a8091901a 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,4 +1,5 @@ application.ini +config.php *_user.php *.sqlite touch.txt diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 9fc913964..1b108dcdf 100644 --- 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 Minz_Configuration { - const CONF_PATH_NAME = '/application.ini'; + const CONF_PATH_NAME = '/config.php'; /** * VERSION est la version actuelle de MINZ @@ -126,10 +126,7 @@ class Minz_Configuration { ); } - $ini_array = parse_ini_file ( - DATA_PATH . self::CONF_PATH_NAME, - true - ); + $ini_array = include(DATA_PATH . self::CONF_PATH_NAME); if (!$ini_array) { throw new Minz_PermissionDeniedException ( @@ -147,7 +144,6 @@ class Minz_Configuration { } $general = $ini_array['general']; - // sel_application est obligatoire if (!isset ($general['sel_application'])) { throw new Minz_BadConfigurationException ( diff --git a/public/index.php b/public/index.php index 829e418f9..c8b15b3d9 100755 --- a/public/index.php +++ b/public/index.php @@ -29,7 +29,7 @@ if (file_exists ('install.php')) { $dateLastModification = max( @filemtime(DATA_PATH . '/touch.txt'), @filemtime(LOG_PATH . '/application.log'), - @filemtime(DATA_PATH . '/application.ini') + @filemtime(DATA_PATH . '/config.php') ); $_SERVER['QUERY_STRING'] .= '&utime=' . file_get_contents(DATA_PATH . '/touch.txt'); //For ETag if (httpConditional($dateLastModification, 0, 0, false, false, true)) { diff --git a/public/install.php b/public/install.php index 7fbae3436..dbbecb1a3 100644 --- a/public/install.php +++ b/public/install.php @@ -261,23 +261,29 @@ function saveStep3 () { $_SESSION['bd_prefix'] = addslashes ($_POST['prefix']); $_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] . (empty($_SESSION['default_user']) ? '' : ($_SESSION['default_user'] . '_')); - $file_conf = DATA_PATH . '/application.ini'; - $f = fopen ($file_conf, 'w'); - writeLine ($f, '[general]'); - writeLine ($f, 'environment = "' . empty($_SESSION['environment']) ? 'production' : $_SESSION['environment'] . '"'); - writeLine ($f, 'use_url_rewriting = false'); - writeLine ($f, 'sel_application = "' . $_SESSION['sel_application'] . '"'); - writeLine ($f, 'base_url = ""'); - writeLine ($f, 'title = "' . $_SESSION['title'] . '"'); - writeLine ($f, 'default_user = "' . $_SESSION['default_user'] . '"'); - writeLine ($f, '[db]'); - writeLine ($f, 'type = "' . $_SESSION['bd_type'] . '"'); - writeLine ($f, 'host = "' . $_SESSION['bd_host'] . '"'); - writeLine ($f, 'user = "' . $_SESSION['bd_user'] . '"'); - writeLine ($f, 'password = "' . $_SESSION['bd_password'] . '"'); - writeLine ($f, 'base = "' . $_SESSION['bd_base'] . '"'); - writeLine ($f, 'prefix = "' . $_SESSION['bd_prefix'] . '"'); - fclose ($f); + $ini_array = array( + 'general' => array( + 'environment' => empty($_SESSION['environment']) ? 'production' : $_SESSION['environment'], + 'use_url_rewriting' => false, + 'sel_application' => $_SESSION['sel_application'], + 'base_url' => '', + 'title' => $_SESSION['title'], + 'default_user' => $_SESSION['default_user'], + ), + 'db' => array( + 'type' => $_SESSION['bd_type'], + 'host' => $_SESSION['bd_host'], + 'user' => $_SESSION['bd_user'], + 'password' => $_SESSION['bd_password'], + 'base' => $_SESSION['bd_base'], + 'prefix' => $_SESSION['bd_prefix'], + ), + ); + file_put_contents(DATA_PATH . '/config.php', "