--- /dev/null
+module AwayMsg;
+
+package AwayMsg;
+use strict;
+use warnings;
+
+BEGIN {
+ use Exporter ();
+ our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+ $VERSION = 1.00;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(&db_connect $dhb);
+ %EXPORT_TAGS = ( );
+ @EXPORT_OK = qw();
+}
+
+sub db_connect () {
+ my $h = DBI->connect("dbi:SQLite:away.db",
+ { AutoCommit=>0,
+ RaiseError=>1, ShowErrorStatement=>1
+ })
+ or die "$DBI:errstr ?";
+
+ $dbh->do("BEGIN");
+
+ $dbh->do("CREATE TEMPORARY TABLE config (".
+ " emailaddr TEXT PRIMARY KEY NOT NULL,".
+ " username TEXT NOT NULL,".
+ " forwardfile TEXT NOT NULL".
+ ")");
+
+ open C, "config" or die $!;
+ while (<C>) {
+ s/^\s+//;
+ next if m/^\#/;
+ chomp or die;
+ s/\s+$//;
+ my @s = split;
+ die "$_ ?" unless @s==3;
+ $dbh->do("INSERT INTO config".
+ " (emailaddr, username, forwardfile)".
+ " VALUES (?,?,?)",
+ {}, @s);
+ }
+ $dbh->do("COMMIT");
+
+ return $h;
+}
--- /dev/null
+nj@hemmel.com nickj .forward
+nj@cumbriancef.com nickj .forward
--- /dev/null
+<%doc>
+<%/doc>
+<%init>
+use AwayMsg;
+<html lang="en"><head>
+<title>Email "out of office" setup</title>
+</head><body>
+<h1>Email "out of office" setup</h1>
+<h2>Our email addresses</h2>
+
+
+<%perl>
+my %row;
+my $sth = $dbh->prepare("SELECT emailaddr, textid, expires"
+ " FROM schema
+ " RIGHT JOIN addresses USING (emailaddr)".
+ " JOIN texts USING (textid)",
+ " ORDER BY emailaddr");
+</%perl>
+
+<table>
+<tr>
+<td>Address</td>
+<td>O-o-o status</td>
+<td>Which message?</td>
+<td>Expiry date</td>
+</tr><tr>
+% while ($row= $sth->fetchrow_hashref()) {
+<td><% $row->{'emailaddr'} |h %></td>
+% if (defined $row->{'textid'}) {
+% my $expiry = expires2timet($row->{'expires'});
+% if ($expiry > time) {
+<td>active</td>
+<td><% $row->{'textid'} |h %></td>
+<td><% $row->{'expires'} |h %></td>
+<td>
--- /dev/null
+
+CREATE TABLE texts (
+ textid INTEGER PRIMARY KEY NOT NULL,
+ name TEXT NOT NULL,
+ subject TEXT NOT NULL,
+ text TEXT NOT NULL,
+ expires TEXT
+ );
+
+CREATE TABLE addresses (
+ emailaddr TEXT PRIMARY KEY NOT NULL,
+ textid INTEGER
+ );
+