--- a/index.cgi Fri Jul 01 16:20:17 2011 +0200
+++ b/index.cgi Fri Jul 01 16:25:21 2011 +0200
@@ -16,11 +16,16 @@
use File::Basename;
use Mail::RFC822::Address qw(valid);
+sub insert(\%);
+sub confirm($);
+sub slurp($);
+
+
delete @ENV{grep /PATH$/ => keys %ENV};
$ENV{PATH} = "/usr/bin:/usr/sbin:/bin:/sbin";
my $DSN = "DBI:SQLite:db.sqlite3";
-my $SECRET = "iexaephuwe"; # used for generating the hash
+my $SECRET = slurp "./secret"; chomp($SECRET);
my $EXPIRATION = 3600; # the link is valid for 1 hour only
my $SUBJECT = "Retter packen"; # ASCII only! *used for mail subject*
my %FIELDS = (
@@ -39,9 +44,6 @@
my $DBH = DBI->connect($DSN, undef, undef, {RaiseError=>1});
END { $DBH and $DBH->disconnect }
-sub insert(\%);
-sub confirm($);
-
MAIN: {
# Redirect if called without the script name, this avoids
@@ -235,3 +237,9 @@
return %data;
}
+
+sub slurp($) {
+ open(my $_, $_[0]) or die "Can't open $_[0]: $!\n";
+ local $/ = undef;
+ return <$_>;
+}