11 print CGI::header(-type=>'text/html; charset=utf-8');
15 $ccbs_dbdebug = defined(shift) ? 1 : 0;
17 my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=sql.samfundet.no", "ccbs", "GeT|>>B_")
18 or die "Couldn't connect to database";
19 $dbh->{RaiseError} = 1;
24 my ($dbh, $sql, @parms) = @_;
25 my $q = $dbh->prepare($sql)
26 or die "Could not prepare query: " . $dbh->errstr;
28 or die "Could not execute query: " . $dbh->errstr;
32 warn "params=" . join(', ', @parms);
36 while (my $ref = $q->fetchrow_hashref()) {
39 for my $k (sort keys %$ref) {
40 $dbstr .= " " . $k . "=" . $ref->{$k};
51 sub process_template {
52 my ($page, $title, $vars) = @_;
53 $vars->{'page'} = $page;
54 $vars->{'title'} = $title;
57 INCLUDE_PATH => 'templates/',
62 my $template = Template->new($config);
65 $template->process('main.tmpl', $vars, \$output)
66 or die $template->error();
72 # Gosh! Net::Resolver::DNS is brain-damaged.
74 return if $msg =~ m#Win32/Registry.pm#;
77 ccbs::process_template('error.tmpl', 'Internal Server Error',