Re: [PHP] $_ENV not working for me with PHP 4.2.0

2003-10-06 Thread Burhan Khalid
John Wilcox wrote:
I've been trying to make a simple script which just
outputs the username that the script is currently
executing under (in order to test that suexec is
working properly).  I've tried using the following
line:
?php print $_ENV['USER']; ?

and it fails to produce any output and returns the
following error in my log file: [Sun Oct  5 14:02:35
2003] [error] PHP Notice:  Undefined index:  USER in
/home/test/test.php on line 1
Now, I've tried the same command on another server
running PHP 4.2.0 and it correctly outputs the
username as expected.  Both these machines are running
Debian Linux.
Try echo pre; print_r($_ENV); echo /pre;
to see what information is available in the ENV array.
Are both servers running the same implementation of PHP? (CGI/SAPI, etc.)

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Passing POST args to PHP when run as a CGI (was Re: [PHP] $_ENV not working for me with PHP 4.2.0)

2003-10-06 Thread John Wilcox

--- Curt Zirzow [EMAIL PROTECTED] wrote:
 Technically it is 4.1.0 (where did you see the
 4.2.0?) but anything
 prior to that you should use $HTTP_ENV_VARS

my mistake, you're right, it was 4.1.0.


http://php.net/manual/en/language.variables.predefined.php
 http://php.net/manual/en/reserved.variables.php
 
 A diff of your php.ini will tell the story I'll bet
 a diff output
 would be something like:
 
 306c306
  variables_order = GPCS
 ---
  variables_order = EGPCS

yes, you're correct, my php.ini uses 'variable_order =
GPCS'.  I tried changing this to EGPCS, but
$_ENV['USER']; would still not work.

 To get the user that apache is really running as you
 want to do
 something like: 
 
   print `whoami`;

I've been playing around a bit more, and made a simple
script:

?php
echo getenv('USER'), br /;
print `whoami` . br /;
print $_ENV['USER'];
?

It produces the following output:

john
nobody
(and an error is produced in the logfile for
$_ENV['USER']: Undefined index:  USER)

Now, I'm running this PHP script from within a virtual
host with a certain user/group (test/test - made
possible by using suEXEC), so  I can't understand why
getenv('USER'); is returning john..

Anyway, I've been reading up on using suEXEC with PHP
scripts, and it looks like the scripts have to be run
as a .cgi in order to inherit the user/group of the
virtual host..  I've tried changing around one of my
PHP scripts so that it runs as a cgi (basically I just
renamed the file to test.cgi and added
#!/usr/local/bin/php to the beginning of the script). 
The only problem is that now my $_POST['TEST'];
doesn't work within the script, so my new problem is
how to figure out passing variables from one script to
another when using PHP as a .cgi.  Am I doing
something wrong, or does something need to be changed
in order for PHP to be able to receive these POST
variables?
If anyone has any ideas, please let me know.  Thanks
in advance,

John


__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



[PHP] $_ENV not working for me with PHP 4.2.0

2003-10-05 Thread John Wilcox
I've been trying to make a simple script which just
outputs the username that the script is currently
executing under (in order to test that suexec is
working properly).  I've tried using the following
line:

?php print $_ENV['USER']; ?

and it fails to produce any output and returns the
following error in my log file: [Sun Oct  5 14:02:35
2003] [error] PHP Notice:  Undefined index:  USER in
/home/test/test.php on line 1

Now, I've tried the same command on another server
running PHP 4.2.0 and it correctly outputs the
username as expected.  Both these machines are running
Debian Linux.

Now I figure it must be some configuration setting
that is messing this up somehow, but I have no idea
where to look.  I've checked out the documentation and
it states that PHP versions later than 4.2.0 use the
$_ENV global variable to access environment variables,
so it seems like I'm using it correctly.  Anyways, if
anyone has any suggestions, please let me know! 
Thanks in advance,

John Wilcox

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Re: [PHP] $_ENV not working for me with PHP 4.2.0

2003-10-05 Thread Tom Rogers
Hi,

Monday, October 6, 2003, 4:43:20 AM, you wrote:
JW I've been trying to make a simple script which just
JW outputs the username that the script is currently
JW executing under (in order to test that suexec is
JW working properly).  I've tried using the following
JW line:

JW ?php print $_ENV['USER']; ?

JW and it fails to produce any output and returns the
JW following error in my log file: [Sun Oct  5 14:02:35
JW 2003] [error] PHP Notice:  Undefined index:  USER in
JW /home/test/test.php on line 1

JW Now, I've tried the same command on another server
JW running PHP 4.2.0 and it correctly outputs the
JW username as expected.  Both these machines are running
JW Debian Linux.

JW Now I figure it must be some configuration setting
JW that is messing this up somehow, but I have no idea
JW where to look.  I've checked out the documentation and
JW it states that PHP versions later than 4.2.0 use the
JW $_ENV global variable to access environment variables,
JW so it seems like I'm using it correctly.  Anyways, if
JW anyone has any suggestions, please let me know! 
JW Thanks in advance,

JW John Wilcox

JW __
JW Do you Yahoo!?
JW The New Yahoo! Shopping - with improved product search
JW http://shopping.yahoo.com

Do this to see what is available in your enviroment, it would seem that USER is
not being set by the system or is called something else.

echo `printenv`;

(use backticks)

-- 
regards,
Tom

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



Re: [PHP] $_ENV not working for me with PHP 4.2.0

2003-10-05 Thread Curt Zirzow
* Thus wrote John Wilcox ([EMAIL PROTECTED]):
 I've been trying to make a simple script which just
 outputs the username that the script is currently
 executing under (in order to test that suexec is
 working properly).  I've tried using the following
 line:
 
 ?php print $_ENV['USER']; ?

This var isn't the USER that the process is running under, it is
the USER that started apache (assuming thats your webserver). You
can see all the same vars if you execute the command `env`.

I also tested this:

  shutting down apache
  setenv TEST putvarinenv
  started apache

  test.php:
  echo getenv('TEST');

yields:
'putvarinenv'


 
 and it fails to produce any output and returns the
 following error in my log file: [Sun Oct  5 14:02:35
 2003] [error] PHP Notice:  Undefined index:  USER in
 /home/test/test.php on line 1
 
 Now, I've tried the same command on another server
 running PHP 4.2.0 and it correctly outputs the
 username as expected.  Both these machines are running
 Debian Linux.

if the username was expected, I'm guessing your output was root, you should
really change the webserver process to something other than root
(an unprivlaged user).

 
 Now I figure it must be some configuration setting
 that is messing this up somehow, but I have no idea
 where to look.  I've checked out the documentation and
 it states that PHP versions later than 4.2.0 use the
 $_ENV global variable to access environment variables,
 so it seems like I'm using it correctly.  Anyways, if
 anyone has any suggestions, please let me know! 
 Thanks in advance,

Technically it is 4.1.0 (where did you see the 4.2.0?) but anything
prior to that you should use $HTTP_ENV_VARS

http://php.net/manual/en/language.variables.predefined.php
http://php.net/manual/en/reserved.variables.php

A diff of your php.ini will tell the story I'll bet a diff output
would be something like:

306c306
 variables_order = GPCS
---
 variables_order = EGPCS


To get the user that apache is really running as you want to do
something like: 

  print `whoami`;
  

Curt
-- 
List Stats: http://zirzow.dyndns.org/html/mlists/php_general/

I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] $_ENV not working for me with PHP 4.2.0

2003-10-05 Thread John Wilcox
Hi Tom, when I put echo `printenv`; into a script, I
see in big bold letters: USER=john so this environment
variable seems to be available..  getenv('USER');
works fine, so I guess I'll just use that instead.. No
idea why $_ENV['USER']; doesn't work though.  Thanks
for the suggestion,

John


--- Tom Rogers [EMAIL PROTECTED] wrote:
 Hi,
 
 Monday, October 6, 2003, 4:43:20 AM, you wrote:
 JW I've been trying to make a simple script which
 just
 JW outputs the username that the script is
 currently
 JW executing under (in order to test that suexec is
 JW working properly).  I've tried using the
 following
 JW line:
 
 JW ?php print $_ENV['USER']; ?
 
 JW and it fails to produce any output and returns
 the
 JW following error in my log file: [Sun Oct  5
 14:02:35
 JW 2003] [error] PHP Notice:  Undefined index: 
 USER in
 JW /home/test/test.php on line 1
 
 JW Now, I've tried the same command on another
 server
 JW running PHP 4.2.0 and it correctly outputs the
 JW username as expected.  Both these machines are
 running
 JW Debian Linux.
 
 JW Now I figure it must be some configuration
 setting
 JW that is messing this up somehow, but I have no
 idea
 JW where to look.  I've checked out the
 documentation and
 JW it states that PHP versions later than 4.2.0 use
 the
 JW $_ENV global variable to access environment
 variables,
 JW so it seems like I'm using it correctly. 
 Anyways, if
 JW anyone has any suggestions, please let me know! 
 JW Thanks in advance,
 
 JW John Wilcox
 
 JW __
 JW Do you Yahoo!?
 JW The New Yahoo! Shopping - with improved product
 search
 JW http://shopping.yahoo.com
 
 Do this to see what is available in your enviroment,
 it would seem that USER is
 not being set by the system or is called something
 else.
 
 echo `printenv`;
 
 (use backticks)
 
 -- 
 regards,
 Tom
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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