Browse Source

Favicons compatibles multi-utilisateurs

Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126
Alexandre Alapetite 12 năm trước cách đây
mục cha
commit
574d37bddc

+ 1 - 1
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',

+ 1 - 1
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 '

+ 9 - 4
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) {

+ 1 - 1
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 () {

+ 1 - 1
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';
 }