#!/usr/bin/perl

use		CGI qw(:standard);

# sk 13-07-2006: avoid informative errors to browser 
#use		CGI::Carp(fatalsToBrowser);

BEGIN {
	if ($ENV{'SERVER_NAME'} =~ m"localhost") {
		unshift @INC, "c:/prog/perl/elsnet/cgi-bin/lib";
	} else {
		unshift @INC, "lib";
	}
	require SSI2;
	require Date;
	require paths2;
        require Elsnet::Subs;
	import SSI2;
	import Date;
	import paths2;
        import Elsnet::Subs;
}

# added sk 18-08-2004: check QUERY_STRING for hacks

&checkQUERY();

print header();


my @names			=	param();
my %param			=	();
foreach (@names) {	$param{$_}	=	param($_); }

my $show_event			=	"$cgi_directory/html/show_event.html";
my $file				=	"$events_directory/$param{keywords}";

open(FILE,$file) || &cgiDie("$0: Sorry, couldn't open $file: $!");

print qq{<table border=0>\n};
while ($line = <FILE>) {
	if ($line =~ s/<!-- (.*?) -->\n/$1/) {;
		($key,$value) = split /\t/, $line;
		$info{$key} = $value;
	} else {
		$filetext	=	$line;
		last;
	}
	
}
$filetext	.=	join "", <FILE>;

close FILE;

$data{subject}	=	$info{Subject};
$data{category}	=	$info{Category};
$data{from}		=	$info{From};
$data{email}	= 	$info{Email};
# replace @ by _(on)_ SK 03-09-2008
$data{email} =~ s/@/_(on)_/g ;
$data{received}	=	$info{"Date received"};
$data{deadline}	=	$info{Deadline} || "-";
$data{startdate}=	$info{"Start date"} || "-";
$data{text}		=	$filetext;
# replace mailto and @ in text SK 07-09-2008
$data{text} =~ s/@/_(on)_/g ;
$data{text} =~ s/mailto:/\/messageto.html?/g ;

print ssi($show_event, $root_directory, \%data);

