X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=AwayMsg.pm;h=472850a81149ae3bcb0d5fd0e5b0ee4e07f8236c;hb=c57e2e54c4b7e03d882f6fb503653427c26cbe5b;hp=483345524ee2dedb1eae5678b601e78e97494b70;hpb=0652dacb9b7ebbdd9c5ec7502ee5a5533a22cdc8;p=nj-awaymsg.git diff --git a/AwayMsg.pm b/AwayMsg.pm index 4833455..472850a 100644 --- a/AwayMsg.pm +++ b/AwayMsg.pm @@ -12,7 +12,7 @@ BEGIN { our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); - @EXPORT = qw(db_connect db_commit expires2timet + @EXPORT = qw(db_connect db_commit www_begin $dbh); %EXPORT_TAGS = ( ); @EXPORT_OK = qw(); @@ -20,16 +20,21 @@ BEGIN { our ($dbh); +sub www_begin ($$) { + my ($r,$m) = @_; + $r->header_out("Cache-Control: no-cache"); +} + sub db_connect () { my $dbf; foreach my $d (@INC) { - $dbf = "$d/away.db"; + $dbf = "$d/data/away.db"; if (stat $dbf) { chdir($d) or die $!; last; } } - $dbh = DBI->connect("dbi:SQLite:away.db", + $dbh = DBI->connect("dbi:SQLite:$dbf",'','', { AutoCommit=>0, RaiseError=>1, ShowErrorStatement=>1 }) @@ -47,23 +52,11 @@ sub nooutput ($) { } } -sub expires2timet ($) { - my ($str) = @_; - if ($str eq '') { - return undef; - } - open F, "-|", qw(date -d),'$str',qw(+%s) or die $!; - my $dtime = ; - $?=0; $!=0; close F or die "$? $!"; - $dtime =~ m/^\d+$/ or die "$dtime ?"; - return $dtime+0; -} - sub db_commit () { nooutput("SELECT * FROM addresses LEFT JOIN config". " USING (emailaddr) WHERE forwardfile IS NULL"); nooutput("SELECT * FROM addresses LEFT JOIN texts". - " USING (textid) WHERE name IS NULL"); + " USING (textid) WHERE desc IS NULL"); $dbh->do("COMMIT"); }