11 require '../intl/Sesse::GettextizeTemplates.pm';
13 require '../config.pm';
14 -r '../config.local.pm' and require '../config.local.pm';
16 POSIX::setlocale( &POSIX::LC_CTYPE , $ccbs::config::lang );
17 POSIX::setlocale( &POSIX::LC_MESSAGES , $ccbs::config::lang );
18 Locale::gettext::bindtextdomain("ccbs", "po");
19 Locale::gettext::textdomain("ccbs");
24 $start_time = [Time::HiRes::gettimeofday()];
27 # Hack to get the non-templatized gettext stuff working
29 return Locale::gettext::gettext(@_);
33 print CGI::header(-type=>'text/html; charset=utf-8');
38 print CGI::header(-status=>'303 See other',
39 -location=>'http://ccbs.sesse.net/' . $location,
40 -type=>'text/html; charset=utf-8');
44 my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=www.positivegaming.com", "ccbs", "GeT|>>B_")
45 or die "Couldn't connect to database";
46 $dbh->{RaiseError} = 1;
51 my ($dbh, $sql, @parms) = @_;
52 my $q = $dbh->prepare($sql)
53 or die "Could not prepare query: " . $dbh->errstr;
55 or die "Could not execute query: " . $dbh->errstr;
57 if ($config::ccbs::dbdebug) {
59 warn "params=" . join(', ', @parms);
63 while (my $ref = $q->fetchrow_hashref()) {
64 if ($config::ccbs::dbdebug) {
66 for my $k (sort keys %$ref) {
67 $dbstr .= " " . $k . "=" . $ref->{$k};
78 sub process_template {
79 my ($page, $title, $vars) = @_;
80 $vars->{'page'} = $page;
81 $vars->{'title'} = $title;
82 $vars->{'public'} = $config::ccbs::noadmin;
83 $vars->{'timetogenerate'} = sprintf "%.3f", Time::HiRes::tv_interval($start_time);
86 INCLUDE_PATH => 'templates/',
90 FACTORY => 'Sesse::GettextizeTemplates'
92 my $template = Template->new($config);
95 $template->process('main.tmpl', $vars, \$output)
96 or die $template->error();
104 ccbs::print_header();
105 ccbs::process_template('user-error.tmpl', _('Error'),
106 { message => $msg });
111 user_error(_("Sorry, the database is in no-admin-mode.")) if ($config::ccbs::noadmin);
114 $SIG{__DIE__} = sub {
115 # Gosh! Net::Resolver::DNS is brain-damaged.
117 return if $msg =~ m#Win32/Registry.pm#;
119 ccbs::print_header();
120 ccbs::process_template('error.tmpl', _('Internal Server Error'),
121 { message => HTML::Entities::encode_entities($msg) });