Categories > TinyButStrong general >

Header Issue

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Jeff Hardy
Date: 2005-02-19
Time: 22:19

Header Issue

I have this code:

template:
<tr>
<td valign="top"><strong>Código de Segurança:<strong></td>
<td><img src="[onshow;script=../includes/image.inc.php;getob]"></td>
</tr>

image.inc.php:

<?php

# Gera uma hash e tranforma em imagem, serve para impedir que haja
# gente a carregar no submit mais que uma vez.
include_once("sessao.inc.php");
include_once("password.inc.php");
$pass = passwd(4);
session_register("sessao_registo");
$sessao_registo = $pass;
header ("Content-type: image/png");
$im = imagecreate (40, 20);
$fundo = ImageColorAllocate ($im, 214, 228, 244);
$riscas = ImageColorAllocate ($im, 148, 185, 226);
$letras = ImageColorAllocate ($im, 0, 0, 0);
$BASimgcolor_grey = imagecolorallocate($im, 200, 200, 200);

$num1arcs = ($im + 3) ;
for ($i=1; $i<=$num1arcs; $i++) {
    imagearc($im, -15+$i*30+rand(-20,20), 40+rand(-20,20), 96+rand(-20,20), 96+rand(-20,20), 0, 360, $riscas);
    }
$num2arcs = ($BASnumimgchars + 3);
for ($i=1; $i<=$num2arcs; $i++) {
    imagearc($im, -15+$i*30+rand(-20,20), 40+rand(-20,20), 96+rand(-20,20), 96+rand(-20,20), 0, 360, $BASimgcolor_grey);
    }

ImageTTFText ($im, 10, 0, 5, 15, $letras, "verdana.ttf", $pass);
ImagePNG($im);

?>

I'm getting a broken image instead of the full page .. i think the problem is with that - header ("Content-type: image/png"); -

Without tinybutstrong i make a <? include "../images/image.inc.php"; ?> and it works fine.

Any idea?
Thanks ;)
By: Pirjo Posio
Date: 2005-02-20
Time: 07:20

Re: Header Issue

Hi Jeff,

I think it's a problem of path. You have in your template
<img src="[onshow;script=../includes/image.inc.php;getob]">
and in your include-version <? include "../images/image.inc.php"; ?>

- Pirjo
By: Jeff Hardy
Date: 2005-02-20
Time: 10:24

Re: Header Issue

Hi Pirjo, the path problem it was me when i wrote the post.
In my include-version i have
<? include "../includes/image.inc.php"; ?>

Thanks for your reply
By: Skrol29
Date: 2005-02-20
Time: 15:07

Re: Header Issue

Hello Jeff,

It seems that you're trying to put the binary contents of the image instead of the SRC link in the Html page. This is not valid. The SRC attibute accepts only URL.

It should be:
<img src="../includes/image.inc.php">

The header() call was not good too, because it would be applied to the Html page generated by the template instead of the image itself. But this is not the major problem.
By: Jeff Hardy
Date: 2005-02-20
Time: 17:22

Re: Header Issue

Thank you Skrol29, it worked ;)