Re: [PHP] session variables and SVG documents

2010-02-01 Thread Ashley Sheridan
On Mon, 2010-02-01 at 11:37 +0100, Aurelie REYMUND wrote:

> Hello,
> 
> I have the following problem with the Adobe SVG viewer:
> I try to generate a SVG document using PHP. the following code is working
> well under Firefox, as well as IE with ASV:
> 
>  
> header("Content-type: image/svg+xml");
> 
> $graph_title = 'title';
> 
> 
> print('');
> $svgwidth=500;
> $svgheight=400;
> ?>
> 
>  http://www.w3.org/TR/SVG/DTD/svg10.dtd";>
>  xmlns="http://www.w3.org/2000/svg";>
> This is a php-random rectangle test
>  srand((double) microtime() * 100); //initalizing random generator
> for ($i = 0; $i < 20; $i+=1) {
> $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for rand
> function
> $y = floor(rand(0,$svgheight-1));
> $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside of
> viewbox
> $height = floor(rand(0,$svgheight-$y));
> $red = floor(rand(0,255));
> $blue = floor(rand(0,255));
> $green = floor(rand(0,255));
> $color = "rgb(".$red.",".$green.",".$
> blue.")";
> print "\t style=\"fill:$color;\"/>\n";
> }
> ?>
>  text-anchor="middle">The servers Date and Time is:  (strftime("%Y-%m-%d, %H:%M:%S")); ?>
>  text-anchor="middle">You are running:
>  text-anchor="middle">
> 
> 
> If now I want to include the session_start() at the beginning of the code,
> in IE I got a pop-up dialog called "download file"
> 
> What am I doing wrong ?
> 
> Regards,
> Aurelie


It sounds like it's the SVG plugin you're using on IE that's badly
misbehaving. That said, I've not seen any plugins that correctly pass
across the full headers that the browser would. I tried using sessions
once to secure media files by checking for a valid login against the
session id, but the plugins requesting the video clips didn't send any
cookie data in the header request. As such, it might be better to not
rely on it in this case.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] session variables and SVG documents

2010-02-01 Thread Ray Solomon

From: "Aurelie REYMUND" 
Sent: Monday, February 01, 2010 3:37 AM
To: 
Subject: [PHP] session variables and SVG documents


Hello,

I have the following problem with the Adobe SVG viewer:
I try to generate a SVG document using PHP. the following code is working
well under Firefox, as well as IE with ASV:

');
$svgwidth=500;
$svgheight=400;
?>

http://www.w3.org/TR/SVG/DTD/svg10.dtd";>

xmlns="http://www.w3.org/2000/svg";>
   This is a php-random rectangle test
\n";
}
?>
   The servers Date and Time is: 
   You are running:
   


If now I want to include the session_start() at the beginning of the code,
in IE I got a pop-up dialog called "download file"

What am I doing wrong ?

Regards,
Aurelie




It appears IE does not support svg yet and you need a plugin for it.

However, you could also design your code differently by using Imagemagick to 
convert the svg to png.

If that suits your needs, then use the modified code below:



xmlns="http://www.w3.org/2000/svg";>

   This is a php-random rectangle test';


for ($i = 0; $i < 20; $i++) {
$x = floor(rand(0,$svgwidth-1));
$y = floor(rand(0,$svgheight-1));
$width = floor(rand(0,$svgwidth-$x));
$height = floor(rand(0,$svgheight-$y));
$red = floor(rand(0,255));
$blue = floor(rand(0,255));
$green = floor(rand(0,255));
$color = "rgb(".$red.",".$green.",".$blue.")";
	$svg .= "\tstyle=\"fill:$color;\"/>\n";

}

   $svg .= 'text-anchor="middle">The servers Date and Time is: '.date("Y-m-d, 
H:m:s").'
   text-anchor="middle">You are running:
   text-anchor="middle">'.$HTTP_USER_AGENT.'

';


file_put_contents('/tmp/image.svg', $svg);

exec("/usr/bin/rsvg /tmp/image.svg /tmp/image.png");

echo file_get_contents('/tmp/image.png');
?>

-Ray Solomon



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] session variables and SVG documents

2010-02-03 Thread Aurelie REYMUND
Hello,

unfortunately, it does not suite my needs. The image must be clickable. The
application I'm developping reads data from a database and display the
information graphically. The user must be able to click on some elements of
the picture, and I have to store the information the user clicked on
(session vars). I cannot tell the user not to use IE, so I have to find
another solution...

Regards,
Aurelie

2010/2/1 Ray Solomon 

> From: "Aurelie REYMUND" 
> Sent: Monday, February 01, 2010 3:37 AM
> To: 
> Subject: [PHP] session variables and SVG documents
>
>
>  Hello,
>>
>> I have the following problem with the Adobe SVG viewer:
>> I try to generate a SVG document using PHP. the following code is working
>> well under Firefox, as well as IE with ASV:
>>
>> >
>> header("Content-type: image/svg+xml");
>>
>> $graph_title = 'title';
>>
>>
>> print('');
>> $svgwidth=500;
>> $svgheight=400;
>> ?>
>>
>> > http://www.w3.org/TR/SVG/DTD/svg10.dtd";>
>> > xmlns="http://www.w3.org/2000/svg";>
>>   This is a php-random rectangle test
>> > srand((double) microtime() * 100); //initalizing random generator
>> for ($i = 0; $i < 20; $i+=1) {
>>   $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for rand
>> function
>>   $y = floor(rand(0,$svgheight-1));
>>   $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside of
>> viewbox
>>   $height = floor(rand(0,$svgheight-$y));
>>   $red = floor(rand(0,255));
>>   $blue = floor(rand(0,255));
>>   $green = floor(rand(0,255));
>>   $color = "rgb(".$red.",".$green.",".$
>> blue.")";
>>   print "\t> style=\"fill:$color;\"/>\n";
>> }
>> ?>
>>   > text-anchor="middle">The servers Date and Time is: > (strftime("%Y-%m-%d, %H:%M:%S")); ?>
>>   > text-anchor="middle">You are running:
>>   > text-anchor="middle">
>> 
>>
>> If now I want to include the session_start() at the beginning of the code,
>> in IE I got a pop-up dialog called "download file"
>>
>> What am I doing wrong ?
>>
>> Regards,
>> Aurelie
>>
>>
>
> It appears IE does not support svg yet and you need a plugin for it.
>
> However, you could also design your code differently by using Imagemagick
> to convert the svg to png.
> If that suits your needs, then use the modified code below:
>
>
> 
> header("Content-type: image/png");
>
> $graph_title = 'title';
>
> $svgwidth=500;
> $svgheight=400;
>
> $svg = '
> http://www.w3.org/2000/svg";>
>   This is a php-random rectangle test';
>
>
> for ($i = 0; $i < 20; $i++) {
>
>$x = floor(rand(0,$svgwidth-1));
>$y = floor(rand(0,$svgheight-1));
>$width = floor(rand(0,$svgwidth-$x));
>$height = floor(rand(0,$svgheight-$y));
>$red = floor(rand(0,255));
>$blue = floor(rand(0,255));
>$green = floor(rand(0,255));
>$color = "rgb(".$red.",".$green.",".$blue.")";
>$svg .= "\t height=\"$height\" style=\"fill:$color;\"/>\n";
> }
>
>   $svg .= ' text-anchor="middle">The servers Date and Time is: '.date("Y-m-d,
> H:m:s").'
>text-anchor="middle">You are running:
>text-anchor="middle">'.$HTTP_USER_AGENT.'
> ';
>
>
> file_put_contents('/tmp/image.svg', $svg);
>
> exec("/usr/bin/rsvg /tmp/image.svg /tmp/image.png");
>
> echo file_get_contents('/tmp/image.png');
> ?>
>
> -Ray Solomon
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] session variables and SVG documents

2010-02-03 Thread Ashley Sheridan
On Wed, 2010-02-03 at 10:49 +0100, Aurelie REYMUND wrote:

> Hello,
> 
> unfortunately, it does not suite my needs. The image must be clickable. The
> application I'm developping reads data from a database and display the
> information graphically. The user must be able to click on some elements of
> the picture, and I have to store the information the user clicked on
> (session vars). I cannot tell the user not to use IE, so I have to find
> another solution...
> 
> Regards,
> Aurelie
> 
> 2010/2/1 Ray Solomon 
> 
> > From: "Aurelie REYMUND" 
> > Sent: Monday, February 01, 2010 3:37 AM
> > To: 
> > Subject: [PHP] session variables and SVG documents
> >
> >
> >  Hello,
> >>
> >> I have the following problem with the Adobe SVG viewer:
> >> I try to generate a SVG document using PHP. the following code is working
> >> well under Firefox, as well as IE with ASV:
> >>
> >>  >>
> >> header("Content-type: image/svg+xml");
> >>
> >> $graph_title = 'title';
> >>
> >>
> >> print('');
> >> $svgwidth=500;
> >> $svgheight=400;
> >> ?>
> >>
> >>  >> http://www.w3.org/TR/SVG/DTD/svg10.dtd";>
> >>  >> xmlns="http://www.w3.org/2000/svg";>
> >>   This is a php-random rectangle test
> >>  >> srand((double) microtime() * 100); //initalizing random generator
> >> for ($i = 0; $i < 20; $i+=1) {
> >>   $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for rand
> >> function
> >>   $y = floor(rand(0,$svgheight-1));
> >>   $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside of
> >> viewbox
> >>   $height = floor(rand(0,$svgheight-$y));
> >>   $red = floor(rand(0,255));
> >>   $blue = floor(rand(0,255));
> >>   $green = floor(rand(0,255));
> >>   $color = "rgb(".$red.",".$green.",".$
> >> blue.")";
> >>   print "\t >> style=\"fill:$color;\"/>\n";
> >> }
> >> ?>
> >>>> text-anchor="middle">The servers Date and Time is:  >> (strftime("%Y-%m-%d, %H:%M:%S")); ?>
> >>>> text-anchor="middle">You are running:
> >>>> text-anchor="middle">
> >> 
> >>
> >> If now I want to include the session_start() at the beginning of the code,
> >> in IE I got a pop-up dialog called "download file"
> >>
> >> What am I doing wrong ?
> >>
> >> Regards,
> >> Aurelie
> >>
> >>
> >
> > It appears IE does not support svg yet and you need a plugin for it.
> >
> > However, you could also design your code differently by using Imagemagick
> > to convert the svg to png.
> > If that suits your needs, then use the modified code below:
> >
> >
> >  >
> > header("Content-type: image/png");
> >
> > $graph_title = 'title';
> >
> > $svgwidth=500;
> > $svgheight=400;
> >
> > $svg = '
> > http://www.w3.org/2000/svg";>
> >   This is a php-random rectangle test';
> >
> >
> > for ($i = 0; $i < 20; $i++) {
> >
> >$x = floor(rand(0,$svgwidth-1));
> >$y = floor(rand(0,$svgheight-1));
> >$width = floor(rand(0,$svgwidth-$x));
> >$height = floor(rand(0,$svgheight-$y));
> >$red = floor(rand(0,255));
> >$blue = floor(rand(0,255));
> >$green = floor(rand(0,255));
> >$color = "rgb(".$red.",".$green.",".$blue.")";
> >$svg .= "\t > height=\"$height\" style=\"fill:$color;\"/>\n";
> > }
> >
> >   $svg .= ' > text-anchor="middle">The servers Date and Time is: '.date("Y-m-d,
> > H:m:s").'
> >> text-anchor="middle">You are running:
> >> text-anchor="middle">'.$HTTP_USER_AGENT.'
> > ';
> >
> >
> > file_put_contents('/tmp/image.svg', $svg);
> >
> > exec("/usr/bin/rsvg /tmp/image.svg /tmp/image.png");
> >
> > echo file_get_contents('/tmp/image.png');
> > ?>
> >
> > -Ray Solomon
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >


IE doesn't display SVG natively, and the plugins for it are pants.
However, IE does make use of its own propitiatory vector language called
VML, This is how the Cufon font replacer system works.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] session variables and SVG documents

2010-02-03 Thread tedd

At 10:49 AM +0100 2/3/10, Aurelie REYMUND wrote:

Hello,

unfortunately, it does not suite my needs. The image must be clickable. The
application I'm developping reads data from a database and display the
information graphically. The user must be able to click on some elements of
the picture, and I have to store the information the user clicked on
(session vars). I cannot tell the user not to use IE, so I have to find
another solution...

Regards,
Aurelie



Aurelie:

The image must be clickable?

I must not be understanding something. Anything can be made 
clickable, just put it in an anchor, such as:


Click This

The previous post mentioned using ImageMagick to convert the svg to 
png -- so write that script and place it in an anchor. I don't see 
the problem.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] session variables and SVG documents

2010-02-03 Thread Adam Richardson
On Wed, Feb 3, 2010 at 8:20 AM, Ashley Sheridan 
wrote:

> On Wed, 2010-02-03 at 10:49 +0100, Aurelie REYMUND wrote:
>
> > Hello,
> >
> > unfortunately, it does not suite my needs. The image must be clickable.
> The
> > application I'm developping reads data from a database and display the
> > information graphically. The user must be able to click on some elements
> of
> > the picture, and I have to store the information the user clicked on
> > (session vars). I cannot tell the user not to use IE, so I have to find
> > another solution...
> >
> > Regards,
> > Aurelie
> >
> > 2010/2/1 Ray Solomon 
> >
> > > From: "Aurelie REYMUND" 
> > > Sent: Monday, February 01, 2010 3:37 AM
> > > To: 
> > > Subject: [PHP] session variables and SVG documents
> > >
> > >
> > >  Hello,
> > >>
> > >> I have the following problem with the Adobe SVG viewer:
> > >> I try to generate a SVG document using PHP. the following code is
> working
> > >> well under Firefox, as well as IE with ASV:
> > >>
> > >>  > >>
> > >> header("Content-type: image/svg+xml");
> > >>
> > >> $graph_title = 'title';
> > >>
> > >>
> > >> print('');
> > >> $svgwidth=500;
> > >> $svgheight=400;
> > >> ?>
> > >>
> > >>  > >> http://www.w3.org/TR/SVG/DTD/svg10.dtd";>
> > >>  > >> xmlns="http://www.w3.org/2000/svg";>
> > >>   This is a php-random rectangle test
> > >>  > >> srand((double) microtime() * 100); //initalizing random generator
> > >> for ($i = 0; $i < 20; $i+=1) {
> > >>   $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for
> rand
> > >> function
> > >>   $y = floor(rand(0,$svgheight-1));
> > >>   $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside
> of
> > >> viewbox
> > >>   $height = floor(rand(0,$svgheight-$y));
> > >>   $red = floor(rand(0,255));
> > >>   $blue = floor(rand(0,255));
> > >>   $green = floor(rand(0,255));
> > >>   $color = "rgb(".$red.",".$green.",".$
> > >> blue.")";
> > >>   print "\t > >> style=\"fill:$color;\"/>\n";
> > >> }
> > >> ?>
> > >>> >> text-anchor="middle">The servers Date and Time is:  > >> (strftime("%Y-%m-%d, %H:%M:%S")); ?>
> > >>> >> text-anchor="middle">You are running:
> > >>> >> text-anchor="middle">
> > >> 
> > >>
> > >> If now I want to include the session_start() at the beginning of the
> code,
> > >> in IE I got a pop-up dialog called "download file"
> > >>
> > >> What am I doing wrong ?
> > >>
> > >> Regards,
> > >> Aurelie
> > >>
> > >>
> > >
> > > It appears IE does not support svg yet and you need a plugin for it.
> > >
> > > However, you could also design your code differently by using
> Imagemagick
> > > to convert the svg to png.
> > > If that suits your needs, then use the modified code below:
> > >
> > >
> > >  > >
> > > header("Content-type: image/png");
> > >
> > > $graph_title = 'title';
> > >
> > > $svgwidth=500;
> > > $svgheight=400;
> > >
> > > $svg = '
> > > http://www.w3.org/2000/svg";>
> > >   This is a php-random rectangle test';
> > >
> > >
> > > for ($i = 0; $i < 20; $i++) {
> > >
> > >$x = floor(rand(0,$svgwidth-1));
> > >$y = floor(rand(0,$svgheight-1));
> > >$width = floor(rand(0,$svgwidth-$x));
> > >$height = floor(rand(0,$svgheight-$y));
> > >$red = floor(rand(0,255));
> > >$blue = floor(rand(0,255));
> > >$green = floor(rand(0,255));
> > >$color = "rgb(".$red.",".$green.",".$blue.")";
> > >$svg .= "\t > > height=\"$height\" style=\"fill:$color;\"/>\n";
> > > }
> > >
> > >   $svg .= ' > > text-anchor="middle">The servers Date and Time is: '.date("Y-m-d,
> > > H:m:s").'
> > >> > text-anchor="middle">You are running:
> > >> > text-anchor="middle">'.$HTTP_USER_AGENT.'
> > > ';
> > >
> > >
> > > file_put_contents('/tmp/image.svg', $svg);
> > >
> > > exec("/usr/bin/rsvg /tmp/image.svg /tmp/image.png");
> > >
> > > echo file_get_contents('/tmp/image.png');
> > > ?>
> > >
> > > -Ray Solomon
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
>
>
> IE doesn't display SVG natively, and the plugins for it are pants.
> However, IE does make use of its own propitiatory vector language called
> VML, This is how the Cufon font replacer system works.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
Maybe svgweb (by Google) would allow you to achieve your goals:
http://code.google.com/p/svgweb/

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com