| 
				 Broken siggy images 
 
			
			I read this thread  again, but it didn't seem to fix it. Neither of the BBcodes for my pets seem to be working, and it just gives a broken image:
  
(forum)
  
(alternate)
 
This is what my code looks like:
 
	PHP Code: 
		
			
public function bbcode(){ 
$mysidia = Registry::get("mysidia");
 $adopt = $this->getField("adopt");
 $document = $this->document;
 $document->setTitle($this->lang->bbcode.$adopt->getName());
 $document->addLangvar($this->lang->bbcode_info);
 $document->add(new Comment("<br>"));
 
 $forumComment = new Comment("Forum BBCode: ");
 $forumComment->setUnderlined();
 $forumcode = "[url={$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}][img]{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()}[/img][/url]";
 $forumArea = new TextArea("forumcode", $forumcode, 4, 50);
 $forumArea->setReadOnly(TRUE);
 
 $altComment = new Comment("Alternative BBCode: ");
 $altComment->setUnderlined();
 $altcode = "[url={$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}][img]{$mysidia->path->getAbsolute()}get/{$adopt->getAdoptID()}.gif[/img][/url]";
 $altArea = new TextArea("altcode", $altcode, 4, 50);
 $altArea->setReadOnly(TRUE);
 
 $htmlComment = new Comment("HTML BBCode: ");
 $htmlComment->setUnderlined();
 $htmlcode = "<a href='{$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}' target='_blank'>
 <img src='{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()}' border=0></a>";
 $htmlArea = new TextArea("htmlcode", $htmlcode, 4, 50);
 $htmlArea->setReadOnly(TRUE);
 
 $document->add($forumComment);
 $document->add($forumArea);
 $document->add($altComment);
 $document->add(($mysidia->settings->usealtbbcode == "yes")?$altArea:new Comment("The Admin has disabled Alt BBCode for this site."));
 $document->add($htmlComment);
 $document->add($htmlArea);
 
 (myadoptsview)
 
	PHP Code: 
		
			
public function siggy(){
$mysidia = Registry::get("mysidia");
 // The adoptable is available, let's collect its info
 $usingimage = "no";
 $image = $this->adopt->getImage();
 
 $usegd = $mysidia->settings->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
 $type = $this->adopt->getType();
 list($width, $height, $type, $attr) = getimagesize($image); // The size of the original adoptable image
 
 // Lets create the new target image, with a size big enough for the text for the adoptable
 $newheight = $height + 72;
 $newwidth = ($newwidth < 250)?250:$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
 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);
 
 // Build text for siggy
 $str1 = "Name: ".$this->adopt->getName();
 $str2 = "Owner: ".$this->adopt->getOwner();
 $str3 = "Click Here to Feed Me!";
 $str4 = "More Adopts at:";
 $str5 = "www.".constant("DOMAIN");
 
 // Renger Image
 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);
 
 // At the very last, let's clean up temporary files
 header("Content-Type: image/GIF");
 ImageGif ($image);
 imagedestroy($image);
 imagedestroy($img_temp);
 imagedestroy($img_old);
 imagedestroy($bgi);
 
 }
 elseif(function_exists('imagepng') and $usegd == "yes" and $imagemime == "image/png"){
 $usingimage = "yes"; //Turn the template system off
 $type = $this->adopt->getType();
 list($width, $height, $type, $attr) = getimagesize($image); // The size of the original adoptable image
 
 // Lets create the new target image, with a size big enough for the text for the adoptable
 $newheight = $height + 72;
 $newwidth = ($newwidth < 250)?250:$width;
 $img_temp = imagecreatetruecolor($newwidth, $newheight);
 $alphablending = true;
 
 // Lets create the image and save its transparency
 $img_old = @imagecreatefrompng($image);
 imagealphablending($img_old, true);
 imagesavealpha($img_old, true);
 
 // Lets copy the old image into the new image with
 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);
 
 // Build text for siggy
 $str1 = "Name: ".$this->adopt->getName();
 $str2 = "Owner: ".$this->adopt->getOwner();
 $str3 = "Click Here to Feed Me!";
 $str4 = "More Adopts at:";
 $str5 = "www.".constant("DOMAIN");
 
 // Renger Image
 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);
 
 // At the very last, let's clean up temporary files
 header("Content-Type: image/PNG");
 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...
 $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"){
 throw new InvalidIDException("The file Extension is not allowed!");
 }
 else{
 // File type is allowed, so proceed
 $status = "";
 header($contentType);
 $curl = new Curl($image);
 $curl->setHeader();
 $curl->exec();
 $curl->close();
 }
 }
 }
 
 (levelup)
		 |