From 58300c36ad77e8d788e99825d509fe8657a36854 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 26 Dec 2013 01:56:58 +0100 Subject: Cookie : sous-répertoire pour index (changements de répertoires !) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implémente https://github.com/marienfressinaud/FreshRSS/issues/333 /public/ est renommé /p/ /public/index.php est déplacé dans /p/i/index.php Le cookie de session est limité à /p/i/ --- p/f.php | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 p/f.php (limited to 'p/f.php') diff --git a/p/f.php b/p/f.php new file mode 100644 index 000000000..a56d58617 --- /dev/null +++ b/p/f.php @@ -0,0 +1,70 @@ + $icoMTime)) { + if ($txtMTime == false) { + header('HTTP/1.1 404 Not Found'); + header('Content-Type: image/gif'); + readfile(PUBLIC_PATH . '/themes/icons/grey.gif'); //TODO: Better 404 favicon + die(); + } + $url = file_get_contents($txt); + if (!download_favicon($url, $ico)) { + die(); + } +} + +require(LIB_PATH . '/http-conditional.php'); + +header('Content-Type: image/x-icon'); +header('Content-Disposition: inline; filename="' . $id . '.ico"'); + +if (!httpConditional($icoMTime, 2592000, 2)) { + readfile($ico); +} -- cgit v1.2.3 From 574d37bddc4e00ddbc6af57c28838e1dea6a730b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 26 Dec 2013 19:58:17 +0100 Subject: Favicons compatibles multi-utilisateurs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126 --- app/Controllers/feedController.php | 2 +- app/Models/CategoryDAO.php | 2 +- app/Models/Feed.php | 13 +++++++++---- lib/Minz/Configuration.php | 2 +- p/f.php | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) (limited to 'p/f.php') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 04d0aa98b..dc8a854a9 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -395,7 +395,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { 'type' => 'good', 'content' => Minz_Translate::t ('feed_deleted') ); - FreshRSS_Feed::faviconDelete($id); + //TODO: Delete old favicon } else { $notif = array ( 'type' => 'bad', diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index 6b07ab063..1cc616ac0 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -90,7 +90,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { 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 ') + . ($details ? 'f.* ' : 'f.id, f.name, f.url, f.website, f.priority, f.error, f.cache_nbEntries, f.cache_nbUnreads ') . 'FROM `' . $this->prefix . 'category` c ' . 'LEFT OUTER JOIN `' . $this->prefix . 'feed` f ON f.category = c.id ' . 'GROUP BY f.id ' diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 3008e33d7..f9a586122 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -28,6 +28,11 @@ class FreshRSS_Feed extends Minz_Model { public function id () { return $this->id; } + + public function hash() { + return hash('crc32b', Minz_Configuration::salt() . $this->url); + } + public function url () { return $this->url; } @@ -96,7 +101,7 @@ class FreshRSS_Feed extends Minz_Model { return $this->nbNotRead; } public function faviconPrepare() { - $file = DATA_PATH . '/favicons/' . $this->id () . '.txt'; + $file = DATA_PATH . '/favicons/' . $this->hash() . '.txt'; if (!file_exists ($file)) { $t = $this->website; if (empty($t)) { @@ -105,13 +110,13 @@ class FreshRSS_Feed extends Minz_Model { file_put_contents($file, $t); } } - public static function faviconDelete($id) { - $path = DATA_PATH . '/favicons/' . $id; + public static function faviconDelete($hash) { + $path = DATA_PATH . '/favicons/' . $hash; @unlink($path . '.ico'); @unlink($path . '.txt'); } public function favicon () { - return Minz_Url::display ('/f.php?' . $this->id ()); + return Minz_Url::display ('/f.php?' . $this->hash()); } public function _id ($value) { diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 1b108dcdf..6c7206988 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -63,7 +63,7 @@ class Minz_Configuration { /* * Getteurs */ - public static function selApplication () { + public static function salt () { return self::$sel_application; } public static function environment () { diff --git a/p/f.php b/p/f.php index a56d58617..872b8cc2c 100644 --- a/p/f.php +++ b/p/f.php @@ -37,7 +37,7 @@ function download_favicon ($website, $dest) { } $id = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '0'; -if (!ctype_digit($id)) { +if (!ctype_xdigit($id)) { $id = '0'; } -- cgit v1.2.3 From 2c57e7254d613683ec20076d37b33ea2a7dd2d83 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 26 Dec 2013 20:11:18 +0100 Subject: Favicons : test pour améliorer le cache HTTP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test d'utilisation de PATH_INFO plutôt que QUERY_STRING pour améliorer la mise en cache. À tester sur différents serveurs --- app/Models/Feed.php | 2 +- p/f.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'p/f.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index f9a586122..4f90b9872 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -116,7 +116,7 @@ class FreshRSS_Feed extends Minz_Model { @unlink($path . '.txt'); } public function favicon () { - return Minz_Url::display ('/f.php?' . $this->hash()); + return Minz_Url::display ('/f.php/' . $this->hash()); } public function _id ($value) { diff --git a/p/f.php b/p/f.php index 872b8cc2c..660128a59 100644 --- a/p/f.php +++ b/p/f.php @@ -36,7 +36,14 @@ function download_favicon ($website, $dest) { return true; } -$id = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '0'; +if (isset($_SERVER['PATH_INFO'])) { + $id = substr($_SERVER['PATH_INFO'], 1); +} elseif (isset($_SERVER['QUERY_STRING'])) { + $id = $_SERVER['QUERY_STRING']; +} else { + $id = '0'; +} + if (!ctype_xdigit($id)) { $id = '0'; } -- cgit v1.2.3 From 3cff96fae3bba77ac630e3ea7076558b10e9ed8b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 12 Jan 2014 16:27:35 +0100 Subject: Corrige problème favicons sous Nginx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/marienfressinaud/FreshRSS/issues/364 --- p/f.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'p/f.php') diff --git a/p/f.php b/p/f.php index 660128a59..5db9ab213 100644 --- a/p/f.php +++ b/p/f.php @@ -7,13 +7,6 @@ function download_favicon ($website, $dest) { $ok = false; $url = 'http://g.etfv.co/' . $website; - /*if (!is_dir ($favicons_dir)) { - if (!mkdir ($favicons_dir, 0755, true)) { - header('Location: ' . $url); - return false; - } - }*/ - $c = curl_init ($url); curl_setopt ($c, CURLOPT_HEADER, false); curl_setopt ($c, CURLOPT_RETURNTRANSFER, true); @@ -36,13 +29,7 @@ function download_favicon ($website, $dest) { return true; } -if (isset($_SERVER['PATH_INFO'])) { - $id = substr($_SERVER['PATH_INFO'], 1); -} elseif (isset($_SERVER['QUERY_STRING'])) { - $id = $_SERVER['QUERY_STRING']; -} else { - $id = '0'; -} +$id = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '0'; if (!ctype_xdigit($id)) { $id = '0'; -- cgit v1.2.3