1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/perl -wT
  2. use strict;
  3. use warnings;
  4. use Sys::Hostname;
  5. sub mygetstrtime {
  6. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (time);
  7. $year += 1900; $mon += 1;
  8. return sprintf "%02d/%02d/%04d %02d:%02d:%02d", $mon, $mday, $year, $hour, $min, $sec;
  9. }
  10. print "Content-type: text/plain; charset=utf-8\n";
  11. print "Pragma: no-cache\n";
  12. print "Cache-Control: no-cache\n\n";
  13. my $ip = $ENV{'REMOTE_ADDR'};
  14. my $port = $ENV{'REMOTE_PORT'};
  15. my $myip = $ENV{'SERVER_ADDR'};
  16. my $myport = $ENV{'SERVER_PORT'};
  17. my $myhostname = hostname;
  18. my $mylocaltime = &mygetstrtime;
  19. my $username = ( $^O eq "MSWin32" ? '' : getpwuid( $< ));
  20. print "Client:\n";
  21. print " $ip:$port\n";
  22. print "\n";
  23. print "Server:\n";
  24. print " $myip:$myport\n";
  25. print " $username\@$myhostname:$myport\n";
  26. print " $mylocaltime\n";