0) && ($srcheight > 0) && (($srcwidth > $max_width) || ($srcheight > $max_height)) ) { $srcaspect=$srcwidth / $srcheight; $maxaspect=$max_width / $max_height; if($srcaspect > $maxaspect) { # limit by width: $destwidth=$max_width; $destheight=$destwidth / $srcaspect; } else { # limit by height: $destheight=$max_height; $destwidth=$destheight * $srcaspect; } $destimg=imagecreatetruecolor($destwidth,$destheight); imagecopyresampled($destimg, $srcimg, 0, 0, 0, 0, $destwidth, $destheight, $srcwidth, $srcheight); } else { $destimg=$srcimg; } imagejpeg($destimg,$scaledfile,$quality); } # fetch a POST or GET variabele, removing possible slashes # $forcenumber=true? Then interpret the value as an integer function fetchVar($varname, $forcenumber) { if (isset($_POST[$varname])) { $value = $_POST[$varname]; } elseif (isset($_GET[$varname])) { $value = $_GET[$varname]; } if (isset($value)) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } if ($forcenumber) { $value=intval($value); } } return $value; } ?>