GIF89a;
Direktori : /home/serb/www/ |
Current File : /home/serb/www/avatar.php |
<?php require_once('lib/ak_php_img.php'); $image = isset($_GET['image']) ? str_replace(array('/', '..', '\\'), '', $_GET['image']) : null; $noImage = '../images/no_photo_female.gif'; chdir('avtar'); if (!$image) { $image = $noImage; } if (!is_dir('cache')) { mkdir('cache'); } if (!is_file($image)) { $image = $noImage; } $avatarDir = __DIR__ . '/avtar'; $cacheDir = $avatarDir . '/cache'; $imageArr = explode('.', $image); $ext = array_pop($imageArr); if (!$ext) { $image = $noImage; } switch( strtolower($ext) ) { case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": default: $ctype="image/jpeg"; break; } header('Content-type: ' . $ctype); $fileModTime = filemtime($avatarDir . '/' . $image); // Getting headers sent by the client. $headers = getRequestHeaders(); // Checking if the client is validating his cache and if it is current. if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == $fileModTime)) { // Client's cache IS current, so we just respond '304 Not Modified'. header('Last-Modified: '.gmdate('D, d M Y H:i:s', $fileModTime).' GMT', true, 304); } else { // Image not cached or cache outdated, we respond '200 OK' and output the image. header('Last-Modified: '.gmdate('D, d M Y H:i:s', $fileModTime).' GMT', true, 200); header('Content-Type: '.$ctype); header('Content-Transfer-Encoding: binary'); if (!is_file($cacheDir . '/' . $image)) { ak_img_resize($avatarDir . '/' . $image, $cacheDir . '/' . $image, 210, false, $ext); } header('Content-Length: '.filesize($cacheDir . '/' . $image)); echo file_get_contents($cacheDir . '/' . $image); }