env_info.cgi (2086B) - raw
1 #!/usr/bin/perl -wT 2 3 use strict; 4 5 my %env_info = ( 6 SERVER_SOFTWARE => "the server software", 7 SERVER_NAME => "the server hostname or IP address", 8 GATEWAY_INTERFACE => "the CGI specification revision", 9 SERVER_PROTOCOL => "the server protocol name", 10 SERVER_PORT => "the port number for the server", 11 REQUEST_METHOD => "the HTTP request method", 12 PATH_INFO => "the extra path info", 13 PATH_TRANSLATED => "the extra path info translated", 14 DOCUMENT_ROOT => "the server document root directory", 15 SCRIPT_NAME => "the script name", 16 QUERY_STRING => "the query string", 17 REMOTE_HOST => "the hostname of the client", 18 REMOTE_ADDR => "the IP address of the client", 19 AUTH_TYPE => "the authentication method", 20 REMOTE_USER => "the authenticated username", 21 REMOTE_IDENT => "the remote user is (RFC 931): ", 22 CONTENT_TYPE => "the media type of the data", 23 CONTENT_LENGTH => "the length of the request body", 24 HTTP_ACCEPT => "the media types the client accepts", 25 HTTP_USER_AGENT => "the browser the client is using", 26 HTTP_REFERER => "the URL of the referring page", 27 HTTP_COOKIE => "the cookie(s) the client sent" 28 ); 29 30 print "Content-type: text/html\n\n"; 31 32 print <<END_OF_HEADING; 33 34 <HTML> 35 <HEAD> 36 <TITLE>A List of Environment Variables</TITLE> 37 </HEAD> 38 39 <BODY> 40 <H1>CGI Environment Variables</H1> 41 42 <TABLE BORDER=1> 43 <TR> 44 <TH>Variable Name</TH> 45 <TH>Description</TH> 46 <TH>Value</TH> 47 </TR> 48 END_OF_HEADING 49 50 my $name; 51 52 # Add additional variables defined by web server or browser 53 foreach $name ( keys %ENV ) { 54 $env_info{$name} = "an extra variable provided by this server" 55 unless exists $env_info{$name}; 56 } 57 58 foreach $name ( sort keys %env_info ) { 59 my $info = $env_info{$name}; 60 my $value = $ENV{$name} || "<I>Not Defined</I>"; 61 print "<TR><TD><B>$name</B></TD><TD>$info</TD><TD>$value</TD></TR>\n"; 62 } 63 64 print "</TABLE>\n"; 65 print "</BODY></HTML>\n";