11 require '../intl/Sesse::GettextizeTemplates.pm';
16 $start_time = [Time::HiRes::gettimeofday()];
18 POSIX::setlocale( &POSIX::LC_CTYPE , "nb_NO.UTF-8" );
19 POSIX::setlocale( &POSIX::LC_MESSAGES , "nb_NO.UTF-8" );
20 Locale::gettext::bindtextdomain("ccbs", "po");
21 Locale::gettext::textdomain("ccbs");
24 our $ccbs_dbdebug = 0;
26 # Set this flag to disable any admin tasks -- it's quite crude, but hey :-)
27 our $ccbs_noadmin = 0;
29 # Hack to get the non-templatized gettext stuff working
31 return Locale::gettext::gettext(@_);
35 print CGI::header(-type=>'text/html; charset=utf-8');
40 print CGI::header(-status=>'303 See other',
41 -location=>'http://ccbs.sesse.net/' . $location,
42 -type=>'text/html; charset=utf-8');
46 $ccbs_dbdebug = defined(shift) ? 1 : 0;
48 my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=www.positivegaming.com", "ccbs", "GeT|>>B_")
49 or die "Couldn't connect to database";
50 $dbh->{RaiseError} = 1;
55 my ($dbh, $sql, @parms) = @_;
56 my $q = $dbh->prepare($sql)
57 or die "Could not prepare query: " . $dbh->errstr;
59 or die "Could not execute query: " . $dbh->errstr;
63 warn "params=" . join(', ', @parms);
67 while (my $ref = $q->fetchrow_hashref()) {
70 for my $k (sort keys %$ref) {
71 $dbstr .= " " . $k . "=" . $ref->{$k};
82 sub process_template {
83 my ($page, $title, $vars) = @_;
84 $vars->{'page'} = $page;
85 $vars->{'title'} = $title;
86 $vars->{'public'} = $ccbs_noadmin;
87 $vars->{'timetogenerate'} = sprintf "%.3f", Time::HiRes::tv_interval($start_time);
90 INCLUDE_PATH => 'templates/',
94 FACTORY => 'Sesse::GettextizeTemplates'
96 my $template = Template->new($config);
99 $template->process('main.tmpl', $vars, \$output)
100 or die $template->error();
108 ccbs::print_header();
109 ccbs::process_template('user-error.tmpl', _('Error'),
110 { message => $msg });
115 user_error(_("Sorry, the database is in no-admin-mode.")) if ($ccbs_noadmin);
118 $SIG{__DIE__} = sub {
119 # Gosh! Net::Resolver::DNS is brain-damaged.
121 return if $msg =~ m#Win32/Registry.pm#;
123 ccbs::print_header();
124 ccbs::process_template('error.tmpl', _('Internal Server Error'),
125 { message => HTML::Entities::encode_entities($msg) });