PDA

View Full Version : Broken siggy images


Dinocanid
06-30-2017, 04:16 PM
I read this thread (http://www.mysidiaadoptables.com/forum/showthread.php?t=5279&highlight=siggy) 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:
http://adopttest.mysidiahost.com/levelup/siggy/2107 (http://adopttest.mysidiahost.com/levelup/click/2107)
(forum)
http://adopttest.mysidiahost.com/get/2107.gif (http://adopttest.mysidiahost.com/levelup/click/2107)
(alternate)

This is what my code looks like:
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 = "{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()} ({$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()})";
$forumArea = new TextArea("forumcode", $forumcode, 4, 50);
$forumArea->setReadOnly(TRUE);

$altComment = new Comment("Alternative BBCode: ");
$altComment->setUnderlined();
$altcode = "{$mysidia->path->getAbsolute()}get/{$adopt->getAdoptID()}.gif ({$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()})";
$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)
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)

Abronsyth
06-30-2017, 10:15 PM
That's curious, I compared it to mine/from my site and though they are being generated in the same format, mine is working.

So comparing my levelup.php to yours, I do see distinct differences in the siggy function. Majorly in that you have this chunk here...which does not exist at all in mine:
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);

}

Aside from that everything else is the same...so maybe something to do with that? :catfish:

Dinocanid
06-30-2017, 10:18 PM
That's the png image mod, I added it recently to see if it would fix the problem; it didn't though :hmmm:

Abronsyth
06-30-2017, 11:07 PM
Okay, I just found the tiniest discrepancy that makes a big difference!!

In your myadoptsview file find this line;
$altcode = "{$mysidia->path->getAbsolute()}get/{$adopt->getAdoptID()}.gif ({$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()})";

Replace it with this:
$altcode = "{$mysidia->path->getAbsolute()}get/{$adopt->getAdoptID()}.gif\" ({$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()})";

Let me know if that works :BIGO:

Dinocanid
06-30-2017, 11:12 PM
That didn't work either.

Abronsyth
06-30-2017, 11:16 PM
Huh, those were the only two differences I could find. I'll try replacing my functions with yours and see if it breaks my images, if not then chances are it is an issue in another file.

Edit: Oh, and do you have a closing bracket for the bbcode function for myadoptsview.php? It's not included in what you pasted, but I assumed you just didn't paste it.

Dinocanid
06-30-2017, 11:24 PM
Yeah it's there, I just didn't paste it. I can't think of another file that would be causing it, unless bbcodes are handled elsewhere too.

Abronsyth
07-01-2017, 10:07 AM
Okay, so I tested your script with my site, both each individually (only the levelup, only the myadoptsview) and together, but my images work in each case.

Now when I take my ../levelup/siggy/{$aid} and put it in my URL bar it shows me the image. However, when I take yours;
http://adopttest.mysidiahost.com/levelup/siggy/2107

I get this mess...
Warning: Cannot modify header information - headers already sent by (output started at /home/adopttes/public_html/levelup.php:34) in /home/adopttes/public_html/levelup.php on line 197
GIF89a���T�L��t,B$l�d�����Db$t�td�\$64N,T~LT�T ��|,F,��Č�|�Ƅ|�t DnD��|�ޔl�\d�\d�\4F,t�l��� ��424��|��l�d���t�l&�֌4V4���l�d|�t�֜  ��.�΄$>$���t�l��TvLl�lT�T��|,B,DbDLrL\�\���l�lDjD,d�d$6$4 N4T~T����ƌ|�|���l�dd�d4F4���  ��!��,���� H���� �"Å*A" ���ŋ3j�ȱ�Ǐ Cfl�pP d.���dƅ G��I��$C�$Ȇ� $H"� J��ѣ1��� �? �5�Úp z ���P W�W�<�� �I�l0�8 �@Xܴel�XV�Z�h i$��&�P ���I���lH� ��p30d�� z!�5@�h��*Y , �! 2� ����4P �� P� �F}>���$��pl�6i��.�lZ �kP\�`sa&c�ve& DHzϰ��8 �(�P �p�Y ��<і zְl����M�����e�bi4P .0���_Q�y���i2&���idw�x��g�)��i�Y�j�#���� ���pS�R�yoxQ���Y��f�Z��Vp��v�P�ވs��p�U�}pGz� G����8�I�bpbp�f����p@�ח ��g��9���>�X� �af3f��) d 0z�yz���X�!���� �8��Ԡ�1! @ڍ`� �p}H� ꡗ����QP\�'�``�3 c��}�I���G�/z�����I�6��7ʠ<��dP��ЀB:��G�_����XQ�?H�tЀbv���y�I��\��j`�{�� 0:Вez�6�7�L�,k�)� P�3�q �8��u��X�B�k�P���w�xX����pzz��������0�5z��*�P�� ٶ�;�,�� 4V�� ��r #J�@J�Xj�e�voG������.�9�ә�������_�,����� I���� %� W�#:���t��3Pm�� ��v�X�t�Ι��������j��:�P�� j#jJ�3G� z�y9����Tm:p :@p��������+Z�zЊ����p����:� � ��8 ��*����&� �� `` Ơ-��вZۑ@f��iXkm�����+� ;�� ���� ���W0�b�g��N� 8�b�;*���C� P0�00A �Y ������v�����(w�(z��0�$i�?� ��P +9-ْ�P�&� �`���6j����?�sʐ�����������}o[zz�8��7H�&�z5�f��ΰ�� ��Wp`�k��{���ͅ ū�6����K�� q����1q?�����f0 =��.���+��;����� �K����Ú�2� �0 s����r7w_��G�<��k��51�{�d��̱N����� �@� _� ;`��2��.���(~H���I�G���{��p7ڱ:�������ڦ. @�; >p�� �:�A��I�� �*i�E���Z�Ȁ�hʴ]��_|�=,�7��#i #�>�ƶ��5��I� L�Kxɰ��Ы5l�z���M �Pq�b ,�K������0a��p �l ��������)) � �,i�fz���\ʖz�8Ka�ʜ � -az ˛P5� A����5`� <��H��ɗ�����*��˖� �S�#�!)���1�e �+ٙ���[ß|�˴O��_��Ê���/�,�? :6CP�9��۫-��i����5���J�����|�_�@-�� &�� ����!P��|�O�΀�Ģ���.}#<��0,!�7�����Z��]��슸��6B�E�#!�N�ԁ��;}��Ã¥촖�˼Å*&�]=:L��\�3 ��<����P��,�R�+M\=�s&�B�zz�6z�;�%m��k�P� -��9��, m��m�8��J�M,��n�ٞ�ى�ʲ#6�l�5�_���6� �ٰ�Q����k�)���q���m�-������]��}�؝�ڽ����������=��]��}��������������=��]��}�������������� �@�>� ��>��������� ��n�� �� �������P�>�^^��!�����4N�.��&�s��,��/��3��~���.�B��J�I��>~�����R>�V�F~�+nT��K����.�HN�]>�)^Yn�N��h^�U��[� a��pN�Aq��_��k>w~���>N�"��%. 5��u~�X���ㇾ�5��A�b^�[n�n�D��in� ��~�蜞�~�xnߡ������8��*�鷑��z�>�^� �붞�s�뎮3�>t���1.�9�>�P����.�I�0��ޖ�.�^�G��E^�x�J��n��M~�����z.�l���n �~�.��^������Z��YN�Ǯ��~��N�.���������������� ���_���h������)��N������ �����2Y�|�P�~�^�A� _�;������� ��K�N���=�~�^��n)#o��W��Z����o���n��o�N揞# �.�a��h�B��R��N�Ӯ�<��^_�E/㢮�@��zO����1��O�i� ���i魞��陏�ڮ�_�%�l���?� 2�����+��&��f����|�$�������7�����v����������r�>��o��������?�ۮ��n������������A�n����a��n�)?��O ��������/�Ȓ���h��m� $�p�B� L����#R���ĉ3n���F�$G"d���D�'?��S�L�5m�ęS�N�=}�T�P�E�E�T�R�M�>�U�T�U�^ŚU�V�]��L�4�ñ^͞���ҍ/��| 4.Z��;
Warning: imagedestroy(): 108 is not a valid Image resource in /home/adopttes/public_html/levelup.php on line 200

Fatal error: Uncaught exception 'GUIException' with message 'This document has no title yet.' in /home/adopttes/public_html/classes/class_document.php:52 Stack trace: #0 /home/adopttes/public_html/classes/class_frame.php(217): Document->getTitle() #1 /home/adopttes/public_html/classes/class_template.php(161): Frame->render() #2 /home/adopttes/public_html/classes/class_view.php(279): Template->render() #3 /home/adopttes/public_html/classes/class_frontcontroller.php(102): View->render() #4 /home/adopttes/public_html/index.php(75): FrontController->render() #5 /home/adopttes/public_html/index.php(79): IndexController::main() #6 {main} thrown in /home/adopttes/public_html/classes/class_document.php on line 52

It's complaining an awful lot in there.

It would seem like it is finding an error somewhere in the levelup file, but as I said it worked for me just fine so I would imagine it is running into trouble either outside of the siggy function in the levelup file, or in a different file altogether.

Dinocanid
07-01-2017, 12:32 PM
Ok so I replaced my entire levelup file with a fresh one and the forum codes seem to be working now (alternate code still looks broken though, does this board allow it?)
I'll update if I find out what broke it when I add back my changes one at a time.
EDIT: Ok so here I was using style tags inside the file :ti: That seemed to be the problem.

Hall of Famer
07-06-2017, 09:20 AM
So your issue is resolved?

Dinocanid
07-06-2017, 10:56 AM
Yes, it's fixed now.