[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 i.php

Zen Cart 源代码 i.php




下载文件

文件名: i.php
文件类型: PHP文件
文件大小: 1.25 KiB
MD5: 6369e874daecbfafac99a90ba7ffb4bf

i.php - 关闭高亮
  1. <?php
  2. $filename = '../'.$_REQUEST['f'];
  3.  
  4. if(!file_exists($filename)) die('Error: File does not exist');
  5. if(!function_exists('imagecreatetruecolor')) die('Error: GD2 not installed / configured');
  6.  
  7. $fn_array = explode('.', $filename);
  8. $type = strtolower(end($fn_array));
  9.  
  10. if ($type == 'jpg' || $type == 'jpeg') $img = @imagecreatefromjpeg($filename);
  11. elseif ($type == 'png') $img = @imagecreatefrompng($filename);
  12. elseif ($type == 'gif')  {
  13.     if(!function_exists('imagecreatefromgif')) die('Error: Your version of GD does not support GIFs');
  14.     $img = @imagecreatefromgif($filename);
  15. }
  16. else die("Error: Image type not supported");
  17.  
  18. $x = imagesx($img);
  19. $y = imagesy($img);
  20.  
  21. $width = 150;
  22. $height = round(($y/$x) * $width);
  23.  
  24. $tmpimage = imagecreatetruecolor($width, $height);
  25. imagecopyresampled($tmpimage, $img, 0, 0, 0, 0, $width, $height, $x, $y);
  26. imagedestroy($img);
  27. $img = $tmpimage;
  28.  
  29. if ($type == 'jpg' || $type == 'jpeg') {
  30.     header("Content-type: image/jpeg");
  31.     imagejpeg($img, '', 65);
  32. }
  33. elseif ($type == 'png') {
  34.     header("Content-type: image/png");
  35.     imagetruecolortopalette($img, false, 128);
  36.     imagepng($img);
  37. }
  38. elseif ($type == 'gif') {
  39.     header("Content-type: image/png");
  40.     imagetruecolortopalette($img, false, 128);
  41.     imagepng($img);
  42. }
  43. ?>