--- /dev/null
+DirectoryIndex index.pl
--- /dev/null
+body {
+ font-family: georgia, arial, sans-serif;
+ background-color: white;
+}
+* {
+/* border: 1px solid black; */
+}
+.header {
+ margin-bottom: 1em;
+}
+.menu {
+ border-top: 1px solid gray;
+ border-bottom: 1px solid gray;
+ padding-top: 0.5em;
+ padding-bottom: 0.5em;
+ margin-bottom: 1em;
+ text-align: center;
+ background-color: rgb(161,206,222);
+}
+h1 img {
+ vertical-align: middle;
+ margin-left: 1em;
+ margin-right: 1em;
+}
+
+.main {
+ margin-left: 3em;
+}
+/* .main > div, but IE can't handle that :-/ */
+.main div {
+ border-left: 2px solid rgb(78,179,78);
+}
+.main div.msg, .main div.qotd {
+ border: 2px solid red;
+ background-color: rgb(161,206,222);
+ padding: 0.5em;
+ margin-bottom: 0.5em;
+}
+.msgfooter {
+ font-size: smaller;
+ text-align: right;
+}
+.msgfooter input {
+ margin-left: 0.5em;
+}
+
+.main p, .main pre {
+ margin-left: 1em;
+}
+table {
+ border-collapse: collapse;
+ background-color: white;
+ margin-left: 2em;
+ font-size: smaller;
+}
+th, td {
+ border: 1px solid black;
+ padding: 2px;
+}
+th { background-color: rgb(128,229,128); }
+tr.even td { background-color: #ffa; }
+tr.total { border-top: 2px solid black; }
+tr.own { border: 2px solid red; }
+
+a:link, a:hover, th a:link, th a:visited, th a:hover {
+ color: blue;
+}
+a:visited {
+ color: navy;
+}
+
+/* IE sucks! */
+tr.own td, tr.own th { border-top: 2px solid red; border-bottom: 2px solid red; }
+
+.footer {
+ padding-top: 0.5em;
+ margin-top: 1em;
+ font-size: x-small;
+ border-top: 1px solid gray;
+}
--- /dev/null
+package ccbs;
+use Template;
+use CGI;
+use DBI;
+use strict;
+use warnings;
+
+our $ccbs_dbdebug = 0;
+
+sub print_header {
+ print CGI::header(-type=>'text/html; charset=utf-8');
+}
+
+sub db_connect {
+ $ccbs_dbdebug = defined(shift) ? 1 : 0;
+
+ my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=sql.samfundet.no", "ccbsmmeligaen", "Noohos8h")
+ or die "Couldn't connect to database";
+ $dbh->{RaiseError} = 1;
+ return $dbh;
+}
+
+sub db_fetch_all {
+ my ($dbh, $sql, @parms) = @_;
+ my $q = $dbh->prepare($sql)
+ or die "Could not prepare query: " . $dbh->errstr;
+ $q->execute(@parms)
+ or die "Could not execute query: " . $dbh->errstr;
+
+ if ($ccbs_dbdebug) {
+ warn $sql;
+ warn "params=" . join(', ', @parms);
+ }
+
+ my @ret = ();
+ while (my $ref = $q->fetchrow_hashref()) {
+ if ($ccbs_dbdebug) {
+ my $dbstr = "";
+ for my $k (sort keys %$ref) {
+ $dbstr .= " " . $k . "=" . $ref->{$k};
+ }
+ warn $dbstr;
+ }
+ push @ret, $ref;
+ }
+
+ $q->finish;
+ return \@ret;
+}
+
+sub process_template {
+ my ($page, $title, $vars) = @_;
+ $vars->{'page'} = $page;
+ $vars->{'title'} = $title;
+
+ my $config = {
+ INCLUDE_PATH => 'templates/',
+ INTERPOLATE => 1,
+ POST_CHOMP => 1,
+ EVAL_PERL => 1,
+ };
+ my $template = Template->new($config);
+
+ my $output = '';
+ $template->process('main.tmpl', $vars, \$output)
+ or die $template->error();
+
+ print $output;
+}
+
+$SIG{__DIE__} = sub {
+ # Gosh! Net::Resolver::DNS is brain-damaged.
+ my $msg = shift;
+ return if $msg =~ m#Win32/Registry.pm#;
+
+ ccbs::print_header();
+ ccbs::process_template('error.tmpl', 'Internal Server Error',
+ { message => $msg });
+};
+
+1;
--- /dev/null
+#! /usr/bin/perl
+
+use ccbs;
+use strict;
+use warnings;
+
+ccbs::print_header();
+ccbs::process_template('index.tmpl', 'Forside');
--- /dev/null
+[%# vim:set filetype=html: %]
+<div>
+ <p>Velkommen. Tomt foreløpig. :-)</p>
+</div>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="no">
+ <head>
+ <title>[% title %] - CCBS</title>
+ <link rel="stylesheet" type="text/css" href="ccbs.css" />
+ </head>
+ <body>
+ <h1>[% title %]</h1>
+
+ <div class="main">
+[% INCLUDE $page %]
+ </div>
+ </body>
+</html>