Hey folks, yet again.
[php]
if ($back == "m") //$back is a value pulled from a db; that works perfectly.
{
$wid = $rowing['width'];
$hei = $rowing['height'];
createthumb("66 0x240background 2.gif", "./user/" . $user . "_back.gif" , $wid, $hei);
$image = imagecreatefrom gif("./user/" . $user . "_back.gif" );
$blue = ImageColorAlloc ate($image, 200, 200, 255); // prepare some blueness
$black = ImageColorAlloc ate($image, 0, 0, 0); // ... and whiteness
$im = ImageCreate(300 , 35);
$black_a = imagecoloralloc ate($im, 0, 0, 0);
$white_a = imagecolortrans parent($im, $black_a);
$white = ImageColorAlloc ate($im, 255, 255, 255);
ImageFill($im, 0, 0, $white_a);
Imagettftext($i m, 15, 0, 10, 30, $white, $font, $user . "'s Shoutbox");
$cur_line_y = 65; // This stores how far down the image the current line will print
$postperpage = 11;
}
elseif ($back == "u")
{
$wid = $rowing['width'];
$hei = $rowing['height'];
// createthumb("./user/".$user."_img.g if", "./user/" . $user . "_backim.gi f", $wid, $hei);
imagecreatefrom gif("./user/" . $user . "_img.gif") ;
$images = imagecreate($wi d, $hei);
$imge = imagecreatefrom gif("./user/" . $user . "_backim.gi f");
imagecopymerge( $images, $imge, 0, 0, 0, 0, $wid, $hei, 20);
imagegif($image s, "./user/" . $user . "_back_trans.gi f");
$image = imagecreatefrom gif("./user/" . $user . "_back_trans.gi f");
$im = ImageCreate(300 , 35);
$black_a = imagecoloralloc ate($im, 0, 0, 0);
$white_a = imagecolortrans parent($im, $black_a);
$white = ImageColorAlloc ate($im, 255, 255, 255);
ImageFill($im, 0, 0, $white_a);
Imagettftext($i m, 15, 0, 10, 30, $white, $font, $user . "'s Shoutbox");
$cur_line_y = 74; // This stores how far down the image the current line will print
$postperpage = 10;
}
$sql = ""; // no need for actuall SQL statement - it works.
$result = mysql_query($sq l) or die("error in sqllls: " . mysql_error());
$cur_line_x = 24; // This stores how far across the image the current line will print
$pagecharwidth = 75; // this is the maximum length of the line before it wraps;
$lineheight = 18; // This is how much to move down to print the next line
$pagelinelimit = 1; // How many of each comment appears per page.
//ImageString($im age, 3, 15, $cur_line_y, trim(stripslash es($wordwrapped[0])), $black);
$numberOfLines = $pagelinelimit;
for ($i = 0; $i < $numberOfLines; $i++)
{
while ($row = mysql_fetch_arr ay($result))
{
$name = "[" . htmlspecialchar s_decode($row['username']) . "] "; //it works - returns username
$font = $row['font']; //it works - renders the colour
$color = $row['color']; //it works - changes the font
$line = htmlspecialchar s_decode($row['comment']); //it works, posts the shout
if ($name == "[] ")
{
$name = "";
$line = $name . $line;
}
else
{
$line = $name . $line;
}
//code for emoticons.
//add shouts to image!
if ($back == "m" )
{
if ($color == "white" || $color == "yellow" || $color == "green" || $color ==
"orange" || $color == "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
elseif ($color != "white" || $color != "yellow" || $color != "green" || $color !=
"orange" || $color != "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, getfont($font),
trim($line));
}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line));
}
}
elseif ($back == "w" )
{
$blac = imagecoloralloc ate($image, 0, 0, 0);
if ($color == "black" || $color == "purple" || $color == "blue" || $color ==
"emerald" || $color == "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
elseif ($color != "black" || $color != "purple" || $color != "blue" || $color !=
"emerald" || $color != "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $blac, getfont($font),
trim($line));
}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line));
}
}
[/php]
Depending on the values of $back, the background of the image changes and the font colours also change. This code works so far.
Problem code
[php]
elseif($back == "u")
{
if ($color == "white" || $color == "yellow" || $color == "green" || $color ==
"orange" || $color == "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}elseif ($color != "black" || $color != "purple" || $color != "blue" || $color !=
"emerald" || $color != "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, getfont($font),
trim($line));
}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line) . " ");
}
}
$cur_line_y += $lineheight;
}
}
[/php]
The problem is that when $back == "u", for the first two comments the colours are normal then after that the older comments turn black; the newest comment is in colour but it also changes the colour of the $im that says "User's Shoutbox", which is created as a seperate image.
I can't, for the life of me, see the problem.. can you?
An example: $back == "u" because it's an uploaded background. The oldest comment was white, then I added the Yellow comment, the white one turned black.
Hope that makes sense; if you need more code, just ask. =)
Sam
[php]
if ($back == "m") //$back is a value pulled from a db; that works perfectly.
{
$wid = $rowing['width'];
$hei = $rowing['height'];
createthumb("66 0x240background 2.gif", "./user/" . $user . "_back.gif" , $wid, $hei);
$image = imagecreatefrom gif("./user/" . $user . "_back.gif" );
$blue = ImageColorAlloc ate($image, 200, 200, 255); // prepare some blueness
$black = ImageColorAlloc ate($image, 0, 0, 0); // ... and whiteness
$im = ImageCreate(300 , 35);
$black_a = imagecoloralloc ate($im, 0, 0, 0);
$white_a = imagecolortrans parent($im, $black_a);
$white = ImageColorAlloc ate($im, 255, 255, 255);
ImageFill($im, 0, 0, $white_a);
Imagettftext($i m, 15, 0, 10, 30, $white, $font, $user . "'s Shoutbox");
$cur_line_y = 65; // This stores how far down the image the current line will print
$postperpage = 11;
}
elseif ($back == "u")
{
$wid = $rowing['width'];
$hei = $rowing['height'];
// createthumb("./user/".$user."_img.g if", "./user/" . $user . "_backim.gi f", $wid, $hei);
imagecreatefrom gif("./user/" . $user . "_img.gif") ;
$images = imagecreate($wi d, $hei);
$imge = imagecreatefrom gif("./user/" . $user . "_backim.gi f");
imagecopymerge( $images, $imge, 0, 0, 0, 0, $wid, $hei, 20);
imagegif($image s, "./user/" . $user . "_back_trans.gi f");
$image = imagecreatefrom gif("./user/" . $user . "_back_trans.gi f");
$im = ImageCreate(300 , 35);
$black_a = imagecoloralloc ate($im, 0, 0, 0);
$white_a = imagecolortrans parent($im, $black_a);
$white = ImageColorAlloc ate($im, 255, 255, 255);
ImageFill($im, 0, 0, $white_a);
Imagettftext($i m, 15, 0, 10, 30, $white, $font, $user . "'s Shoutbox");
$cur_line_y = 74; // This stores how far down the image the current line will print
$postperpage = 10;
}
$sql = ""; // no need for actuall SQL statement - it works.
$result = mysql_query($sq l) or die("error in sqllls: " . mysql_error());
$cur_line_x = 24; // This stores how far across the image the current line will print
$pagecharwidth = 75; // this is the maximum length of the line before it wraps;
$lineheight = 18; // This is how much to move down to print the next line
$pagelinelimit = 1; // How many of each comment appears per page.
//ImageString($im age, 3, 15, $cur_line_y, trim(stripslash es($wordwrapped[0])), $black);
$numberOfLines = $pagelinelimit;
for ($i = 0; $i < $numberOfLines; $i++)
{
while ($row = mysql_fetch_arr ay($result))
{
$name = "[" . htmlspecialchar s_decode($row['username']) . "] "; //it works - returns username
$font = $row['font']; //it works - renders the colour
$color = $row['color']; //it works - changes the font
$line = htmlspecialchar s_decode($row['comment']); //it works, posts the shout
if ($name == "[] ")
{
$name = "";
$line = $name . $line;
}
else
{
$line = $name . $line;
}
//code for emoticons.
//add shouts to image!
if ($back == "m" )
{
if ($color == "white" || $color == "yellow" || $color == "green" || $color ==
"orange" || $color == "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
elseif ($color != "white" || $color != "yellow" || $color != "green" || $color !=
"orange" || $color != "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, getfont($font),
trim($line));
}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line));
}
}
elseif ($back == "w" )
{
$blac = imagecoloralloc ate($image, 0, 0, 0);
if ($color == "black" || $color == "purple" || $color == "blue" || $color ==
"emerald" || $color == "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
elseif ($color != "black" || $color != "purple" || $color != "blue" || $color !=
"emerald" || $color != "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $blac, getfont($font),
trim($line));
}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line));
}
}
[/php]
Depending on the values of $back, the background of the image changes and the font colours also change. This code works so far.
Problem code
[php]
elseif($back == "u")
{
if ($color == "white" || $color == "yellow" || $color == "green" || $color ==
"orange" || $color == "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}elseif ($color != "black" || $color != "purple" || $color != "blue" || $color !=
"emerald" || $color != "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, getfont($font),
trim($line));
}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));
}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line) . " ");
}
}
$cur_line_y += $lineheight;
}
}
[/php]
The problem is that when $back == "u", for the first two comments the colours are normal then after that the older comments turn black; the newest comment is in colour but it also changes the colour of the $im that says "User's Shoutbox", which is created as a seperate image.
I can't, for the life of me, see the problem.. can you?
An example: $back == "u" because it's an uploaded background. The oldest comment was white, then I added the Yellow comment, the white one turned black.
Hope that makes sense; if you need more code, just ask. =)
Sam
Comment