11 print CGI::header(-type=>'application/xhtml+xml; charset=utf-8');
16 print CGI::header(-status=>'303 See other',
17 -location=>'http://ccbs.sesse.net/' . $location,
18 -type=>'text/html; charset=utf-8');
22 $ccbs_dbdebug = defined(shift) ? 1 : 0;
24 my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=sql.samfundet.no", "ccbs", "GeT|>>B_")
25 or die "Couldn't connect to database";
26 $dbh->{RaiseError} = 1;
31 my ($dbh, $sql, @parms) = @_;
32 my $q = $dbh->prepare($sql)
33 or die "Could not prepare query: " . $dbh->errstr;
35 or die "Could not execute query: " . $dbh->errstr;
39 warn "params=" . join(', ', @parms);
43 while (my $ref = $q->fetchrow_hashref()) {
46 for my $k (sort keys %$ref) {
47 $dbstr .= " " . $k . "=" . $ref->{$k};
58 sub process_template {
59 my ($page, $title, $vars) = @_;
60 $vars->{'page'} = $page;
61 $vars->{'title'} = $title;
64 INCLUDE_PATH => 'templates/',
69 my $template = Template->new($config);
72 $template->process('main.tmpl', $vars, \$output)
73 or die $template->error();
82 ccbs::process_template('user-error.tmpl', 'Feil',
89 # Gosh! Net::Resolver::DNS is brain-damaged.
91 return if $msg =~ m#Win32/Registry.pm#;
94 ccbs::process_template('error.tmpl', 'Internal Server Error',