Page 1 of 1

help me understand

Posted: Fri Jan 30, 2004 4:56 am
by jtc970
i have a php image with random lines

http://sigs.hopto.org/sigs/mysig/sig51.php

this is an example of my problem..and it doesnt make sense
if you go to this image in internet explorer and keep refreshing it will show 4 different random lines and the time
all is good there...

in opera...
the random line doesnt work well (only shows 1 or 2) but the time changes fine.

somebody please help me understand this?
server side means it shouldnt matter what browser the user is using right?

i got a headache...

Posted: Fri Jan 30, 2004 6:31 am
by twigletmac
How are you doing the random selection?

Mac

Posted: Fri Jan 30, 2004 6:49 am
by jtc970
sig51.php has this in it

Code: Select all

$addliner="1 random 1
2 random 2
3 random 3
4 random 4";
include_once("../thepic.php");
thepic.php

Code: Select all

blah blah blah

$liner = split("\n", $addliner );
$p = intval(rand(0,(count($liner)-1)));
$addliner = $linerї$p]; 

blah blah blah

ImageTTFText ($image,20, 0, 10, 10, $color,$fontr,$addliner);

Posted: Fri Jan 30, 2004 1:23 pm
by jtc970
*bump*
almost 30 people dont know the answer....do you?

Posted: Fri Jan 30, 2004 1:27 pm
by AVATAr
maybe a cache control problem?

Posted: Fri Jan 30, 2004 1:47 pm
by Roja
Cant be a cache-control problem - even if you shift refresh, it has issues.

Plus, its a direct-output image - if you put headers on it, it messes up the output becuase its expecting an image only.

No, when I went, I noticed that the properties on the file gave an error, like it usually does when the graphic doesnt match the output type.

My bet is that he's taking a gif file, and outputting it as a PNG - causing a problem in the filters. IE accepts it, Moz and Opera don't (sorta).

Paste the image generation code, and we'll see whats going on.

(update)
You can see it directly in Moz, by right clicking, view property, and look at the alt tag.. it says something like..

"The image “file:sig51.png” cannot be displayed, because it contains errors"

Which generally means something in the script to generate the image messed up.

Posted: Fri Jan 30, 2004 1:58 pm
by jtc970
yyou migh have gotten those errors when i was trying to put in no-cache headers :)
right, but i am using a png and just overlaying text

this is sig51.php

Code: Select all

<?
$addline1="";
$color1="000000255";
$size1="30";
$font1="arial.ttf";
$right1="100";
$down1="50";
$rotate1="-10";
$addline2="";
$color2="000000000";
$size2="10";
$font2="arial.ttf";
$right2="0";
$down2="10";
$rotate2="0";
$addliner="1 random 1
2 random 2
3 random 3
4 random 4";
$colorr="000000000";
$sizer="20";
$fontr="BNKGOTHL.TTF";
$rightr="20";
$downr="50";
$rotater="0";
$colort="000000000";
$sizet="20";
$fontt="arial.ttf";
$rightt="200";
$downt="50";
$rotatet="0";
$colorip="000000000";
$sizeip="10";
$fontip="arial.ttf";
$rightip="80";
$downip="0";
$rotateip="0";
$uname="24.218.231.121";
$back1="frame_orange.png";
include_once("../thepic.php");

here is the code for thepic.php

Code: Select all

<? Header( "Content-type: image/png"); 
$time = strftime("%I:%M", time());
#$timearray = explode(':',$time);
$ip = getenv(REMOTE_ADDR);

$liner = split("\n", $addliner );
$p = intval(rand(0,(count($liner)-1)));
$addliner = $liner&#1111;$p]; 

$image = imagecreatefrompng('backs/'.$back1); /* Attempt to open */
$color1r = substr($color1,0,3);
$color1g = substr($color1,3,3);
$color1b = substr($color1,-3,3);
$color1 = ImageColorAllocate($image,$color1r,$color1g,$color1b);

$color2r = substr($color2,0,3);
$color2g = substr($color2,3,3);
$color2b = substr($color2,-3,3);
$color2 = ImageColorAllocate($image,$color2r,$color2g,$color2b);

$colortr = substr($colort,0,3);
$colortg = substr($colort,3,3);
$colortb = substr($colort,-3,3);
$colort = ImageColorAllocate($image,$colortr,$colortg,$colortb);

$colorrr = substr($colorr,0,3);
$colorrg = substr($colorr,3,3);
$colorrb = substr($colorr,-3,3);
$colorr = ImageColorAllocate($image,$colorrr,$colorrg,$colorrb);

$coloripr = substr($colorip,0,3);
$coloripg = substr($colorip,3,3);
$coloripb = substr($colorip,-3,3);
$colorip = ImageColorAllocate($image,$coloripr,$coloripg,$coloripb);

$black= ImageColorAllocate($image,0,0,0); 
ImageTTFText ($image,$size1, $rotate1, $right1, $down1, $color1,'fonts/'.$font1,$addline1);
ImageTTFText ($image,$size2, $rotate2, $right2, $down2, $color2,'fonts/'.$font2,$addline2);
ImageTTFText ($image,$sizet, $rotatet, $rightt, $downt, $colort,'fonts/'.$fontt,$time);
ImageTTFText ($image,$sizer, $rotater, $rightr, $downr, $colorr,'fonts/'.$fontr,$addliner);
ImageTTFText ($image,$sizeip, $rotateip, $rightip, $downip, $colorip,'fonts/'.$fontip,$ip);
Imagepng($image);

ImageDestroy($image); 
?>
I understand it's not great code but im just trying to get this to work before I make arrays and what not....

Posted: Fri Jan 30, 2004 7:07 pm
by jtc970
oh masters of the php dn, help to strengthen a newbies belief in you powers to leave no problem unsolved.

Posted: Sat Jan 31, 2004 4:34 am
by jtc970
8O I will mark this problem 'unsolvable'
and everything we beleive about php is wrong!

Posted: Sat Jan 31, 2004 10:30 am
by twigletmac
Which version of PHP are you using? There's no reason why randomness should be any different on Moz than it is on IE. Although I don't seem to be able to see the image in IE (v6) at all?

Mac

Posted: Sat Jan 31, 2004 10:39 am
by jtc970
version 4.3.4.4

i know there shouldnt be a difference...
but i know the image is refreshing because the time changes

its all php. im completely confused.
the image shows fine in my ie 6, its png
:?

Posted: Sat Jan 31, 2004 12:17 pm
by Illusionist
ya when i view it in ie everything is fine, but when i view it in firebird(mozilla) it only shows 3 random lines and when i view the properties it says error with the picture...

Posted: Sat Jan 31, 2004 12:23 pm
by jtc970
i beleive mozilla puts that as an alt text on all straight image views incase it doesn't show... i tried it and every image has that same alt text.

the only thing I can possibly think of (and it may be way off the wall) is php randomizes the seed using something to do with the remote browser...nutty i know, but what else could it be?

Posted: Sun Feb 01, 2004 10:16 am
by jtc970
i added

Code: Select all

$liner = split("\n", $addliner );
shuffle($liner);
function make_seed() &#123; 
   list($usec, $sec) = explode(' ', microtime()); 
   return (float) $sec + ((float) $usec * 100000); 
&#125; 
srand(make_seed()); 
$p = intval(rand(0,(count($liner)-1)));

$addliner = $liner&#1111;$p];
and now it works in ie and mozilla
I have the latest php....

I would of figured a bunch of smart people would be intrigued by this
problem.