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