View file WP-wap/img.php

File size: 1.02Kb
<?
 
if(!function_exists('getimagesize')) exit;

$imgType = "";
$imgURL = urldecode($_GET['imgsrc']);

if(strpos($imgURL, "http") != 0) exit;

$size = @getimagesize($imgURL);

if($size !== FALSE){
	$imgType = $size['mime'];
} else {
	exit;
}
header("Content-Type: ".$imgType);
$imgExt = str_replace("image/", "", $imgType);

resizeImage($imgURL, $imgExt);


function resizeImage($sourcefile, $imgExt) {
	$old = null;

	$functionName = "imagecreatefrom".$imgExt;
	if(!function_exists($functionName)) return null;

	$old = $functionName($sourcefile);

	$old_w = imagesx($old);
	$old_h = imagesy($old);

	$forcedwidth = $old_w/2;
	if($old_w > 176) {
	 $forcedwidth = $old_w/4;
	}

	if ($forcedwidth == 0) $forcedwidth = 1;
	$k = $old_w / $forcedwidth;
	if ($k < 1) $k = $forcedwidth / $old_w;
	$forceheight = $old_h / $k;
	$newi = imagecreatetruecolor($forcedwidth, $forceheight);
	imagecopyresampled($newi, $old, 0, 0, 0, 0, $forcedwidth, $forceheight, $old_w, $old_h);
	return imagegif($newi);
}

?>