ERROR : unable to open $file in write mode"; } fwrite($fp,$source); $remove = 1; } else { @$fp = fopen($_REQUEST['url'],"r"); if (!$fp) { header ("Content-type: text/html"); echo "Not an image"; exit(); } else { $file = $_REQUEST['url']; fclose($fp); } } list ($a, $b, $type, $attr) = @getimagesize ($file); if (!$type) { $type = basename ($_REQUEST['url']); $type = preg_split ('/\./',$type); $type = array_pop ($type); } switch ($type) { case '2': if (function_exists("imagecreatefromjpeg")) $img = @imagecreatefromjpeg ($file); else show_plain ($file); break; case '3': if (function_exists("imagecreatefrompng")) $img = @imagecreatefrompng ($file); else show_plain ($file); break; case '1': if (function_exists("imagecreatefromgif")) $img = @imagecreatefromgif ($file); else show_plain ($file); break; case '15': if (function_exists("imagecreatefromwbmp")) $img = @imagecreatefromwbmp ($file); else show_plain ($file); break; case '16': if (function_exists("imagecreatefromxbm")) $img = @imagecreatefromxbm ($file); else show_plain ($file); break; case 'xpm': if (function_exists("imagecreatefromxpm")) $img = @imagecreatefromxpm ($file); else show_plain ($file); break; case 'gd': if (function_exists("imagecreatefromgd")) $img = @imagecreatefromgd ($file); else show_plain ($file); break; case 'gd2': if (function_exists("imagecreatefromgd2")) $img = @imagecreatefromgd2 ($file); else show_plain ($file); break; default: //we are not stupid... header ("Content-type: text/html"); echo "Not an image"; exit(); break; } $width = @imagesx($img); $height = @imagesy($img); $newwidth = $_REQUEST['width']; if (empty($newidth)) $newidth = 50; $newheight = $_REQUEST['height']; if (empty($newheight)) $newheight = round($newwidth * ($height / $width)) ; // php-4.2.x is stupid enough to define on gd only a stub for imagecopyresampled. // So function_exists('imagecopyresampled') will fail. if (!extension_loaded('gd2') and (substr(PHP_OS,0,3) != 'WIN')) loadPhpExtension('gd2'); if (extension_loaded('gd2')) { $thumb = imagecreatetruecolor($newwidth, $newheight); $img = imagecopyresampled($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); } else { $thumb = imagecreate($newwidth, $newheight); $img = imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); } if ($remove == 1) unlink ($file); header ("Content-type: image/png"); imagepng($thumb); function show_plain () { $mime = mime_content_type ($_REQUEST['url']); header ("Content-type: $mime"); readfile($_REQUEST['url']); exit(); } /* $Log: not supported by cvs2svn $ Revision 1.5 2007/01/04 16:44:18 rurban mkdir 0775 Revision 1.4 2005/10/31 17:03:19 rurban fix "r" */ // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: ?>