#!/usr/bin/perl
# shebang only for color coding, just ignore it m'kay?
use strict;
use vars qw(%get %post %fields %cookie %INTERNAL);

if ($ENV{QUERY_STRING} ne ''){
    for (split /&/, $ENV{QUERY_STRING}) {
	my @keyval = split /=/;
	DecodeURI(@keyval);
	$get{$keyval[0]} = $keyval[1];
    }
}


$INTERNAL{post} = <STDIN>;
if ($INTERNAL{post} ne ''){
    for (split /&/, $INTERNAL{post}) {
	my @keyval = split /=/;
	DecodeURI(@keyval);
	$post{$keyval[0]} = $keyval[1];
    }
}

%fields = %get;
@fields{keys %post} = values %post;
#%fields = (%get, %post);

if ($ENV{HTTP_COOKIE} ne ''){
    for (split /; ?/, $ENV{HTTP_COOKIE}) {
	my @keyval = split /=/;
	$cookie{$keyval[0]} ||= $keyval[1];
    }
}

1;
