Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-29 Thread Richard Lynch
On Thu, October 27, 2005 3:43 am, Christoph Freundl wrote:
 I have a problem with the persistence of environment variables when
 mixing PHP and SSI (Apache) and I am not sure if I just made an error
 or if this approach cannot work at all.
 So please consider the following files:

I *believe* that there are two different scenarios here:

1. Each virtual is a totally separate HTTP request, in the
stateless HTTP protocol, and your environment variables in one will
not (ever) survive to the next.

2. Apache is configured to do virtual requests as some kind of
sub-request and it's all in one single HTTP request/process/thread. 
I *think* this is a feature I've read about in HTTP specification at
http://apache.org

If I'm right about all this, none of this has much to do with PHP
really, and has everything to do with Apache and configuration.  You'd
have the same issues in mod_perl or mod_python as you are having in
PHP.

PS Abondon SSI and just use PHP and your headaches will all disappear.
:-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-29 Thread Richard Lynch
On Fri, October 28, 2005 9:36 am, Christoph Freundl wrote:
 Perhaps I return to what I primarily intended to ask: is it really the
 wanted behaviour of virtual() that changes that are made by the
 included file do not influence the environment of the including file?

That is most definitely a desirable behaviour for some users.

/virtual is a separate HTTP requestm just as if the user had surfed
there and crammed in the result.

HTTP is stateless for various reasons.

There are pros and cons to that, but it was not done on a whim.

You MIGHT be able to pass myvar *into* the /virtual as a GET arg...

!-- #virtual /whatever.shtml?myvar=!-- #print myvar 

I'm pretty sure of 2 things:
1. !-- #print myvar -- is probably not how you print out an SSI var.
2. Even if it *IS* how you do it, nesting the !-- # directives ain't
gonna work.

But you get the idea.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Mixed PHP/SSI and environment variables

2005-10-28 Thread Christoph Freundl
Hello,

I have a problem with the persistence of environment variables when 
mixing PHP and SSI (Apache) and I am not sure if I just made an error 
or if this approach cannot work at all.
So please consider the following files:

setvar.shtml
-
!--#set var=myvar value=myval --
-

showvar.php
-
?php echo apache_getenv( myvar ); ?
-

info.shtml
-
!--#include virtual=setvar.shtml --
!--#include virtual=showvar.php --
-

info.php
-
?php
  virtual( setvar.shtml );
  echo apache_getenv( myvar );
?
-

What I would expect is that you get the same result if you call 
info.shtml and info.php. What happens when I tried (PHP 4.3.10 with 
both Apache 1.3.33 and 2.0.53): the shtml shows the variable but the 
php does not, it seems to forget the variable set in setvar.shtml.
Please, can anybody tell me what is going wrong here?

Regards, Christoph

-- 
Christoph Freundlhttp://www10.informatik.uni-erlangen.de/~chfreund/
Lehrstuhl für Systemsimulation (Inf. 10), Cauerstr. 6, D-91058 Erlangen
   The earth is like a tiny grain of sand, only much, much heavier.

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



Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-28 Thread Jochem Maas

Christoph Freundl wrote:

Hello,

I have a problem with the persistence of environment variables when 
mixing PHP and SSI (Apache) and I am not sure if I just made an error 
or if this approach cannot work at all.

So please consider the following files:

setvar.shtml
-
!--#set var=myvar value=myval --
-

showvar.php
-
?php echo apache_getenv( myvar ); ?
-

info.shtml
-
!--#include virtual=setvar.shtml --
!--#include virtual=showvar.php --
-

info.php
-
?php
  virtual( setvar.shtml );


have yuou tried include/require here instead of virtual()

I imagine that the env of the subprocess wouldn't affect
the env of the parent process - i.e. to me it makes sense
if you say the env var in the subprocess is not available in
the parent process.


  echo apache_getenv( myvar );
?
-

What I would expect is that you get the same result if you call 
info.shtml and info.php. What happens when I tried (PHP 4.3.10 with 
both Apache 1.3.33 and 2.0.53): the shtml shows the variable but the 
php does not, it seems to forget the variable set in setvar.shtml.

Please, can anybody tell me what is going wrong here?

Regards, Christoph



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



Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-28 Thread Christoph Freundl
Am Freitag, 28. Oktober 2005 13:22 schrieb Jochem Maas:
  info.php
  -
  ?php
virtual( setvar.shtml );

 have yuou tried include/require here instead of virtual()

 I imagine that the env of the subprocess wouldn't affect
 the env of the parent process - i.e. to me it makes sense
 if you say the env var in the subprocess is not available in
 the parent process.

echo apache_getenv( myvar );
  ?
  -

Nope, both include and require result that the content of setvar.shtml 
shows up literally in the output without the SSI having been processed 
by Apache.

-- 
Christoph Freundlhttp://www10.informatik.uni-erlangen.de/~chfreund/
Lehrstuhl für Systemsimulation (Inf. 10), Cauerstr. 6, D-91058 Erlangen
  Quiet people aren't the only ones who don't say much. - R. Baalke

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



Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-28 Thread Jochem Maas

Christoph Freundl wrote:

Am Freitag, 28. Oktober 2005 13:22 schrieb Jochem Maas:


info.php
-
?php
 virtual( setvar.shtml );


have yuou tried include/require here instead of virtual()

I imagine that the env of the subprocess wouldn't affect
the env of the parent process - i.e. to me it makes sense
if you say the env var in the subprocess is not available in
the parent process.



 echo apache_getenv( myvar );
?
-



Nope, both include and require result that the content of setvar.shtml 
shows up literally in the output without the SSI having been processed 
by Apache.



ok, and if you stick the following in 1 file and call it?:

!--#set var=myvar value=myval --
?php echo apache_getenv( myvar ); ?


... just thinking out loud here.





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



Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-28 Thread Christoph Freundl
Am Freitag, 28. Oktober 2005 13:42 schrieb Jochem Maas:
 ok, and if you stick the following in 1 file and call it?:

 !--#set var=myvar value=myval --
 ?php echo apache_getenv( myvar ); ?

 ... just thinking out loud here.

Ok, I tried this by configuring Apache such that .php-files are also 
parsed for Server Side Includes and wrote it the way you suggest. Now 
I am really confused: the SSI statements are obviously recognized 
because they do not appear in the resulting file but
a) apache_getenv does still not return the value for the variable but
b) if I call phpinfo() instead of apache_getenv the variable myvar 
plus the set value is shown correctly in the Apache Environment and
c) an SSI !--#echo var=myvar -- after the php block also gives the
correct value

Perhaps I return to what I primarily intended to ask: is it really the 
wanted behaviour of virtual() that changes that are made by the 
included file do not influence the environment of the including file?

Regards, Christoph

-- 
Christoph Freundlhttp://www10.informatik.uni-erlangen.de/~chfreund/
Lehrstuhl für Systemsimulation (Inf. 10), Cauerstr. 6, D-91058 Erlangen
Tel: +49-9131-85-28676 | A low voter turnout is an indication of fewer
Fax: +49-9131-85-28928 |people going to the polls. - D. Quayle

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



Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-28 Thread Jochem Maas

Christoph Freundl wrote:

Am Freitag, 28. Oktober 2005 13:42 schrieb Jochem Maas:


ok, and if you stick the following in 1 file and call it?:

!--#set var=myvar value=myval --
?php echo apache_getenv( myvar ); ?

... just thinking out loud here.




I just looked at apache_getenv():

string apache_getenv ( string variable [, bool walk_to_top] )

the second arg maybe something to consider?
also does getenv() [http://php.net/getenv] have the same problems?




Ok, I tried this by configuring Apache such that .php-files are also 
parsed for Server Side Includes and wrote it the way you suggest. Now 
I am really confused: the SSI statements are obviously recognized 
because they do not appear in the resulting file but

a) apache_getenv does still not return the value for the variable but
b) if I call phpinfo() instead of apache_getenv the variable myvar 
plus the set value is shown correctly in the Apache Environment and

c) an SSI !--#echo var=myvar -- after the php block also gives the
correct value

Perhaps I return to what I primarily intended to ask: is it really the 
wanted behaviour of virtual() that changes that are made by the 
included file do not influence the environment of the including file?


I would say yes because virtual() create a sub-process, with it _own_ env.



Regards, Christoph



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