1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
|
#!/usr/bin/perl -w
use strict;
use CGI;
my $cgi = new CGI;
my $email = $cgi->param('unsubscribe');
print $cgi->header();
print $cgi->start_html(-title=>"unsubscribe");
if ( $email eq "" ) {
print $cgi->startform(-action => 'unsubscribe.pl', -method => 'POST');
print "unsubscribe: ".$cgi->textfield(-name=>'unsubscribe',-size=>'50',-maxlength=>'50');
print $cgi->submit("send").$cgi->reset("reset");
}
else {
my ($name, $domain) = split(/@/, $email);
if ( $name eq "" || $domain eq "") {
print "name or domain is empty";
}
elsif ( $name =~ /\W/ && ! $name =~ /[\.-_]/ ) {
print "name contains illegal charakters!";
}
elsif ( $domain =~ /\W/ && ! $domain =~ /[\.-_]/ ) {
print "name contains illegal charakters!";
}
elsif ( length($name) < 3 || length($domain) < 6 ) {
print "This email address is too short";
}
elsif ( ! $domain =~ /[\w\.-_]+\.[\D\D]+/ ) {
print "invalid domain";
}
else {
print "unsubsribing: $email";
open (FILE, "./unsubscribe.txt") or die "cannot create/open unsubscribe.txt!";
prinf FILE $email."\n";
close FILE;
}
}
print $cgi->end_html(); |