#!/usr/bin/perl use warnings; use strict; use CGI; use DBI; use XML::Simple; my $config = XMLin('/var/www/config.xml'); my $dbconfig = $config->{database}; my $dbh = DBI->connect("dbi:$dbconfig->{driver}:dbname=$dbconfig->{database}", "$dbconfig->{username}", "$dbconfig->{password}") || die "Can't connect ($DBI::err):$DBI::errstr\n"; my $cgi = new CGI; my $abbr = lc($cgi->param('abbr')) || ''; $abbr =~ s/\/$//; my ($query, $sth); if ($abbr ne '') { $query = "SELECT faqurl FROM projects WHERE lower(abbr)=?"; $dbh = DBI->connect("dbi:$dbconfig->{driver}:dbname=$dbconfig->{database}", "$dbconfig->{username}", "$dbconfig->{password}") || die "Can't connect ($DBI::err):$DBI::errstr\n"; my ($faqurl); $sth = $dbh->prepare($query); $sth->execute($abbr); $sth->bind_columns(\$faqurl); if ($sth->fetch() && $faqurl) { print $cgi->redirect($faqurl); } else { print $cgi->redirect("http://www.dutchpowercows.org/faqs/"); } } else { print $cgi->header( -charset => 'UTF-8' ); print $cgi->start_html( -encoding => 'UTF-8', -style => {'src' => 'http://www.dutchpowercows.org/dpc.css'}, -class => 'popup', -head => $cgi->meta({-http_equiv => 'Content-Type', -content => 'text/html; charset=UTF-8'}), -title => 'Overzicht FAQs' ); print '