5){echo "ERROR! Number of allowed photos has been exceeded."; exit;} if($_FILES[images][size][$key] != 0) { copy($_FILES[images][tmp_name][$key], $file); $ext = $_FILES[images][type][$key]; // CHECK FOR GD IMAGE HEADER PROBLEMS checkjpeg($file,LANG_FILE_ERROR); /* THIS DOWNSAMPLES IF THE PHOTO IS TOO LARGE */ $setphotoW = 600; $setphotoH = 435; // GET IMAGE SIZE list($width, $height) = getimagesize($file); // CHECK FOR ORIENTATION AND CHECK IF REDUCTION IS NEEDED // SET REDUCTION AND RATIO IF NEEDED if($width>$height){ if($width > $setphotoW){ $pratio = ($height / $width); $newpwidth = $setphotoW; $newpheight = ($setphotoW * $pratio); } else {$newpwidth = $width; $newpheight = $height;} }else{ if($height > $setphotoH){ $pratio = ($width / $height); $newpheight = $setphotoH; $newpwidth = ($setphotoH * $pratio); } else {$newpwidth = $width; $newpheight = $height;} } // LOAD IMAGE $newimage = imagecreatetruecolor($newpwidth, $newpheight); if($ext=='image/jpg' || $ext=='image/jpeg' || $ext=='image/pjpeg') {$source = imagecreatefromjpeg($file);} if($ext=='image/png') {$source = imagecreatefrompng($file); } if($ext=='image/gif'){$source = imagecreatefromgif($file);} // RESIZE IMAGE fastimagecopyresampled($newimage, $source, 0, 0, 0, 0, $newpwidth, $newpheight, $width, $height, $quality = 3); // OUTPUT RESIZED IMAGE TO FILE if($ext=='image/jpg' || $ext=='image/jpeg' || $ext=='image/pjpeg') {imagejpeg($newimage,$file); } if($ext=='image/png') {imagepng($newimage,$file); } if($ext=='image/gif') {imagegif($newimage,$file); } /* THIS CREATES THE THUMBNAIL FILE */ $setthumbW = 133; $setthumbH = 100; // GET IMAGE SIZE list($width, $height) = getimagesize($file); // CHECK FOR ORIENTATION AND CHECK IF REDUCTION IS NEEDED // SET REDUCTION AND RATIO IF NEEDED if($width>$height){ $tratio = ($height / $width); $newtwidth = $setthumbW; $newtheight = ($setthumbW * $tratio); }else{ $tratio = ($width / $height); $newtheight = $setthumbH; $newtwidth = ($setthumbH * $tratio); } // LOAD IMAGE $newthumb = imagecreatetruecolor($newtwidth, $newtheight); if($ext=='image/jpg' || $ext=='image/jpeg' || $ext=='image/pjpeg') {$source = imagecreatefromjpeg($file); } if($ext=='image/png') {$source = imagecreatefrompng($file); } if($ext=='image/gif') {$source = imagecreatefromgif($file); } // RESIZE IMAGE fastimagecopyresampled($newthumb, $source, 0, 0, 0, 0, $newtwidth, $newtheight, $width, $height, $quality = 1.5); // OUTPUT RESIZED IMAGE TO FILE if($ext=='image/jpg' || $ext=='image/jpeg' || $ext=='image/pjpeg') {imagejpeg($newthumb,$thumb); } if($ext=='image/png') {imagepng($newthumb,$thumb); } if($ext=='image/gif') {imagegif($newthumb,$thumb); } if($_SESSION['seclev']!='1'){$more=" AND owner_id='".smart($owner)."'";} mysql_select_db($dbname,$dbc); $sql="UPDATE listings SET photo".$field." = '".smart($filename)."' WHERE listing_id='".smart($listingid)."'".$more.""; $results=mysql_query($sql)or die(mysql_error()); $field++; while (($photorow['photo'.$field]) != ''){$field++; } } else {header("Location: addphotos.php?listingid=".$listingid."&idx=".$idx."&loc=".$loc."&errno=1"); exit;} } } if($loc=='edit'){header("Location: editad.php?listingid=".$listingid);} else { header("Location: manage.php");} ?>