All pastes #614963 Raw Edit

Unnamed

public php v1 · immutable
#614963 ·published 2007-07-11 21:30 UTC
rendered paste body
$photo_location = "img/";	$photo_category = $_POST['gallery'];		$unsorted = scandir($photo_location);		$upload_filename = $_FILES['uploadedfile']['name'];		function createthumb($name,$filename,$new_w,$new_h){		$system=explode('.',$name);		if (preg_match('/jpg|jpeg/',$system[1])){			$src_img=imagecreatefromjpeg($name);		}		if (preg_match('/png/',$system[1])){			$src_img=imagecreatefrompng($name);		}		$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);		imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);		if (preg_match("/png/",$system[1])) {			imagepng($dst_img,$filename); 		}		else {			imagejpeg($dst_img,$filename); 		}		imagedestroy($dst_img); 		imagedestroy($src_img);	}		if (ereg(".jpg",$upload_filename) or ereg(".jpeg",$upload_filename)) {		$uploadExt = ".jpg";	}	elseif (ereg(".png",$upload_filename)) {		$uploadExt = ".png";	}	else {		header( "Location: ?page_name=photo_err");	}    foreach ($unsorted as $filename) {	    if(ereg("thumb",$filename) && ereg($photo_category,$filename)) {		   	$images_list[] .= $filename;	    }    }        $numImgs = count($images_list);        $numImgs++;        $target_path = $photo_location;        $thumbTarget = "img/thumb_";    $target_path = $target_path . $photo_category . "photo" . $numImgs . $uploadExt;        $thumbTarget = $thumbTarget . $photo_category . "photo" . $numImgs . $uploadExt;	if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {		createthumb($target_path, $thumbTarget, 275, 206);		header( 'Location: ?page_name=photo_conf');	}	else {		header( 'Location: ?page_name=photo_err');	}