addBehavior('publicHeadContent',array('publicSimplyFavicon','publicHeadContent')); class publicSimplyFavicon extends dcUrlHandlers { public static $mimetypes = array( 'ico' => 'image/x-icon', 'png' => 'image/png', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'mng' => 'video/x-mng' ); public static function simplyFaviconUrl($arg) { global $core; $mimetypes = self::$mimetypes; $public_path = path::real(path::fullFromRoot((string) $core->blog->settings->public_path,DC_ROOT)).'/favicon.'; if (!$core->blog->settings->system->simply_favicon || empty($arg) || !array_key_exists($arg,$mimetypes) || file_exists($public_path.'favicon'.$arg) ) { throw new Exception ("Page not found",404); } else { header('Content-Type: '.$mimetypes[$arg].';'); readfile($public_path.$arg); exit; } } public static function publicHeadContent($core) { if (!$core->blog->settings->system->simply_favicon){return;} $mimetypes = self::$mimetypes; $public_path = path::real(path::fullFromRoot((string) $core->blog->settings->public_path,DC_ROOT)).'/favicon.'; $public_url = $core->blog->url.$core->url->getBase('simplyFavicon').'.'; // ico : IE6 if (file_exists($public_path.'ico') && '?' != substr($core->blog->url,-1)) { echo ''."\n"; } // png: apple and others if (file_exists($public_path.'png')) { echo ''."\n". ''."\n"; } // all others else { foreach($mimetypes as $ext => $mime) { if (file_exists($public_path.$ext)) { echo ''."\n"; break; } } } } } ?>