<?php /* Image server */ // serves image files via HTTP if (isset($_GET['img'])) { $img = $_GET['img']; streamImage(PATH_PHP_IMAGES . $img); } function streamImage($path = '') { if (file_exists($path)) { $pi = pathinfo($path); // ,PATHINFO_EXTENSION switch ($pi['extension']) { default: $contentType = 'image/jpeg'; break; case 'gif': $contentType = 'image/gif'; break; case 'png': $contentType = 'image/png'; break; } header("Content-type: " . $contentType); readfile($path); } else { die; } }
$th_type = $thSize[2]; if ($th_height != $height or $th_width != $width) { $th->delete(); $th_result = $imageutils->resizeImage($file->getAbsolutePath(), $th->getAbsolutePath(), $width, $height, $ext, $th_quality); } if ($file->lastModified() != $th->lastModified()) { $th->delete(); $th_result = $imageutils->resizeImage($file->getAbsolutePath(), $th->getAbsolutePath(), $width, $height, $ext, $th_quality); } if ($th_result) { $th->setLastModified($file->lastModified()); } // Output image streamImage($th->getAbsolutePath(), $th_type, $th_preview); } else { if (!$th->exists() and $config['thumbnail.gd.auto_generate'] == true) { $th_result = $imageutils->resizeImage($file->getAbsolutePath(), $th->getAbsolutePath(), $width, $height, $ext, $th_quality); if ($th_result && $th->exists()) { $thSize = @getimagesize($th->getAbsolutePath()); $th_type = $thSize[2]; $th->setLastModified($file->lastModified()); } } } // failsafe check if ($th->exists() && $th_type) { streamImage($th->getAbsolutePath(), $th_type, $th_preview); } else { Header("Location: " . $previewurl); } die;