Welcome to The Daily Denada
'.$message.'
';
my $fancy = $msg->attach(Type => 'multipart/related');
$fancy = $msg->attach(
Type =>'text/html',
# Data =>'Click the following link to confirm your emaildress:
http://daily.denada.dk/subscribe/?key='.$akey.'&action=confirmIf you are not the person asking to be subscribed to The Daily Denada mail, please ignore this message.
You must respond to this message within 14 days or your request will be deleted.',
Data =>$html,
);
$fancy->attach(
Type => 'image/gif',
Id => 'myimage.gif',
Path => '/var/www/virtual/daily.denada.dk/web/siteimages/face4welcomeemail.gif',
);
$msg->send;
# indsæt i DB ..
my $sth = $dbh->prepare("insert into dailymail (rid, added, laststatus, approved, approvalkey) values(?,now(),'conf email sent',?,?)");
$sth->execute($cgi->param('email'), 'no', $akey);
if ($sth->errstr) { print $sth->errstr; }
$sth->finish;
}
} else {
print $cgi->header;
my $t = "
\n";
$t = $t."
\n";
$t = $t."
\n";
$t = $t."If you'd like to receive the Daily Denada by email every day, please enter your emailaddress in the field below. The strip will be sent to you every morning at 5am CET if there is a new strip available. Your email address will not be used for spam, sold to romanians or anyone else for that matter.
\n";
$t = $t."
You will not receive any ads with the strip when you receive it by mail and you can unsubscribe any time you want (after receiving the first email)
\n";
$t = $t."
After entering your address and hitting 'send' you will receive an email with a link you need to click, in order to verify that you are the person subscribing to the list.
\n";
$t = $t."
\n";
$t = $t.start_form(-class=>'emailform',-id=>'emailform');
$t = $t."
Email Address:
".textfield({-class=>'email',-name=>'email'})." ".submit('subscribe')."
\n";
$t = $t."
\n";
# $t = $t."
Verify:
".textfield({-class=>'email',-name=>'emailver',-onchange=>'checkadd(this)'})."
\n";
$t = $t."
\n";
$t = $t.end_form;
$t = $t."
\n";
$t = $t."
You can also subscribe to strip and the comments with your favourite rss-reader by using the links below:
\n";
$t = $t."
\n";
templater("Subscribe to the 'The Daily Denada Strip Mail'",$t);
}
###############################################################################
sub generateID {
my ($np,$npp) = @_;
my $lid = "";
my $aplha = "a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z";
my @aplha = split(" ", $aplha);
my ($r,$j,$i) = 0;
for ($j = 0; $j < $np; $j++) {
$r = int(rand(2));
for ($i = 0; $i < $npp; $i++)
{
if ($r == 1)
{
# // Generate random numbers
$lid .= int(rand(10));
}
else
{
# // Generate random letters
$a = int(rand(52));
$lid .= $aplha[$a];
}
}
}
# så skal vi tjekke om det her ID er brugt tidligere...
#print "checker $lid\n";
if (checkID($lid)) {
#print "returnerer: $lid\n";
return $lid;
} else { $lid = generateID($np,$npp); }
}
sub checkID {
my($i) = @_;
$sth = $dbh->prepare("select * from dailymail where approvalkey = '".$i."' or rid ='".$i."'");
$sth->execute;
my $numrows = $sth->rows;
$sth->finish;
if ($numrows eq 0) {
return 1;
} else { return 0; }
}
sub templater {
my ($title, $message) = @_;
print start_html(
-title=>'The Daily Denada daily mail - '.$title,
-style=>{-src=>'/style.css'},
-head=>[
Link({-rel=>'alternate',-title=>'The Daily Denada',-type=>'application/rss+xml',-href=>'http://daily.denada.dk/rss'}),
Link({-rel=>'alternate',-title=>'Comments for The Daily Denada',-type=>'application/rss+xml',-href=>'http://daily.denada.dk'}) ]);
my $template = Text::Template->new(SOURCE => 'template.tpl') or die "the programmer sucks!: $Text::Template::ERROR";
my $res = $template->fill_in(HASH=> { title => $title, message => $message});
if (defined($res)) { print $res; } else { print "template-failure: $Text::Template::ERROR"; }
print end_html;
}
sub is_valid_email ($) {
my ($addr) = @_;
my $atext = qr/[A-Za-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\+\~]/;
my $dot_atom_text = qr/$atext+(\.$atext+)*/;
my $no_ws_ctl_char = qr/[\x01-\x08\x0b\x0c\x0e-\x1f\x7f]/;
my $qtext_char = qr/([\x21\x23-\x5b\x5d-\x7e]|$no_ws_ctl_char)/;
my $text = qr/[\x01-\x09\x0b\x0c\x0e-\x7f]/;
my $qtext = qr/($qtext_char|\\$text)*/;
my $quoted_string = qr/"$qtext"/;
my $quotedpair = qr/\\$text/;
my $dtext = qr/[\x21-\x5a\x5e-\x7e\x01-\x08\x0b\x0c\x0e-\x1f\x7f]/;
my $dcontent = qr/($dtext|$quotedpair)/;
my $domain_literal = qr/\[(${dcontent})*\]/;
if ( $addr =~ /^($dot_atom_text|$quoted_string)\@($dot_atom_text|$domain_literal)$/ ) {
return 1;
} else {
return 0;
}
}