#!/usr/bin/perl ########################################################################### # environment_variables.cgi # # # # This script was written by Selena Sol (selena@eff.org # # http://www.eff.org/~erict) having been inspired by countless other # # perl authors. Feel free to copy, cite, reference, sample, borrow or # # plagiarize the contents. However, please let me know where it goes so # # that I can at least watch and take part in the development of the # # memes. Information wants to be free, support public domain freware. # # # # Version: 2.0 # # Last Modified: 5-12-96 # # Description: This script will output all of the environment variables # # available for use # # Usage: This script must be placed in a directory which allows cgi # # executables and must have its permissions set such that the web # # server has permission to execute it. # # # ########################################################################### # First, print out the HTTP header. print "Content-type: text/html\n\n"; print "Current Time : ".localtime(time())."

\n"; # Create a list of environment variables by gathering all the "keys" in the # %ENV associative array. @environment_variables = keys (%ENV); # For ever environment variable in the @environment_variables list, print # the variable and then print its associated value. Then quit. foreach $environment_variable (@environment_variables) { print "$environment_variable = $ENV{$environment_variable}
"; } print "

\n"; print " \n"; print "
"; $temp = &ReadParse; print "$in{test} $in{Quit}\n"; exit; sub ReadParse { local (*in) = @_ if @_; local ($i, $loc, $key, $val); # Read in text if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } @in = split(/&/,$in); $vars = ""; $c=0; foreach $i (0 .. $#in) { # Convert plus's to spaces $in[$i] =~ s/\+/ /g; # Split into key and value. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. #!! text fields return empty values when user doesn't use; dump these ($val eq "") && next; # Convert %XX from hex numbers to alphanumeric $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; # Associate key and value $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator $in{$key} .= $val; $vars .= "$key, "; #$in =~ s!%5B!\[!gi; #$in =~ s!%5D!\]!gi; } return 1; # just for fun }