fix favicon test on public side
This commit is contained in:
parent
4aafa5128f
commit
19f70a0b64
1 changed files with 18 additions and 16 deletions
34
_public.php
34
_public.php
|
@ -31,30 +31,30 @@ class publicSimplyFavicon extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$mimetypes = self::$mimetypes;
|
$public_path = path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT);
|
||||||
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
|
|
||||||
|
|
||||||
if (!$core->blog->settings->system->simply_favicon
|
if ($core->blog->settings->system->simply_favicon
|
||||||
|| empty($arg)
|
&& !empty($arg)
|
||||||
|| !array_key_exists($arg, $mimetypes)
|
&& array_key_exists($arg, self::$mimetypes)
|
||||||
|| file_exists($public_path . 'favicon' . $arg)
|
&& file_exists($public_path . '/favicon.' . $arg)
|
||||||
) {
|
) {
|
||||||
throw new Exception('Page not found', 404);
|
header('Content-Type: ' . self::$mimetypes[$arg] . ';');
|
||||||
|
readfile($public_path . '/favicon.' . $arg);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: ' . $mimetypes[$arg] . ';');
|
self::p404();
|
||||||
readfile($public_path . $arg);
|
|
||||||
exit;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function publicHeadContent($core)
|
public static function publicHeadContent($core)
|
||||||
{
|
{
|
||||||
if (!$core->blog->settings->system->simply_favicon) {
|
if (!$core->blog->settings->system->simply_favicon) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mimetypes = self::$mimetypes;
|
$public_path = path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT) . '/favicon.';
|
||||||
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
|
|
||||||
$public_url = $core->blog->url . $core->url->getBase('simplyFavicon') . '.';
|
$public_url = $core->blog->url . $core->url->getBase('simplyFavicon') . '.';
|
||||||
|
|
||||||
// ico : IE6
|
// ico : IE6
|
||||||
|
@ -67,10 +67,12 @@ class publicSimplyFavicon extends dcUrlHandlers
|
||||||
echo
|
echo
|
||||||
'<link rel="apple-touch-icon" href="' . $public_url . 'png" />' . "\n" .
|
'<link rel="apple-touch-icon" href="' . $public_url . 'png" />' . "\n" .
|
||||||
'<link rel="icon" type="image/png" href="' . $public_url . 'png" />' . "\n";
|
'<link rel="icon" type="image/png" href="' . $public_url . 'png" />' . "\n";
|
||||||
}
|
|
||||||
// all others
|
// all others
|
||||||
else {
|
} else {
|
||||||
foreach ($mimetypes as $ext => $mime) {
|
foreach (self::$mimetypes as $ext => $mime) {
|
||||||
|
if (in_array($ext, ['ico', 'png'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (file_exists($public_path . $ext)) {
|
if (file_exists($public_path . $ext)) {
|
||||||
echo
|
echo
|
||||||
'<link rel="icon" type="' . $mime . '" href="' . $public_url . $ext . '" />' . "\n";
|
'<link rel="icon" type="' . $mime . '" href="' . $public_url . $ext . '" />' . "\n";
|
||||||
|
|
Loading…
Reference in a new issue