$value) $$key = addslashes($value); foreach ($_GET as $key => $value) $$key = addslashes($value); //print stripslashes('< img src = '. $_GET['fromfile'] . '>'); //$dossier = $_GET['do']; function ErrorPNG($err) { $im = @imagecreate(100, 30); /* Create a blank image */ $bgc = @imagecolorallocate($im, 255, 255, 255); $tc = @imagecolorallocate($im, 0, 0, 0); @imagefilledrectangle($im, 0, 0, 100, 30, $bgc); /* Output an errmsg */ @imagestring($im, 1, 5, 5, $err, $tc); return $im; } // control parameters and file existence if(!isset($_GET['fromfile'])) { header("Content-type: image/png"); echo @imagepng(@ErrorPNG("params empty")); exit; } elseif (!file_exists($_GET['fromfile'])) { header("Content-type: image/png"); echo @imagepng(@ErrorPNG("img doesn't exist")); exit; } // try to see if it already exists a cached thumbnail if(function_exists('imagetypes')) { if(file_exists($dossier.md5($_SERVER["QUERY_STRING"]))) { $img=@getimagesize($dossier.md5($_SERVER["QUERY_STRING"])); /* set the cache limiter to 'private' */ session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); /* set the cache expire to 60 minutes */ session_cache_expire(60); $cache_expire = session_cache_expire(); header("Content-type: ".$img['mime']); echo join('',@file($dossier.md5($_SERVER["QUERY_STRING"]))); exit; } elseif(!@is_dir($dossier)) mkdir($dossier,0777);//41 if(!isset($_GET['w'])) $w=100; // setting thumbnail width if missing $img=@getimagesize("./".$fromfile); // getting image data if(is_array($img)) { switch($img[2]) { case 1 : if(!(imagetypes() & IMG_GIF)) { if(!function_exists("imagecreatefromgif")) $nomanage=true; // gif is only readable in recent GD else { $outype="png"; // so the thumb will be in png format $img['mime']="image/png"; } } else $outype="gif"; $imtype="gif"; break; case 2 : if(!(imagetypes() & IMG_JPG)) $nomanage=true; $outype="jpeg"; $imtype="jpeg"; break; case 3 : if(!(imagetypes() & IMG_PNG)) $nomanage=true; $imtype="png"; $outype="png"; break; default : header("Content-type: image/png"); // image format not supported echo imagepng(ErrorPNG("wrong img type")); // by phpauction exit; } $ratio=floatval($img[0]/$w); // calculate proportional ratio $h=ceil($img[1]/$ratio); // proportional height } else { header("Content-type: image/png"); // image is not a recognizable format echo imagepng(ErrorPNG("not image type")); exit; } } else { $nomanage=true; $img=@getimagesize("./".$fromfile); // getting image data } if($nomanage) { header("Content-type: ".$img['mime']); // type not manageable echo join('',@file($fromfile)); // render back the entire image requested exit; } /* set the cache limiter to 'private' */ session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); /* set the cache expire to 60 minutes */ session_cache_expire(60); $cache_expire = session_cache_expire(); $ou = @imagecreatetruecolor($w,$h); // create empty truecolor image $funcall="imagecreatefrom$imtype"; // compose input function name @imagecopyresampled($ou,@$funcall("./".$fromfile), 0,0,0,0,$w,$h,$img[0],$img[1]); // resample a thumbnail $funcall="image$outype"; // compose output function name @$funcall($ou,$dossier.md5($_SERVER["QUERY_STRING"])); // write in output header("Content-type: ".$img['mime']); // header @$funcall($ou); // write in output ?>