<?PHP
ini_set("memory_limit","75M");
include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");
$query = "SELECT * FROM $DB_Photos WHERE id='$photoid'";
$result = mysql_query($query, $Link) or queryError("11", mysql_error());
$ROW = mysql_fetch_object($result);
// Figure out if fullsize or scaled should be used
if(($full == 1) AND ($ROW->fullsize))
$filelocation = $sxContentDir['PhotoFullsize'].$ROW->filename;
else
$filelocation = $sxContentDir['PhotoScaled'].$ROW->filename;
$sxImageInfo = @getimagesize($filelocation);
// Failure to get fullsize file
if( ($ROW->fullsize == 1) AND (!$sxImageInfo) )
{
// Fix db
$query = "UPDATE $DB_Photos SET fullsize='0' WHERE id='$photoid'";
$result = mysql_query($query, $Link) or queryError("12", mysql_error());
// Change file vars
$filelocation = $sxContentDir['PhotoScaled'].$ROW->filename;
$sxImageInfo = getimagesize($filelocation);
}
$sxImageWidth = $sxImageInfo[0];
$sxImageHeight = $sxImageInfo[1];
switch($sxImageInfo[2])
{
case 1: $image = imagecreatefromgif($filelocation); break;
case 2: $image = imagecreatefromjpeg($filelocation); break;
case 3: $image = imagecreatefrompng($filelocation); break;
case 6: $image = imagecreatefromwbmp($filelocation); break;
}
if(imageCompatibility() == "truecolor")
{
$image_new = imagecreatetruecolor($width, $height);
imagecopyresampled($image_new, $image, 0, 0, 0, 0, $width, $height, $sxImageWidth, $sxImageHeight);
}
elseif(imageCompatibility() == "normal")
{
$image_new = imagecreate($width, $height);
imagecopyresized($image_new, $image, 0, 0, 0, 0, $width, $height, $sxImageWidth, $sxImageHeight);
}
else
die($sxLang['PhotoUnsupportedEngine']);
switch($sxImageInfo[2])
{
case 1: header ("Content-Type: image/gif"); break;
case 2: header ("Content-Type: image/jpeg"); break;
case 3: header ("Content-Type: image/png"); break;
case 6: header ("Content-Type: image/bmp"); break;
}
header ("Content-Disposition: inline");
// Watermark on the fly
if($sxSetup['GalleryWatermarking'] > 0)
$image_new = sxWatermarkImage($image_new,$width,$height);
switch($sxImageInfo[2])
{
case 1: imagegif($image_new); break;
case 2: imagejpeg($image_new, '', $compression); break;
case 3: imagepng($image_new); break;
case 6: imagewbmp($image_new); break;
}
imagedestroy($image_new);
imagedestroy($image);
?>