Code:
<?php
include("inc/functions.php");
//***************//
// START SCRIPT //
//***************//
// We need to grab an adoptable ID
$id = $_GET["id"];
// Check that ID exists and is valid
if(is_numeric($id)){
// The ID appears to be valid, so double check...
$result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$id'") ;
$row = mysql_fetch_array($result);
if($row['aid'] == $id){
// The adoptable exists, so let's try and show the image
$usingimage = "no";
$image = getcurrentimage($id);
// Let's see if the server has support for GD or not
// Also to use fancy images the image must be a gif and fancy images must be enabled...
$usegd = grabanysetting("gdimages");
$imageinfo = @getimagesize($image);
$imagemime = $imageinfo["mime"]; // Mime type of the image file, should be a .gif file...
if(function_exists('imagegif') and $usegd == "yes" and $imagemime == "image/gif")
{
$usingimage = "yes"; //Turn the template system off
// BEGIN NEW CODE
list($width, $height, $row['type'], $attr) = getimagesize($image); // The size of the original adoptable image
// Begin the fancy outputs...
// Lets create the new target image, with a size big enough for the text for the adoptable
$newheight = $height + 72;
if($newwidth < 250){
$newwidth = 250;
}
else{
$newwidth = $width;
}
$img_temp = imagecreatetruecolor($newwidth, $newheight);
$alphablending = true;
// Lets create the image and save its transparency
$img_old = @imagecreatefromgif($image);
imagealphablending($img_old, true);
imagesavealpha($img_old, true);
// Lets copy the old image into the new image with
// the given size
ImageCopyResampled(
$img_temp,
$img_old,
0, 0, 0, 0,
$width,
$height,
$width,
$height
);
$textheight = $width + 2;
$image = $img_temp;
$bgi = imagecreatetruecolor($newwidth, $newheight);
$color = imagecolorallocate($bgi, 51, 51, 51);
$str1 = "Name: ".$row['name'];
$str2 = "Owner: ".$row['owner'];
$str3 = "Click Here to Feed Me!";
$str4 = "More Adopts at:";
$str5 = "www.".$domain;
imagestring ($image, 12, 0, $textheight, $str1, $color);
imagestring ($image, 12, 0, $textheight + 13, $str2, $color);
imagestring ($image, 12, 0, $textheight + 26, $str3, $color);
imagestring ($image, 12, 0, $textheight + 42, $str4, $color);
imagestring ($image, 12, 0, $textheight + 55, $str5, $color);
$background = imagecolorallocate($image, 0, 0, 0);
ImageColorTransparent($image, $background);
header("Content-Type: image/GIF");
ImageGif ($image);
imagedestroy($image);
imagedestroy($img_temp);
imagedestroy($img_old);
imagedestroy($bgi);
}
else{
// We are going to try and get this image the old fashioned way...
// Define a list of allowed file extentions...
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';
//Define the output file type
$contentType = 'Content-type: '.$extList[ $imageinfo['extension'] ];
if($imageinfo['extension'] =! "image/gif" and $imageinfo['extension'] =! "image/jpeg" and $imageinfo['extension'] =! "image/png"){
// The file type is NOT ALLOWED
die("Hacking Attempt!");
}
else{
// File type is allowed, so proceed
// Try and read the file in
$status = "";
header ($contentType);
$status = readfile($image);
if($status == "" or $status == "false" or $status == "FALSE"){
// Reading the file failed, so show an error...
header ("text/plain");
die("Readfile appears to be disabled on your host.");
}
}
}
}
else{
// Bogus ID
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
// Bogus ID
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
?>
Thank you so much for all your help on this... ;-; I suck so much at coding.