ERRORImage Extension Unknown.
"; print "The file you uploaded had the following extension: $pext

\n"; return; } if ($imgfile_size=="0") { print "

ERROR

Filesize too big or file mismatch
"; return; } $new_w=150; $new_h=150; print"

    * original filename           : $imgfile_name
    * size of uploaded file       : $imgfile_size
    * mime-type of uploaded file  : $imgfile_type
    * file extension              : .$pext
    
"; if ($pext==jpeg){ $src_img = imagecreatefromjpeg($imgfile); }elseif ($pext==jpg){ $src_img = imagecreatefromjpeg($imgfile); }elseif ($pext==png){ $src_img = imagecreatefrompng($imgfile); }elseif ($pext==gif){ $src_img = imagecreatefromgif($imgfile); }else{ print"
Something went wrong
"; } $old_x = imageSX($src_img); $old_y = imageSY($src_img); if ($old_x > $old_y) { $thumb_w2 = $new_w; $thumb_h2 = $old_y * ($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w2 = $old_x * ($new_w/$old_y); $thumb_h2 = $new_h; } if ($old_x == $old_y) { $thumb_w2 = $new_w; $thumb_h2 = $new_h; } $thumb_w = $new_w; $thumb_h = $new_h; $dst_img = ImageCreateTrueColor($new_w, $new_h); imagefill($dst_img, 0, 0, 0xffffff); imagecopyresampled($dst_img, $src_img, $new_w/2-$thumb_w2/2, $new_h/2-$thumb_h2/2, 0, 0, $thumb_w2, $thumb_h2, $old_x, $old_y); $gogoname = explode(".",$imgfile_name); $frofroname = $gogoname[0]; $currentcont = getcontestnumber(); $imagenumber = $currentcont; $imagenumber.= "_"; $imagenumber.= $user[id]; $imagethumb = $imagenumber; $imagethumb.= ".thumb.jpg"; $imagename = $imagenumber; $imagename.= "."; $imagename.= $pext; $dstfilename = $uploaddir . $imagethumb; $srcfilename = $uploaddir . $imagename; //imagejpeg($src_img, $srcfilename, 80); if (!copy($imgfile, $srcfilename)) { print "
failed to copy $file...
\n"; }else{ imagejpeg($dst_img, $dstfilename, 80); $entered = mysql_fetch_array(mysql_query("select * from contest_entries where user=$user[id] and contest=$currentcont")); if(!$entered[id]){ mysql_query("INSERT INTO `contest_entries` (`user`,`contest`,`filename`,`thumbnail`) VALUES ('$user[id]','$currentcont','$srcfilename','$dstfilename')") or die("
Could not register."); }else{ mysql_query("update contest_entries set `filename`='$srcfilename' where id=$entered[id]"); mysql_query("update contest_entries set `thumbnail`='$dstfilename' where id=$entered[id]"); } } print"
»
"; imagedestroy($dst_img); imagedestroy($src_img); } ?>