unsubscribe button
This commit is contained in:
parent
ba4133170a
commit
f16b3b0b0f
|
@ -79,7 +79,9 @@ SUB: while (my $sub = $sth->fetchrow_hashref) {
|
||||||
],
|
],
|
||||||
body => "Hi,\n\nThe Tor node with the fingerprint '"
|
body => "Hi,\n\nThe Tor node with the fingerprint '"
|
||||||
. $sub->{"fp"} . "' " .
|
. $sub->{"fp"} . "' " .
|
||||||
($status == 1 ? "is down." : "has disappeared from the Tor network!"),
|
($status == 1 ? "is down." : "has disappeared from the Tor network!")
|
||||||
|
. "\n\n----------\nTo unsubscribe, click this link:\n"
|
||||||
|
. $config->{"baseurl"}."/unsubscribe?id=$sub->{id}&s=$sub->{secret}",
|
||||||
);
|
);
|
||||||
my $trans = new Email::Sender::Transport::SMTPS (
|
my $trans = new Email::Sender::Transport::SMTPS (
|
||||||
host => $config->{mail}->{host},
|
host => $config->{mail}->{host},
|
||||||
|
|
|
@ -166,6 +166,33 @@ while ($request->Accept() <= 0) {
|
||||||
$content = read_file("$Bin/confirm.tt");
|
$content = read_file("$Bin/confirm.tt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case (/^\/unsubscribe\?id=[0-9]+&s=[a-z]{16}$/) {
|
||||||
|
if ($ENV{REQUEST_URI} =~ /^\/unsubscribe\?id=([0-9]+)&s=([a-z]{16})$/) {
|
||||||
|
my $id = $1;
|
||||||
|
my $secret = $2;
|
||||||
|
my $q = $dbh->prepare("select * from users where id=? and secret=?");
|
||||||
|
$q->bind_param(1, $id);
|
||||||
|
$q->bind_param(2, $secret);
|
||||||
|
$q->execute;
|
||||||
|
my $href = $q->fetchrow_hashref;
|
||||||
|
|
||||||
|
if ($q->rows != 1) {
|
||||||
|
$code = "Status: 403 Forbidden";
|
||||||
|
my $tt = read_file("$Bin/error.tt");
|
||||||
|
$content = ${ $tmpl->render($tt, {err => 403}) };
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
|
$q->finish;
|
||||||
|
$q = $dbh->prepare("delete from users where id=? and secret=?");
|
||||||
|
$q->bind_param(1, $id);
|
||||||
|
$q->bind_param(2, $secret);
|
||||||
|
$q->execute;
|
||||||
|
$q->finish;
|
||||||
|
|
||||||
|
$content = read_file("$Bin/unsubscribe.tt");
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
my $tt = read_file("$Bin/error.tt");
|
my $tt = read_file("$Bin/error.tt");
|
||||||
$content = ${ $tmpl->render($tt, {err => 404}) };
|
$content = ${ $tmpl->render($tt, {err => 404}) };
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<h1>Thank you</h1>
|
||||||
|
You are no longer subscribed.
|
Loading…
Reference in New Issue