# HG changeset patch # User heiko # Date 1309807838 -7200 # Node ID fd14fab1744dc1c1cd3d74a731ec3fa2e7dc5b80 # Parent c89c297e5d532b086057f7c8222b7b7da5a50aca [mq]: wip diff -r c89c297e5d53 -r fd14fab1744d conf.example/sender --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf.example/sender Mon Jul 04 21:30:38 2011 +0200 @@ -0,0 +1,2 @@ +# the envelope sender to use +noreply@localhost diff -r c89c297e5d53 -r fd14fab1744d conf.example/subject --- a/conf.example/subject Mon Jul 04 17:26:13 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -# subject line prefix. ASCII ONLY -[Retter packen] diff -r c89c297e5d53 -r fd14fab1744d index.cgi --- a/index.cgi Mon Jul 04 17:26:13 2011 +0200 +++ b/index.cgi Mon Jul 04 21:30:38 2011 +0200 @@ -25,10 +25,12 @@ $ENV{PATH} = "/usr/bin:/usr/sbin:/bin:/sbin"; my $DSN = "DBI:SQLite:var/db.sqlite3"; -my $SECRET = read_conf "conf/secret"; chomp($SECRET); -my $SELF = read_conf "conf/self"; chomp($SELF); -my $EXPIRATION = 60; # the link is valid for XX minutes only -my $SENDMAIL = "/usr/sbin/sendmail -t"; +my $EXPIRATION = 60; # expiration time of the first link +my $SECRET = read_conf "conf/secret"; +my $SELF = read_conf "conf/self"; +my $SENDER = read_conf "conf/sender"; +my $SENDMAIL = "/usr/sbin/sendmail -f $SENDER -t"; + my %FIELDS = ( MAN => [qw[givenname surname mail]], OPT => [qw[tel]] @@ -36,7 +38,6 @@ my %ttconfig = ( INCLUDE_PATH => "templates", - DEBUG => 1, ); my $DBH = DBI->connect($DSN, undef, undef, {RaiseError=>1}); @@ -79,12 +80,14 @@ to => scalar(param("mail")), url => "$SELF/$xxx.tmp"}, $sendmail) or die $tt->error(); - close($sendmail); + close($sendmail) + or die "problem sending mail to " + . param("mail"); $sent = param("mail"); } } - $tt->process("access.tpl", { + $tt->process("html.access.tpl", { sent => $sent, warn => %warn ? \%warn : undef, expires => $EXPIRATION, @@ -107,7 +110,7 @@ time() - $time < (60 * $EXPIRATION) or die "EXPIRED"; }; if ($@) { - $tt->process("denied.tpl", { + $tt->process("html.denied.tpl", { url => $SELF, }) or die $tt->error(); exit 0; @@ -127,7 +130,7 @@ or die $tt->error(); close($sendmail); - $tt->process("confirm.tpl", { + $tt->process("html.confirm.tpl", { confirmed => $confirmed, error => delete $data{error}, value => \%data}) or die $tt->error(); @@ -192,7 +195,7 @@ close($sendmail); - $tt->process("form.ack.tpl", { + $tt->process("html.form.ack.tpl", { value => \%value, timestamp => $r{timestamp}, uuid => $r{uuid}, @@ -203,7 +206,7 @@ ## Formular - $tt->process("form.tpl", { + $tt->process("html.form.tpl", { warn => %warn ? \%warn : undef, value => { givenname => scalar param("givenname"), @@ -272,8 +275,10 @@ } sub read_conf($) { - open(my $_, $_[0]) or die "Can't open $_[0]: $!\n"; local $/ = undef; + open(my $f, $_[0]) or die "Can't open $_[0]: $!\n"; + my $_ = <$f>; s/^#.*//mg; - return <$_>; + /^\s*(.*?)\s*$/s; + return $1; } diff -r c89c297e5d53 -r fd14fab1744d templates/access.tpl --- a/templates/access.tpl Mon Jul 04 17:26:13 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -[%INCLUDE "head"%] - -[%IF !sent%] - - Schön, daß Du Dich anmelden möchtest. Um Mißbrauch zu werden wir Dir - jetzt einen Link zusenden, den Du für die Anmeldung verwenden - kannst. - -
- Bitte gib dafür eine Mailadresse an, auf der Du - in den nächsten [%expires%] Minuten erreichbar bist. - Diese Adresse wird nirgendwo gespeichert. - -
- -[%ELSE%] - - Vielen Dank. Eine Mail mit einem Anmeldelink wurde an Deine - Mailadresse [%sent%] geschickt. Der Link ist [%expires%] - Minuten gültig. Diese Adresse wurde von uns nicht gespeichert. - -[%END%] - -[%INCLUDE "foot"%] diff -r c89c297e5d53 -r fd14fab1744d templates/confirm.tpl --- a/templates/confirm.tpl Mon Jul 04 17:26:13 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -[%INCLUDE "head"%] - -[%IF error%] - -Vorname: | [%value.givenname%] |
Name: | [%value.surname%] |
Mail: | [%value.mail%] |
Telefon: | [%value.tel%] |
-Solltest Du weitere Fragen haben, kontaktiere bitte -[%MAILTO%]. - -[%INCLUDE "foot"%] diff -r c89c297e5d53 -r fd14fab1744d templates/denied.tpl --- a/templates/denied.tpl Mon Jul 04 17:26:13 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -[%INCLUDE "head"%] - -
-Tut uns leid, die angegebene URL oder Session existiert nicht oder nicht -mehr. Bitte versuche es über -[%url%] noch einmal. - -
-Danke für Dein Verständnis. - -[%INCLUDE "foot"%] diff -r c89c297e5d53 -r fd14fab1744d templates/foot --- a/templates/foot Mon Jul 04 17:26:13 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -