11 require '../intl/Sesse::GettextizeTemplates.pm';
16 $start_time = [Time::HiRes::gettimeofday()];
19 our $ccbs_dbdebug = 0;
21 # Set this flag to disable any admin tasks -- it's quite crude, but hey :-)
22 our $ccbs_noadmin = 0;
25 print CGI::header(-type=>'text/html; charset=utf-8');
30 print CGI::header(-status=>'303 See other',
31 -location=>'http://ccbs.sesse.net/' . $location,
32 -type=>'text/html; charset=utf-8');
36 $ccbs_dbdebug = defined(shift) ? 1 : 0;
38 my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=www.positivegaming.com", "ccbs", "GeT|>>B_")
39 or die "Couldn't connect to database";
40 $dbh->{RaiseError} = 1;
45 my ($dbh, $sql, @parms) = @_;
46 my $q = $dbh->prepare($sql)
47 or die "Could not prepare query: " . $dbh->errstr;
49 or die "Could not execute query: " . $dbh->errstr;
53 warn "params=" . join(', ', @parms);
57 while (my $ref = $q->fetchrow_hashref()) {
60 for my $k (sort keys %$ref) {
61 $dbstr .= " " . $k . "=" . $ref->{$k};
72 sub process_template {
73 my ($page, $title, $vars) = @_;
74 $vars->{'page'} = $page;
75 $vars->{'title'} = $title;
76 $vars->{'public'} = $ccbs_noadmin;
77 $vars->{'timetogenerate'} = sprintf "%.3f", Time::HiRes::tv_interval($start_time);
79 POSIX::setlocale( &POSIX::LC_MESSAGES , "en_DK.UTF-8");
80 Locale::gettext::bindtextdomain("ccbs", "po");
81 Locale::gettext::textdomain("ccbs");
84 INCLUDE_PATH => 'templates/',
88 FACTORY => 'Sesse::GettextizeTemplates'
90 my $template = Template->new($config);
93 $template->process('main.tmpl', $vars, \$output)
94 or die $template->error();
102 ccbs::print_header();
103 ccbs::process_template('user-error.tmpl', 'Feil',
104 { message => $msg });
109 user_error("Beklager, databasen står i no-admin-mode.") if ($ccbs_noadmin);
112 $SIG{__DIE__} = sub {
113 # Gosh! Net::Resolver::DNS is brain-damaged.
115 return if $msg =~ m#Win32/Registry.pm#;
117 ccbs::print_header();
118 ccbs::process_template('error.tmpl', 'Internal Server Error',
119 { message => HTML::Entities::encode_entities($msg) });