equal
deleted
inserted
replaced
14 use DBI; |
14 use DBI; |
15 use Template; |
15 use Template; |
16 use File::Basename; |
16 use File::Basename; |
17 use Mail::RFC822::Address qw(valid); |
17 use Mail::RFC822::Address qw(valid); |
18 |
18 |
|
19 sub insert(\%); |
|
20 sub confirm($); |
|
21 sub slurp($); |
|
22 |
|
23 |
19 delete @ENV{grep /PATH$/ => keys %ENV}; |
24 delete @ENV{grep /PATH$/ => keys %ENV}; |
20 $ENV{PATH} = "/usr/bin:/usr/sbin:/bin:/sbin"; |
25 $ENV{PATH} = "/usr/bin:/usr/sbin:/bin:/sbin"; |
21 |
26 |
22 my $DSN = "DBI:SQLite:db.sqlite3"; |
27 my $DSN = "DBI:SQLite:db.sqlite3"; |
23 my $SECRET = "iexaephuwe"; # used for generating the hash |
28 my $SECRET = slurp "./secret"; chomp($SECRET); |
24 my $EXPIRATION = 3600; # the link is valid for 1 hour only |
29 my $EXPIRATION = 3600; # the link is valid for 1 hour only |
25 my $SUBJECT = "Retter packen"; # ASCII only! *used for mail subject* |
30 my $SUBJECT = "Retter packen"; # ASCII only! *used for mail subject* |
26 my %FIELDS = ( |
31 my %FIELDS = ( |
27 MAN => [qw[givenname surname mail]], |
32 MAN => [qw[givenname surname mail]], |
28 OPT => [qw[tel]] |
33 OPT => [qw[tel]] |
36 }, |
41 }, |
37 ); |
42 ); |
38 |
43 |
39 my $DBH = DBI->connect($DSN, undef, undef, {RaiseError=>1}); |
44 my $DBH = DBI->connect($DSN, undef, undef, {RaiseError=>1}); |
40 END { $DBH and $DBH->disconnect } |
45 END { $DBH and $DBH->disconnect } |
41 |
|
42 sub insert(\%); |
|
43 sub confirm($); |
|
44 |
46 |
45 MAIN: { |
47 MAIN: { |
46 |
48 |
47 # Redirect if called without the script name, this avoids |
49 # Redirect if called without the script name, this avoids |
48 # other problems later |
50 # other problems later |
233 $sth->execute(1, $uuid); |
235 $sth->execute(1, $uuid); |
234 $DBH->commit; |
236 $DBH->commit; |
235 |
237 |
236 return %data; |
238 return %data; |
237 } |
239 } |
|
240 |
|
241 sub slurp($) { |
|
242 open(my $_, $_[0]) or die "Can't open $_[0]: $!\n"; |
|
243 local $/ = undef; |
|
244 return <$_>; |
|
245 } |