diff options
| author | 2016-10-07 21:55:10 +0200 | |
|---|---|---|
| committer | 2016-10-07 21:55:10 +0200 | |
| commit | f777541ed95eaed41530a1d4756109f644da4a14 (patch) | |
| tree | 03b9eaf2a242b2a7d270d4f83f40fb9d5fa6dd58 | |
| parent | 1cb745818aee43319d2235c13ddded7c6d4c7d86 (diff) | |
| parent | d4c2231a7898b084b6741ceb9b175c9974be65cb (diff) | |
Merge pull request #1290 from Alkarex/refresh-favicon
Auto-refresh favicons
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | lib/Favicon/DataAccess.php | 2 | ||||
| -rw-r--r-- | p/f.php | 16 |
3 files changed, 13 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 27d17624f..c19eb40c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * In a multi-user context, take better advantage of other users’ refreshes [#1280](https://github.com/FreshRSS/FreshRSS/pull/1280) * Support custom ports `localhost:3306` for database servers [#1241](https://github.com/FreshRSS/FreshRSS/issues/1241) * Add date to exported files [#1240](https://github.com/FreshRSS/FreshRSS/issues/1240) + * Auto-refresh favicons after 15 days [#1181](https://github.com/FreshRSS/FreshRSS/issues/1181) * Bug fixing * Correction of bugs related CSRF tokens introduced in version 1.5.0 [#1253](https://github.com/FreshRSS/FreshRSS/issues/1253), [44f22ab](https://github.com/FreshRSS/FreshRSS/pull/1261/commits/d9bf9b2c6f0b2cc9dec3b638841b7e3040dcf46f) * Fix bug in Global view introduced in version 1.5.0 [#1269](https://github.com/FreshRSS/FreshRSS/pull/1269) diff --git a/lib/Favicon/DataAccess.php b/lib/Favicon/DataAccess.php index 17f26b333..ae7509881 100644 --- a/lib/Favicon/DataAccess.php +++ b/lib/Favicon/DataAccess.php @@ -16,7 +16,7 @@ class DataAccess { public function retrieveHeader($url) { $this->set_context(); $headers = @get_headers($url, 1); - return array_change_key_case($headers); + return $headers ? array_change_key_case($headers) : array(); } public function saveCache($file, $data) { @@ -15,6 +15,7 @@ $default_favicon = PUBLIC_PATH . '/themes/icons/default_favicon.ico'; function download_favicon($website, $dest) { global $favicons_dir, $default_favicon; + syslog(LOG_DEBUG, 'FreshRSS Favicon discovery GET ' . $website); $favicon_getter = new \Favicon\Favicon(); $favicon_getter->setCacheDir($favicons_dir); $favicon_url = $favicon_getter->get($website); @@ -23,6 +24,7 @@ function download_favicon($website, $dest) { return @copy($default_favicon, $dest); } + syslog(LOG_DEBUG, 'FreshRSS Favicon GET ' . $favicon_url); $c = curl_init($favicon_url); curl_setopt($c, CURLOPT_HEADER, false); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); @@ -69,18 +71,22 @@ $txt_mtime = @filemtime($txt); header('Content-Type: image/x-icon'); -if ($ico_mtime == false || $txt_mtime > $ico_mtime) { +if ($ico_mtime == false || $txt_mtime > $ico_mtime || ($ico_mtime < time() - 15 * 86400)) { if ($txt_mtime == false) { show_default_favicon(1800); - return; + exit(); } // no ico file or we should download a new one. $url = file_get_contents($txt); if (!download_favicon($url, $ico)) { - // Download failed, show the default favicon - show_default_favicon(86400); - return; + // Download failed + if ($ico_mtime == false) { + show_default_favicon(86400); + exit(); + } else { + touch($ico); + } } } |
