All pastes #101626 Raw Edit

Erm

public php v1 · immutable
#101626 ·published 2006-07-27 00:58 UTC
rendered paste body
<?php	include_once 'config.php';	include_once 'inc/db.inc.php';	if (!isset($_GET['pid']) || !is_numeric($_GET['pid'])) {		//		exit;	}	$query = "SELECT * FROM pics WHERE pid = '{$_GET['pid']}'";	$result = mysql_query ($query) or die(mysql_error().'<br>');	if (!$result) {		die("Missing pic.");	}	$pic = mysql_fetch_assoc($result);	$pic_ext = array('jpg', 'jpeg', 'png', 'gif');	$video_ext = array('mov', 'avi', 'mpg', 'mpeg');	if (!isset($_GET['w']) || !isset ($_GET['h']) || !is_numeric($_GET['w']) || !is_numeric($_GET['h'])) {		if (!isset($_GET['t']) || !is_numeric($_GET['t'])) {			$_GET['t'] = 100;		}		$size = prop_resize($pic['width'], $pic['height'], $_GET['t'], true);		$_GET['w'] = $size['w'];		$_GET['h'] = $size['h'];	}	if (!in_array($pic['ext'],$pic_ext) && !in_array($pic['ext'],$video_ext)) {		die("unsupported extension");	}	if (file_exists($pic['fullname'].'_'.$_GET['w'].'.thmb')) {		header('Content-type: '. $pic['mime']);		readfile($pic['fullname'].'_'.$_GET['w'].'.thmb');		exit;	}	switch($pic['mime']) {		case 'image/jpeg':			$source = @imagecreatefromjpeg ($pic['fullname']);			//imagejpeg($im);			break;		case 'image/gif':			/*			if (isset($_GET['display'])) {				echo file_get_contents($pic['fullname']);				exit;			}*/			//gifsicle --resize-width 200 mil_bug.gif > mil_bug.gif.thmb.gif			exec ('gifsicle --resize-width '.$_GET['w'].' '. escapeshellarg($pic['fullname']) . ' > '.escapeshellarg($pic['fullname'].'_'.$_GET['w'].'.thmb'));			if (file_exists($pic['fullname'].'_'.$_GET['w'].'.thmb')) {				readfile ($pic['fullname'].'_'.$_GET['w'].'.thmb');				exit;			}			$source = @imagecreatefromgif ($pic['fullname']);			//imagegif($im);			break;		case 'image/png':			$source = @imagecreatefrompng ($pic['fullname']);			//imagepng($im);			break;		case 'FFF6 0xFFF0 audio/X-HX-AAC-ADTS':		case 'fff6 0xfff0 audio/x-hx-aac-adts':		case 'FFF6    0xFFF0          audio/X-HX-AAC-ADTS':			//mplayer -frames 1 -nosound -vo jpeg:outdir=test  quality=100 '071305HalleSquealing.mov' -brightness 25 -contrast 10			if (!file_exists($pic['fullname'].'.vthmb')) {				$rnd = rand();				mkdir($rnd);				$exec = "mplayer -frames 1 -nosound -vo jpeg:outdir=$rnd:quality=100 ".escapeshellarg($pic['fullname']).' -brightness 25 -contrast 10';				//echo $exec.'<br>';				exec ($exec);				if (copy ($rnd.'/00000001.jpg',$pic['fullname'].'.vthmb')) {					//echo "ok";					unlink($rnd.'/00000001.jpg');					rmdir($rnd);				}			}			list($pic['width'], $pic['height']) = getimagesize($pic['fullname'].'.vthmb');			$pic['mime'] = 'image/jpeg';			$pic['fullname'] = $pic['fullname'].'.vthmb';			//header('Content-type: image/jpeg');			//echo file_get_contents($pic['fullname'].'.vthmb');			$source = imagecreatefromjpeg ($pic['fullname']);			break;		default:			break;	}	/* if (file_exists($pic['fullname'].'.thmb') && isset($_GET['thmb'])) {		header('Content-type: '. $pic['mime']);		echo file_get_contents($pic['fullname'].'.thmb');		exit;	} */	//echo $pic['ext'];	$thumb = imagecreatetruecolor($_GET['w'], $_GET['h']);	//$bgc = imagecolorallocate ($source, 255, 255, 255);	@imagecopyresampled($thumb, $source, 0, 0, 0, 0, $_GET['w'], $_GET['h'], $pic['width'], $pic['height']);	header('Content-type: '. $pic['mime']);	switch($pic['mime']) {		case 'image/jpeg':			imagejpeg($thumb,$pic['fullname'].'_'.$_GET['w'].'.thmb', 100);			imagejpeg($thumb, null, 100);			//imagejpeg($im);			break;		case 'image/gif':			imagegif($thumb, $pic['fullname'].'_'.$_GET['w'].'.thmb', 100);			imagegif($thumb, null, 100);			//imagegif($im);			break;		case 'image/png':			imagepng($thumb, $pic['fullname'].'_'.$_GET['w'].'.thmb', 100);			imagepng($thumb, null, 100);			//imagepng($im);			break;		default:			break;	}?>