From: Ian Jackson Date: Wed, 12 Sep 2012 18:32:41 +0000 (+0100) Subject: wip X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=nj-awaymsg.git;a=commitdiff_plain;h=210e7d351f034881e4a5e111a323c0084a0d0c20 wip --- diff --git a/AwayMsg.pm b/AwayMsg.pm index 472850a..3e95f71 100644 --- a/AwayMsg.pm +++ b/AwayMsg.pm @@ -25,6 +25,11 @@ sub www_begin ($$) { $r->header_out("Cache-Control: no-cache"); } +sub hquote ($) { + my ($raw) = @_; + return pack "H*", $raw; +} + sub db_connect () { my $dbf; foreach my $d (@INC) { diff --git a/mason/edit b/mason/edit index 651cb3e..bad80b8 100755 --- a/mason/edit +++ b/mason/edit @@ -15,7 +15,7 @@ my $textid; if (defined $create) { } else { foreach my $k (keys %ARGS) { - if ($k =~ m/^t(\d{0,7})$/) { + if ($k =~ m/^t_(\d{0,7})$/) { $textid= $1; last; } @@ -58,7 +58,7 @@ if (!$tx) { die "no such text $textid"; } % while (my $row = $usedq->fetchrow_hashref()) { -
Use for <% $row->{'emailaddr'} |h %>{'emailaddr'}) %> % if (!$create && $row->{'textid'} eq $textid) { checked>(currently using this message) % } elsif (defined $row->{'textid'}) { diff --git a/mason/main b/mason/main index 55528ee..a9a8817 100755 --- a/mason/main +++ b/mason/main @@ -62,7 +62,7 @@ $sth->execute(); <% $row->{'text'} |h %> -
% } diff --git a/mason/save b/mason/save index a34abe9..1f813c4 100755 --- a/mason/save +++ b/mason/save @@ -42,6 +42,19 @@ my $dinsertq = $dbh->prepare("INSERT INTO texts (textid, desc, subject, text)". " VALUES (?,?,?,?)"); $dinsertq->execute($textid, $desc, $subject, $text); +my $tdeleteq = $dbh->prepare("DELETE FROM addresses WHERE textid = ?"); +$tdeleteq->execute($textid); + +my $tinsertq = $dbh->prepare("INSERT INTO addresses (emailaddr, textid)". + " VALUES (?,?)"); +my $tlistq = $dbh->prepare("SELECT * FROM config"); +$tlistq->execute(); +while (my $row = $tlistq->fetchrow_hashref()) { + if ($ARGS{"u_".hquote($row->{'emailaddr'})}) { +fixme + } +} + db_commit(); <& htmlhead, subpage => "Saved \"$desc\"" &>