aboutsummaryrefslogtreecommitdiff
path: root/p/f.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-31 14:48:35 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-31 14:48:35 +0100
commitc29b6d4c226cf9c45d7d372ee4bce3bcbcca99a6 (patch)
tree9a8f2be9185cd110988bf8a687aaa316c9145db9 /p/f.php
parente92acfd8227bc3ac94e9039343ff76c20facf29a (diff)
parente91b72b63cd11ae3c4f59e48439e93955242c673 (diff)
Merge branch 'dev' into beta
Conflicts: README.fr.md README.md
Diffstat (limited to 'p/f.php')
-rw-r--r--p/f.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/p/f.php b/p/f.php
index fefbf9a10..c904e1fcb 100644
--- a/p/f.php
+++ b/p/f.php
@@ -4,6 +4,7 @@ require('../constants.php');
include(LIB_PATH . '/Favicon/Favicon.php');
include(LIB_PATH . '/Favicon/DataAccess.php');
+require(LIB_PATH . '/http-conditional.php');
$favicons_dir = DATA_PATH . '/favicons/';
@@ -46,10 +47,13 @@ function download_favicon($website, $dest) {
function show_default_favicon() {
global $default_favicon;
- header('HTTP/1.1 404 Not Found');
- header('Content-Type: image/ico');
- readfile($default_favicon);
- die();
+ 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)) {
+ readfile($default_favicon);
+ }
}
@@ -64,19 +68,22 @@ $ico = $favicons_dir . $id . '.ico';
$ico_mtime = @filemtime($ico);
$txt_mtime = @filemtime($txt);
-if (($ico_mtime == false) || ($txt_mtime > $ico_mtime)) {
+
+if ($ico_mtime == false || $txt_mtime > $ico_mtime) {
if ($txt_mtime == false) {
show_default_favicon();
+ return;
}
+ // 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();
+ return;
}
}
-require(LIB_PATH . '/http-conditional.php');
-
header('Content-Type: image/x-icon');
header('Content-Disposition: inline; filename="' . $id . '.ico"');