Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

%ENV

Status
Not open for further replies.

uniopp

Technical User
Oct 7, 2001
152
0
0
JP
Hi,
My server provides the following in %ENV.
I would appreciate it if someone could answer
my questions below-

CONTENT_LENGTH
CONTENT_TYPE
DOCUMENT_ROOT
GATEWAY_INTERFACE
HTTP_HOST
HTTP_USER_AGENT
PATH
QUERY_STRING
REMOTE_ADDR
REMOTE_HOST
REMOTE_PORT
REQUEST_METHOD
REQUEST_URI
SCRIPT_FILENAME
SCRIPT_NAME
SERVER_ADDR
SERVER_ADMIN
SERVER_NAME
SERVER_PORT
SERVER_PROTOCOL
SERVER_SIGNATURE
SERVER_SOFTWARE
TZ


1/ If a user calls my perl script will all of the above variables be provided or does it depend on
the users server and browser as well?

2/ If it depends on their server or browser, are any of
the variables standard accross all platforms and browsers?

3/ I noticed that my server doesn't have an HTTP_REFERER.
Will a combination of HTTP_HOST and REQUEST_URI(or SCRIPT_NAME)
do the same thing?

Thank you.
Simon.
 

Hi Simon,

From what I've expirienced so far with the ENV variables is that they differ based on the browser data transfer type. I can't say whether they differ between say ie & netscape or even opera. But if you setup a simple script:

foreach $key (keys %ENV){
print &quot;$key - $ENV{$key}<br>&quot;;
}

And setup a link, and a submit button in a form with the method set to post, you will be able to easily see the change in information between the two.

I had to do this once in order to collect the users ip address along with their service providers address for a security script.

And for 3, the combination won't work. HTTP_REFERER is the url from which the request to your program was dirived, so it make the most sense that GET would have it for sure but I wouldn't see why POST wouldn't have the same information. The lack of this Key in your ENV variables suggests that either the server doesn't support it or you ran your script when there was no referrer. Still wouldn't explain the actual key missing I'd say though.

I think someone else should offer up some info for question 3.

That's about all I can help with,

Tony
 
I want to log as many details about the people who use my script.
I also want to check if they are authorized users, is there a 100%reliable %ENV variable I can use that won't be effected by the users browser type or server?? If not, how can I confirm they are authorized users without having them login?
Thank you.
Simon.
 
OK, here's my $.05 worth (I hope it worth more than $.02):

HTTP_REFERRER is the full URL of the PAGE that called the script. BUT, not all browsers are good about passing it.

HTTP_HOST is a domain name. Not sure whether it is the referring domain name or the domain name of the server running the script, but I suspect the latter.

REQUEST_URI is the path/filename of the script called by the referring page. It's usually the same as SCRIPT_NAME, but I wouldn't bet on it.

Your best bets for validation are probably REMOTE_HOST and/or REMOTE_ADDR, which contain the IP address of the browser. I'd check one first, and if it fails check the other. These are usually pretty reliable. But you'll have to decide for yourself what to do if neither one is set. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top