summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-04-23 22:03:03 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-04-23 22:03:03 +0200
commitbe4f588911c5ef4ad2108154fea0433a90b6e791 (patch)
tree66c6ed1d8960f828e815b1502038e5445ea0ac63
parent70c842031f01422c29fb179610aaf856d92e807c (diff)
parent624824673592dbc21300f9a26c27781f54429de5 (diff)
Merge branch 'favicon_bug' into dev
-rw-r--r--lib/Favicon/DataAccess.php3
-rw-r--r--lib/Favicon/Favicon.php2
-rw-r--r--p/f.php11
3 files changed, 8 insertions, 8 deletions
diff --git a/lib/Favicon/DataAccess.php b/lib/Favicon/DataAccess.php
index 2bfdf640e..17f26b333 100644
--- a/lib/Favicon/DataAccess.php
+++ b/lib/Favicon/DataAccess.php
@@ -15,7 +15,8 @@ class DataAccess {
public function retrieveHeader($url) {
$this->set_context();
- return @get_headers($url, TRUE);
+ $headers = @get_headers($url, 1);
+ return array_change_key_case($headers);
}
public function saveCache($file, $data) {
diff --git a/lib/Favicon/Favicon.php b/lib/Favicon/Favicon.php
index 7ea6ccf16..1912050d6 100644
--- a/lib/Favicon/Favicon.php
+++ b/lib/Favicon/Favicon.php
@@ -99,7 +99,7 @@ class Favicon
switch ($status) {
case '301':
case '302':
- $url = $headers['Location'];
+ $url = isset($headers['location']) ? $headers['location'] : '';
break;
default:
$loop = FALSE;
diff --git a/p/f.php b/p/f.php
index c904e1fcb..0f23921e3 100644
--- a/p/f.php
+++ b/p/f.php
@@ -44,14 +44,13 @@ function download_favicon($website, $dest) {
}
-function show_default_favicon() {
+function show_default_favicon($cacheSeconds = 3600) {
global $default_favicon;
- header('Content-Type: image/x-icon');
header('Content-Disposition: inline; filename="default_favicon.ico"');
$default_mtime = @filemtime($default_favicon);
- if (!httpConditional($default_mtime, 2592000, 2)) {
+ if (!httpConditional($default_mtime, $cacheSeconds, 2)) {
readfile($default_favicon);
}
}
@@ -68,10 +67,11 @@ $ico = $favicons_dir . $id . '.ico';
$ico_mtime = @filemtime($ico);
$txt_mtime = @filemtime($txt);
+header('Content-Type: image/x-icon');
if ($ico_mtime == false || $txt_mtime > $ico_mtime) {
if ($txt_mtime == false) {
- show_default_favicon();
+ show_default_favicon(1800);
return;
}
@@ -79,12 +79,11 @@ if ($ico_mtime == false || $txt_mtime > $ico_mtime) {
$url = file_get_contents($txt);
if (!download_favicon($url, $ico)) {
// Download failed, show the default favicon
- show_default_favicon();
+ show_default_favicon(86400);
return;
}
}
-header('Content-Type: image/x-icon');
header('Content-Disposition: inline; filename="' . $id . '.ico"');
if (!httpConditional($ico_mtime, 2592000, 2)) {