12 print CGI::header(-type=>'text/html; charset=utf-8');
17 print CGI::header(-status=>'303 See other',
18 -location=>'http://ccbs.sesse.net/' . $location,
19 -type=>'text/html; charset=utf-8');
23 $ccbs_dbdebug = defined(shift) ? 1 : 0;
25 my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=altersex.samfundet.no", "ccbs", "GeT|>>B_")
26 or die "Couldn't connect to database";
27 $dbh->{RaiseError} = 1;
32 my ($dbh, $sql, @parms) = @_;
33 my $q = $dbh->prepare($sql)
34 or die "Could not prepare query: " . $dbh->errstr;
36 or die "Could not execute query: " . $dbh->errstr;
40 warn "params=" . join(', ', @parms);
44 while (my $ref = $q->fetchrow_hashref()) {
47 for my $k (sort keys %$ref) {
48 $dbstr .= " " . $k . "=" . $ref->{$k};
59 sub process_template {
60 my ($page, $title, $vars) = @_;
61 $vars->{'page'} = $page;
62 $vars->{'title'} = $title;
65 INCLUDE_PATH => 'templates/',
70 my $template = Template->new($config);
73 $template->process('main.tmpl', $vars, \$output)
74 or die $template->error();
83 ccbs::process_template('user-error.tmpl', 'Feil',
90 # Gosh! Net::Resolver::DNS is brain-damaged.
92 return if $msg =~ m#Win32/Registry.pm#;
95 ccbs::process_template('error.tmpl', 'Internal Server Error',
96 { message => HTML::Entities::encode_entities($msg) });