#!/usr/bin/perl

# Setup
$TimeZoneOffset = "0"; # Zeitzone von +12 bis -12 (0 für Aus)
# End Setup

read(STDIN, $input, $ENV{'CONTENT_LENGTH'});@pairs = split(/&/, $input);@vars = split(/&/, $ENV{QUERY_STRING});foreach my $var (@vars){my($v,$i) = split(/=/, $var);$v =~ tr/+/ /;$v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;$i =~ tr/+/ /;$i =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;$i =~ s/<!--(.|\n)*-->//g;$INFO{$v} = $i;}$action = $INFO{'a'};

if($TimeZoneOffset ne "0" && $TimeZoneOffset =~ /^\-/i) {
	$TimeZoneOffset =~ s/[^0-9]//g;
	$Times = time() - ($TimeZoneOffset * 3600);
}elsif ($TimeZoneOffset ne "0" && $TimeZoneOffset =~ /^\+/i) {
	$TimeZoneOffset =~ s/[^0-9]//g;
	$Times = time() + ($TimeZoneOffset * 3600);
}elsif ($TimeZoneOffset ne "0") {
	$TimeZoneOffset =~ s/[^0-9]//g;
	$Times = time() + ($TimeZoneOffset * 3600);
}else{
	$Times = time();
}
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Times);

$mon_num = $mon+1;
$hour = "0$hour" if($hour < 10);
$min = "0$min" if($min < 10);
$sec = "0$sec" if($sec < 10);
$year += 1900;
	
$mon_num = "0$mon_num" if($mon_num < 10);
$mday = "0$mday" if($mday < 10);

$thishour = (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,0) [(localtime)[2]];
$thismonth = ("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember")[(localtime)[4]];
$thisday = (Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag)[(localtime)[6]];

if($action eq ""){$action = "dd. mmmm yyyy, hh:nn";}
$action =~ s/hh/$hour/g;
$action =~ s/nn/$min/g;
$action =~ s/ss/$sec/g;
$action =~ s/dddd/$thisday/g;
$action =~ s/dd/$mday/g;
$action =~ s/yyyy/$year/g;
$action =~ s/yy/substr($year,2,4)/eg;
$action =~ s/mmmm/$thismonth/g;
$action =~ s/mm/$mon_num/g;

print "Content-Type: text/html\n\n";
if($INFO{'js'} == 1){
	print "document.write('$action')";
}else{
	print $action;
}
exit(0);
