11 # Set this flag to disable any admin tasks -- it's quite crude, but hey :-)
12 our $ccbs_noadmin = 0;
15 print CGI::header(-type=>'text/html; charset=utf-8');
20 print CGI::header(-status=>'303 See other',
21 -location=>'http://ccbs.sesse.net/' . $location,
22 -type=>'text/html; charset=utf-8');
26 $ccbs_dbdebug = defined(shift) ? 1 : 0;
28 my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=altersex.samfundet.no", "ccbs", "GeT|>>B_")
29 or die "Couldn't connect to database";
30 $dbh->{RaiseError} = 1;
35 my ($dbh, $sql, @parms) = @_;
36 my $q = $dbh->prepare($sql)
37 or die "Could not prepare query: " . $dbh->errstr;
39 or die "Could not execute query: " . $dbh->errstr;
43 warn "params=" . join(', ', @parms);
47 while (my $ref = $q->fetchrow_hashref()) {
50 for my $k (sort keys %$ref) {
51 $dbstr .= " " . $k . "=" . $ref->{$k};
62 sub process_template {
63 my ($page, $title, $vars) = @_;
64 $vars->{'page'} = $page;
65 $vars->{'title'} = $title;
66 $vars->{'public'} = $ccbs_noadmin;
69 INCLUDE_PATH => 'templates/',
74 my $template = Template->new($config);
77 $template->process('main.tmpl', $vars, \$output)
78 or die $template->error();
87 ccbs::process_template('user-error.tmpl', 'Feil',
93 user_error("Beklager, databasen står i no-admin-mode.") if ($ccbs_noadmin);
97 # Gosh! Net::Resolver::DNS is brain-damaged.
99 return if $msg =~ m#Win32/Registry.pm#;
101 ccbs::print_header();
102 ccbs::process_template('error.tmpl', 'Internal Server Error',
103 { message => HTML::Entities::encode_entities($msg) });