#!/usr/bin/perl -w
#######################################################
# Email Management System
# Created by Aaron Anderson
# Contact me at: sulfericacid@qwest.net
#######################################################
use strict;
use warnings;
use POSIX;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
# You are requested not to change any configurations in this file.
# Everything is setup to function as-is, any tamporing may damage
# the script.
require SDBM_File;
my %emails;
my $snail = "snail.dbm"; #change to location of snail mail database
my $list = "mylist.dbm"; #change to location of email database
my $adminmail = 'admin@test.com';
my $sendmail = "/usr/lib/sendmail";
tie %emails, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644;
if ( !tied %emails ) {
print "database unsuccessful $!.\n";
}
print header, start_html('Email Management');
if(param()){
my $email = param('email');
my $name = param('name');
my $add1 = param('add1');
my $add2 = param('add2');
my $city = param('city');
my $zip = param('zip');
my $country = param('country');
if (($name) && ($email)) {
if (exists $emails{$email}) {
print "
Email already exists in mailing list";
} else {
$name =~ s/<\;/g;
$add1 =~ s/<\;/g;
$add2 =~ s/<\;/g;
$city =~ s/<\;/g;
$zip =~ s/<\;/g;
$country =~ s/<\;/g;
$name =~ s/:/&\#58\;/g;
$add1 =~ s/:/&\#58\;/g;
$add2 =~ s/:/&\#58\;/g;
$city =~ s/:/&\#58\;/g;
$zip =~ s/:/&\#58\;/g;
$country =~ s/:/&\#58\;/g;
my $info = join("::", $name, $add1, $add2, $city, $zip, $country);
$emails{$email} = $info;
print "Your information was submitted!";
}
} else {
if ($name) {
print "Your email address was missing";
} elsif ($email) {
print "name is missing";
} else {
print "You can't submit an empty form";
}
}
}
my $name = param('name');
my $email = param('email');
my $add1 = param('add1');
my $add2 = param('add2');
my $city = param('city');
my $zip = param('zip');
my $country = param('country');
print <<"END";
END
print end_html();
####
#!/usr/bin/perl -w
#######################################################
# Email Management System
# Created by Aaron Anderson
# Contact me at: sulfericacid@qwest.net
#######################################################
use strict;
use warnings;
use POSIX;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
# You are requested not to change any configurations in this file.
# Everything is setup to function as-is, any tamporing may damage
# the script.
require SDBM_File;
my %emails;
my %snailmail;
my $snail = "snail.dbm"; #change to location of snail mail database
my $list = "mylist.dbm"; #change to location of email database
my $adminmail = 'admin@test.com';
my $sendmail = "/usr/lib/sendmail";
tie %emails, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644;
if ( !tied %emails ) {
print "database unsuccessful $!.\n";
}
tie %snailmail, 'SDBM_File', $snail, O_CREAT | O_RDWR, 0644;
if ( !tied %snailmail ) {
print "database unsuccessful $!.\n";
}
print header, start_html('Email Management');
print <<"END";
END
if(param())
{
my $email = param('email');
if(exists $emails{$email})
{
delete $emails{$email};
print "You were removed from our list.";
exit;
}
else
{
print "Your email address was not found. Please check the spelling.";
exit;
}
}
print end_html();
####
#!/usr/bin/perl
#######################################################
# Email Management System
# Created by Aaron Anderson
# Contact me at: sulfericacid@qwest.net
#######################################################
use strict;
use warnings;
use POSIX;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use SDBM_File;
######################################
# You may need to configure the following
######################################
my $password = "test";
## Set the above to whatever you want the admin password to be
my $url = "http://sulfericacid.perlmonk.org/rac/rac/secure.pl?lookup=";
## The above is a link to your secure.pl file. Change the url but it must be secure.pl?lookup= at the end
######################################
# Please do not configure anything blow this line
######################################
my $cookiename = "login";
my $favorite = param('flavor');
my $tasty = cookie($cookiename);
my $pass = url_param('pass');
my $edituser = url_param('lookup');
my %emails;
my $emails = "mylist.dbm"; #change to location of snail mail database
my $lookup = url_param('lookup');
tie %emails, 'SDBM_File', $emails, O_CREAT | O_RDWR, 0644;
if ( !tied %emails ) {
print "database unsuccessful $!.\n";
}
# No cookie, so if no favourite value, print new form
unless ($tasty eq $password)
{
print header(-expires=>'now'), start_html("Denied");
print "DENIED";
exit;
}
print header();
print start_html('Email Management- Address lookup');
#################################################
# User update checking
#################################################
if (param('update'))
{
my $name = param('name');
my $email = param('email');
my $add1 = param('add1');
my $add2 = param('add2');
my $city = param('city');
my $zip = param('zip');
my $country = param('country');
if($email && $name)
{
if ( exists $emails{$email} && $lookup ne $email)
{
print "This email address is already being used, please select another.";
}
else
{
my $info = join("::", $name, $add1, $add2, $city, $zip, $country);
delete $emails{$edituser};
$emails{$email} = "$info";
print "Updated!";
print "";
#exit;
}
}
else
{
print "A name and email address are required.";
}
}
#################################################
# Edit/Delete button checking
#################################################
if (param('delete'))
{
delete $emails{$edituser};
print "User information was deleted!";
exit;
}
if (param('edit'))
{
my ($name, $add1, $add2, $city, $zip, $country) = split(/::/, $emails{$edituser});
print start_form(), table(
Tr(
td("Name: "),
td(
textfield(
-name => 'name',
-default =>"$name",
-size => 40
)
)
),
Tr(
td("Email: "),
td(
textfield(
-name => 'email',
-default =>"$edituser",
-size => 40
)
)
),
Tr(
td("Address 1: "),
td(
textfield(
-name => 'add1',
-default =>"$add1",
-size => 40
)
)
),
Tr(
td("Address 2: "),
td(
textfield(
-name => 'add2',
-default =>"$add2",
-size => 40
)
)
),
Tr(
td("City/State: "),
td(
textfield(
-name => 'city',
-default =>"$city",
-size => 40
)
)
),
Tr(
td("Zip: "),
td(
textfield(
-name => 'zip',
-default =>"$zip",
-size => 40
)
)
),
Tr(
td("Country: "),
td(
textfield(
-name => 'country',
-default =>"$country",
-size => 40
)
)
),
Tr( td(), td(submit('update')) ),
),
end_form();
exit;
}
#################################################
# Determine if user is found in database, if so print user data and form buttons
#################################################
if ($edituser)
{
if (exists $emails{$edituser})
{
my ($name, $add1, $add2, $city, $zip, $country) = split(/::/, $emails{$edituser});
my $email = $emails{$_};
print "Address information for $name";
print "";
print "$name ";
if ($add1)
{
print "$add1 ";
}
if ($add2 ne "") {
print "$add2 ";
}
if ($city)
{
print "$city ";
}
if ($zip)
{
print "$zip ";
}
if ($country)
{
print "$country ";
}
if ($edituser)
{
print " $edituser ";
}
print " | ";
print start_form(),
submit('edit'),
end_form();
print start_form(),
submit('delete'),
end_form();
print " |
";
exit;
}
else
{
print "User does not exist";
exit;
}
}
#########################################################
# EDIT user information settings
#########################################################
if (param('edit'))
{
print "Edit";
exit;
}
#########################################################
# Main page prints below -- User List
#########################################################
my $count = "0";
foreach (keys %emails)
{
++$count;
}
print "User List: ($count)
";
foreach (reverse sort keys %emails) {
my ($name, $add1, $add2, $city, $zip, $country) = split(/::/, $emails{$_});
print <<"END";
$name
END
}
exit;
####
#!/usr/bin/perl
#######################################################
# Email Management System
# Created by Aaron Anderson
# Contact me at: sulfericacid@qwest.net
#######################################################
########################################
# You may need to configure the following
########################################
my $pw = "test";
## Change the above to the administrator password
my $adminmail = "admin\@test.com";
## Change the above to the administrator email address (this appears as a Reply-To to the emails you send).
## The \ before the @ is NOT optional
my $sendmail = "/usr/lib/sendmail";
## Change the above to the location of sendmail on your server
my $unsub = "list-add.pl"; # unsub link
## Change the above to the location of list-rem.pl on your server
########################################
# Please do not alter anything below this line
########################################
use strict;
use warnings;
use POSIX;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
require SDBM_File;
my $cookiename = "login";
my $favorite = param('flavor');
my $tasty = cookie($cookiename);
my $pass = url_param('pass');
my $edituser = url_param('lookup');
my (%sig, %emails);
my $sigsave = "sig.dbm";
my $list = "mylist.dbm";
# First check if we saved a cookie last time
if($tasty)
{
print header(-expires=>'now'),
start_html("Email Control Panel");
my %snailmail;
my $lookup = url_param('lookup');
my $edituser = url_param('edit');
my %snailmail;
tie %emails, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644;
if ( !tied %emails ) {
print "database unsuccessful $!.\n";
}
tie %sig, 'SDBM_File', $sigsave, O_CREAT | O_RDWR, 0644;
if ( !tied %sig ) {
print "database unsuccessful $!.\n";
}
####################################################
# Save signature if requested
####################################################
if (param('save')) {
$sig{'default'} = param('signature');
}
###################################################
# Form checking
###################################################
if ( param('submit') ) {
# rid ourselves from those nasty params
my $message = param('message');
my $password = param('password');
my $subject = param('subject');
my $signature = param('signature');
my $save = param('save');
my $use = param('use');
my $time = localtime;
if ( $message eq "" || $subject eq "" ) {
print "Your subject or email content was missing.\n";
#exit;
}
else {
if ( $save eq "yes" ) {
print "
";
print "Saving to database...
\n";
$sig{'default'} = $signature;
$sig{'stored'} = $sig{'default'};
print "Your Signature has been saved.
\n";
}
print "
\n";
foreach(keys %emails) {
my ($name, $add1, $add2, $city, $zip, $country) = split(/::/, $emails{$_});
# Email Subs, special commands
my $editmes = $message; # let's not edit $message
$editmes =~ s/\[name\]/$name/g; #[name] = user name
$editmes =~ s/\[time\]/$time/g; #[time] = time sent
$editmes =~ s/\[unsub\]/$unsub/g; #[unsub] = unsubscribe email
my $editsig = $signature; # let's not edit $signature
$editsig =~ s/\[name\]/$name/g; #[name] = user name
$editsig =~ s/\[time\]/$time/g; #[time] = time sent
$editsig =~ s/\[unsub\]/$unsub/g; #[unsub] = unsubscribe email
my $editsub = $subject; # let's not edit $subject
$editsub =~ s/\[name\]/$name/g; # [name] = user name
open( MAIL, "| $sendmail -t" );
print MAIL "To: $_\n";
print MAIL "From: $adminmail\n";
print MAIL "Subject: $editsub\n\n";
print MAIL "$editmes\n";
if ($use ne "" && $signature ne "" ) {
print MAIL "$editsig\n";
}
print MAIL ".\n";
close(MAIL);
}
my $time = localtime;
print "Email successfully sent on $time";
}
}
###################################################
# Begin printing everything
###################################################
print <<"ALL";
ALL
print " ";
print end_html();
exit;
}
# No cookie, so let's print a new form
unless ($favorite eq "$pw")
{
print header(-expires=>'now'), start_html("Email Management- Administrator Login"),
hr(), start_form(),
p("Please enter your password: ", textfield("flavor",$tasty)),
end_form(), hr();
if (param())
{
if ($favorite ne "$pw")
{
print "Wrong password!";
exit;
}
exit;
}
exit;
}
# Favourite value was '$pass', save cookie to browser
my $cookie = cookie(
-NAME => $cookiename,
-VALUE => $favorite,
#-PATH => "/",
-EXPIRES => "+2y",
);
print header(-COOKIE => $cookie, -expires=>'now');
print start_html("Email Control Panel");
tie %emails, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644;
if ( !tied %emails ) {
print "database unsuccessful $!.\n";
}
tie %sig, 'SDBM_File', $sigsave, O_CREAT | O_RDWR, 0644;
if ( !tied %sig ) {
print "database unsuccessful $!.\n";
}
###################################################
# Begin printing everything
###################################################
print <<"ALL";
ALL
print end_html();
exit;