getlocaltime.cgi

 


#!/usr/bin/perl

if ($ENV{'REQUEST_METHOD'} eq 'GET')
{
        @pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST')
{
    read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);

    if ($ENV{'QUERY_STRING'})
    {
        @getpairs =split(/&/, $ENV{'QUERY_STRING'});
        push(@pairs,@getpairs);
    }
}
else
{
    print "Content-type: text/html\n\n";
    print "<P>Use Post or Get";
}


($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=gmtime(time);

%zones = ("EST", 5, "CT", 6, "MT", 7, "PT", 8);
$place= $formdata{'place'};
$zone = $formdata{'zone'};
$hour = $hour-$zones{$zone};

if ($hour <= 0) {
	$hour = $hour +24;
	}
	
$min=sprintf("%02d", $min);
$sec=sprintf("%02d", $sec);


print "Content-type: text/html\n\n";
print "According to my server, right now the time in $place is: $hour:$min:$sec";