name ?: $item->title; $art = new Art($item->id, $type, $kind); $art->get_db(); $etag = $art->id; // That means the client has a cached version of the image $reqheaders = getallheaders(); if (isset($reqheaders['If-Modified-Since']) && isset($reqheaders['If-None-Match'])) { $ccontrol = $reqheaders['Cache-Control']; if ($ccontrol != 'no-cache') { $cetagf = explode('-', $reqheaders['If-None-Match']); $cetag = $cetagf[0]; // Same image than the cached one? Use the cache. if ($cetag == $etag) { header('HTTP/1.1 304 Not Modified'); exit; } } } if (!$art->raw_mime) { $defaultimg = AmpConfig::get('prefix') . AmpConfig::get('theme_path') . '/images/'; switch ($type) { case 'video': case 'tvshow': case 'tvshow_season': $mime = 'image/png'; $defaultimg .= "blankmovie.png"; break; default: $mime = 'image/jpeg'; $defaultimg .= "blankalbum.jpg"; break; } $image = file_get_contents($defaultimg); } else { if ($_GET['thumb']) { $thumb_data = $art->get_thumb($size); $etag .= '-' . $_GET['thumb']; } $mime = isset($thumb_data['thumb_mime']) ? $thumb_data['thumb_mime'] : $art->raw_mime; $image = isset($thumb_data['thumb']) ? $thumb_data['thumb'] : $art->raw; } } if (!empty($image)) { $extension = Art::extension($mime); $filename = scrub_out($filename . '.' . $extension); // Send the headers and output the image $browser = new Horde_Browser(); if (!empty($etag)) { header('ETag: ' . $etag); header('Cache-Control: private'); header('Last-Modified: '.gmdate('D, d M Y H:i:s \G\M\T', time())); } $browser->downloadHeaders($filename, $mime, true); echo $image; }