aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-26 19:58:17 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-26 19:58:17 +0100
commit574d37bddc4e00ddbc6af57c28838e1dea6a730b (patch)
treec8a01810043a473446b61c874995e9d80c1fe197
parent3ba5223e1350bf0c38a81722a7669871400b340a (diff)
Favicons compatibles multi-utilisateurs
Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126
-rwxr-xr-xapp/Controllers/feedController.php2
-rw-r--r--app/Models/CategoryDAO.php2
-rw-r--r--app/Models/Feed.php13
-rw-r--r--lib/Minz/Configuration.php2
-rw-r--r--p/f.php2
5 files changed, 13 insertions, 8 deletions
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';
}