#!/usr/bin/perl # ## WebServer prints Env Info from the User's Browser. 2017-Jun-08, JMS # # Changes... # 2017-Jun-08, javascript feature tweaks. JMS. # 2011-Nov-02, css fix, misc internal tweaks. JMS. # 2011-Oct-24, fix align bug for IE in Standards mode. JMS. # 2011-Oct-21, updates to run Browser in Standards mode. JMS. # 2008-Jun-21, fixes for W3C verification. JMS. # 2008-Jan-30, updates to use CGI and URI std library. JMS. # 2004-Sep-17, debug mode. JMS. # 2003-May-18, from original. JMS. # use CGI qw(:standard); use URI::Escape; $Debug = 0 ; if( $ENV{REMOTE_ADDR} eq "127.0.0.1" ){ if( $ENV{QUERY_STRING} eq "debug" ){ $Debug = 1 ; } if( param('debug') ){ $Debug = param('debug') ; } } # ## Print the HTML Head and Styles... # print < Browser Information
EOT_HEAD # ## End of HTML head, Begin the HTML Body text... # print "\n

Some Information that your Browser sends to this WebServer...

\n"; # ## Sort the relevant Server ENV data into Lists of interest... # EnvLoop: foreach $key ( keys(%ENV) ) { if( index( $key, "REMOTE_" ) == 0 ){ push( @List1, $key ); } elsif( index( $key, "HTTP_" ) == 0 ){ # foreach $val ( "HTTP_USER_AGENT", "HTTP_REFERER" ) { if( $val eq $key ) { push( @List2a, $key ); next EnvLoop } } # foreach $val ("HTTP_CACHE_CONTROL","HTTP_X_FORWARDED_FOR","HTTP_VIA") { if( $val eq $key ) { push( @List2c, $key ); next EnvLoop } } ## else push( @List2b, $key ); } else { if( $Debug ){ push( @List3, $key ); } } } # ## Print the Lists as Tables... # &print_title( "Your IP Address" ); &print_start_table( "table1" ); foreach $key ( sort @List1 ){ $val = $ENV{$key}; &print_row( $key, $val ); } &print_end_table(); &print_title("Your Browser's Info"); &print_start_table("table2"); foreach $key ( sort {$b cmp $a} @List2a ){ $val = $ENV{$key}; &print_row( $key, $val ); } foreach $key ( sort @List2b ){ $val = $ENV{$key}; &print_row( $key, $val ); } foreach $key ( sort @List2c ){ $val = $ENV{$key}; &print_row( $key, $val ); } &print_end_table(); if( $Debug ){ &print_title("Debug: All Other ENV Values"); &print_start_table("table3"); foreach $key ( sort @List3 ){ $val = $ENV{$key}; &print_row( $key, $val ); } &print_end_table(); } # ## The following Java-script displays some local Client Info directly from the User's Browser. ## Unlike the preceeding info, the WebServer doesn't see the results displayed in this section. # print < EOT_JS # ## Done. Finish the HTML... # print <

The original WhoAmI script was written by Georgi Chorbadzhiyski at UnixSol.org.

The source for my version of this script can be downloaded from here.

EOT_TAIL # ## End of Main routine. # # ## Subroutines... # sub print_title($) { ($title) = @_; print "\n

". uri_unescape($title) ."

\n"; } sub print_start_table($) { ($class) = @_; print " \n"; } sub print_row($$) { ($key,$val) = @_; print " \n"; print " \n"; print " \n"; print " \n"; } sub print_end_table($) { ($class) = @_; print "
" . uri_unescape($key) . "" . uri_unescape($val) . "
\n"; } # ## End of Script.