$cgi = CGI->new();
$action = $cgi->param('a');
my %dispatch = (
home => sub { \&home(); },
donate => sub { \&donate(); },
news => sub { \&news(); },
faq => sub { \&faq(); },
dl => sub { \&download(); },
bugs => sub { \&bugs(); },
# ... and so on
);
if (defined $action) {
$action =~ s/[^A-Za-z0-9 ]*/home/g;
}
&begin_page();
$action = HTML::Entities::encode($action);
$action = $cgi->param('a')
&& $dispatch{$cgi->param('a')}
|| $dispatch{'home'};
$action->();
&end_page();
sub home {
my $template = HTML::Template->new(
die_on_bad_params => '0',
filename => 'home.tmpl');
my $content = $template->output;
print $content;
}
####
my $template = HTML::Template->new(
die_on_bad_params => '0',
filename => 'news.tmpl');
my $latest_news = read_file('latest_news');
$template->param(LATEST_NEWS => $latest_news);
my $content = $template->output;
print $content;
##
##
##
##
sub home {
my $template = HTML::Template->new(
die_on_bad_params => '0',
filename => 'home.tmpl');
}
sub donate {
my $template = HTML::Template->new(
die_on_bad_params => '0',
filename => 'donate.tmpl');
}
sub news {
my $template = HTML::Template->new(
die_on_bad_params => '0',
filename => 'news.tmpl');
}
sub faq {
my $template = HTML::Template->new(
die_on_bad_params => '0',
filename => 'faq.tmpl');
}