#!/usr/bin/perl ######################################################## # # # DO NOT REMOVE THIS HEADER # # # ######################################################## # # # COPYRIGHT NOTICE # # Copyright 1999 Thomas J. Delorme # # All Rights Reserved. # # # # For support with EasyList, go to # # # # Psychosys Perl # # at # # http://getperl.virtualave.net # # # # By using this script you agree to indemnify me from # # any liability that might arise from its use. # # # # Redistributing\selling the code for this program # # without prior written consent is expressly # # forbidden. # # # ######################################################## # # # EasyList v1.3 by Thomas J. Delorme # # E-mail : delorme@getperl.virtualave.net # # Created : Saturday August 14, 1999 # # Revisions : See readme.txt # # # ######################################################## # # # If this script doesn't work for you try # # adjusting the first line above to # # #!/usr/local/bin/perl # # DO NOT REMOVE THE # OR ! or add any spaces. # # # ######################################################## ############ ADJUST THESE VARIABLES ################ # You may not need to change the $mailprog variable. # Try it as is first. If it doesn't work try putting a # in # front of the first line below and remove the # on the # second line. If that fails, try the removing the # on # the third line and put a # in front of the other two. # If that fails, ask your administrator where the sendmail # program is on your system. $mailprogram = '/usr/sbin/sendmail'; # $mailprogram = '/usr/lib/sendmail'; # $mailprogram = '/usr/bin/sendmail'; # Edit this one to achieve color matching with the rest # of your site - this would be what goes in your html tag. # # NOTE : DO NOT use " ' # < or > # Use the below example to help you with what is allowed $body = 'bgcolor=000000 text=ffffff link=fac700 alink=ff0000 vlink=ff0000 background="gstback.gif"'; # Name of your mailing list $listname = 'Pop Rox Music Newsletter'; # Describe how often will you send e-mail to your mailing list? - No CAPS $listcycle = 'about once a month'; # Name of your website $mysite = 'Pop Rox'; # URL of your homepage or anywhere you want to send someone after the form $homepage = 'http://www.domkus.com/poprox/home.html'; # Path to e-mail address database - include the filename $emailpath = 'easylist.log'; # URL of this script - include the filename $scripturl = 'http://www.domkus.com/poprox/cgi/maillist/easylist.cgi'; # Password to access admin screen - CHANGE THIS IMMEDIATELY $adminpass = 'popadmin'; # Do you want to be notified if anyone tries to guess your password? $hacknotify = 'yes'; # Change this to your e-mail address # If you're not using PERL 5 on your system ie. version 4 # or earlier, you will need to escape the @ sign like this : # ( \@ instead of just @ ) # # Perl 5 users should be able to enter their straight e-mail address $myemail = 'newsletter@poprox.cjb.net'; # If you want to use file-locking for a more secure database # keep this line as is...if you don't want to use file-locking # or can't use 'flock' change the 1 to 0 # If you have a high-traffic site, I strongly suggest you use # file-locking. $uselock = '1'; ################## THAT'S IT! ###################### # # # You can now play with the script some more if you # # know what you're doing, but if you don't, it's a # # good idea to leave the rest of the script alone and # # use it as is. Remember you may not change the part # # of the script that gives me or the script credit. # # # ######################################################## # Get the form variables if ($ENV{'REQUEST_METHOD'} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } # Break em up into a format the script can read @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } # Assign shorter variable names # (Laziness on my part - but I find the longer # a script gets the more work typing long # variable names becomes.) $thisemail = $FORM{'submitemail'}; # Decide which part of the script we need if ($FORM{'action'} eq 'subscribe') { &subscribe; } if ($FORM{'action'} eq 'unsubscribe') { &unsubscribe; } if ($FORM{'action'} eq 'admin') { &admin; } exit; sub subscribe { if ($thisemail eq "") { print "Location: $homepage\n\n"; exit; } if ($thisemail !~ "\@") { print "Location: $homepage\n\n"; exit; } open (FILE, "$emailpath"); if ($uselock eq '1') { flock FILE, 2; seek FILE, 0, 0; } @emaillist = ; if ($uselock eq '1') { flock FILE, 8; } close (FILE); foreach $emailaddress (@emaillist) { chomp ($emailaddress); if ($emailaddress eq $thisemail) { $already = 1; } } if (!$already) { open (FILE, ">>$emailpath"); if ($uselock eq '1') { flock FILE, 2; seek FILE, 0, 2; } print FILE "$thisemail\n"; if ($uselock eq '1') { flock FILE, 8; } close (FILE); open (MAIL,"|$mailprogram -t"); print MAIL "To: $thisemail\n"; print MAIL "From: $myemail\n"; print MAIL "Subject: Success! $listname joined!\n"; print MAIL "Thank-you for joining $listname!\n\n"; print MAIL "You will receive news and show date information about $mysite\n"; print MAIL "$listcycle.\n\n"; print MAIL "--------------------------------------------\n"; print MAIL "If you have joined $listname by accident or someone else has\n"; print MAIL "joined you without your permission, or\n"; print MAIL "if you ever want to remove yourself from $listname\n"; print MAIL "simply visit $scripturl?action=unsubscribe&submitemail=$thisemail\n"; print MAIL "and you will automatically be removed immediately.\n\n"; print MAIL "Thanks,\n\n"; print MAIL "$mysite staff\n\n"; close (MAIL); print "Content-type: text/html\n\n"; print "Thanks - $listname joined!\n"; print "\n"; print "
\n"; print "

$listname joined!

\n"; print "Thank-you for joining $listname!

\n"; print "You will receive news and information about $mysite \n"; print "$listcycle.

\n"; print "If you have joined $listname by accident or someone else has\n"; print "joined you without your permission, or\n"; print "if you ever want to remove yourself from $listname
\n"; print "simply visit $scripturl?action=unsubscribe&submitemail=$thisemail
\n"; print "and you will automatically be removed immediately.

\n"; print "Thanks,

\n"; print "$mysite staff

\n"; print "

\n"; print "Click here to Return.

\n"; print "\n"; } if ($already) { print "Content-type: text/html\n\n"; print "$thisemail Already Joined!\n"; print "\n"; print "
\n"; print "

$thisemail Already Joined!

\n"; print "

\n"; print "Click here to Return.

\n"; print "\n"; } exit; } sub unsubscribe { if ($thisemail eq "") { print "Location: $homepage\n\n"; exit; } if ($thisemail !~ "\@") { print "Location: $homepage\n\n"; exit; } open (FILE, "$emailpath"); if ($uselock eq '1') { flock FILE, 2; seek FILE, 0, 0; } @emaillist = ; if ($uselock eq '1') { flock FILE, 8; } close (FILE); open (FILE, ">$emailpath"); if ($uselock eq '1') { flock FILE, 2; seek FILE, 0, 0; } foreach $emailaddress (@emaillist) { chomp ($emailaddress); if ($emailaddress ne $thisemail) { print FILE "$emailaddress\n"; } } if ($uselock eq '1') { flock FILE, 8; } close (FILE); open (MAIL,"|$mailprogram -t"); print MAIL "To: $thisemail\n"; print MAIL "From: $myemail\n"; print MAIL "Subject: $thisemail Removed\n"; print MAIL "We are sorry to see you leaving $listname!\n\n"; print MAIL "You will not receive news and information about $mysite\n"; print MAIL "$listcycle anymore.\n\n"; print MAIL "--------------------------------------------\n"; print MAIL "If you ever want to join $listname again\n"; print MAIL "simply visit $scripturl?action=subscribe&submitemail=$thisemail\n"; print MAIL "and you will automatically be joined again.\n\n"; print MAIL "Thanks,\n\n"; print MAIL "$mysite staff\n\n"; close (MAIL); print "Content-type: text/html\n\n"; print "$thisemail Removed!\n"; print "\n"; print "
\n"; print "

$thisemail removed!

\n"; print "We're sorry to see you leaving $listname!

\n"; print "You will not receive news and information about $mysite\n"; print "$listcycle anymore.

\n"; print "If you ever want to join $listname again
\n"; print "simply visit $scripturl?action=subscribe&submitemail=$thisemail
\n"; print "and you will automatically be joined again.

\n"; print "Thanks,

\n"; print "$mysite staff

\n"; print "

\n"; print "Click here to Return.

\n"; print "\n"; exit; } sub admin { if ($FORM{'password'}) { if ($FORM{'password'} eq $adminpass) { if ($FORM{'sendmessage'}) { open (FILE, "$emailpath"); if ($uselock eq '1') { flock FILE, 2; seek FILE, 0, 0; } @emaillist = ; if ($uselock eq '1') { flock FILE, 8; } close (FILE); unless (defined($child_pid = fork())) {die "Process Error : $!\n"}; if ($child_pid) { print "Content-type: text/html\n\n"; print "EasyList Administration\n"; print "\n"; print "

EasyList Administration

\n"; print "Messages Sent Successfully!

\n"; print "

\n"; print "Use the following textarea to enter your message to be sent to all subscribers. Click 'Send!' only once...it may take a few minutes depending on the size of your mailing list and the speed of your server.

\n"; print "

\n"; print "

\n"; print "
\n"; print "For your reference only, this is how your mailing list looks right now :

\n"; print "

\n"; print "

\n"; print "Click here to Return.

\n"; print "\n"; exit(0); } else { close (STDOUT); foreach $emailaddress (@emaillist) { chomp ($emailaddress); open (MAIL,"|$mailprogram -t"); print MAIL "To: $emailaddress\n"; print MAIL "From: $myemail\n"; print MAIL "Subject: $listname\n"; print MAIL "$FORM{'listmessage'}\n\n"; print MAIL "--------------------------------------------\n"; print MAIL "If you have joined $listname by accident\n"; print MAIL "or someone else has joined you without your permission, or\n"; print MAIL "if you ever want to remove yourself from $listname\n"; print MAIL "simply visit: $scripturl?action=unsubscribe&submitemail=$emailaddress\n"; print MAIL "and you will automatically be removed immediately.\n\n"; close (MAIL); } } } if (!$FORM{'sendmessage'}) { open (FILE, "$emailpath"); if ($uselock eq '1') { flock FILE, 2; seek FILE, 0, 0; } @emaillist = ; if ($uselock eq '1') { flock FILE, 8; } close (FILE); print "Content-type: text/html\n\n"; print "EasyList Administration\n"; print "\n"; print "

EasyList Administration

\n"; print "

\n"; print "Use the following textarea to enter your message to be sent to all subscribers. Click 'Send!' only once...it may take a few minutes depending on the size of your mailing list and the speed of your server.

\n"; print "

\n"; print "

\n"; print "
\n"; print "For your reference only, this is how your mailing list looks right now :

\n"; print "

\n"; print "

\n"; print "Click here to Return.

\n"; print "\n"; } } if ($FORM{'password'} ne $adminpass) { print "Content-type: text/html\n\n"; print "EasyList Administration - PASSWORD BREACH\n"; print "\n"; print "

PASSWORD BREACH - WEBMASTER HAS BEEN NOTIFIED

\n"; print "You have been identified as : $ENV{'REMOTE_ADDR'}\n"; print "\n"; if ($hacknotify eq 'yes') { open (MAIL,"|$mailprogram -t"); print MAIL "To: $myemail\n"; print MAIL "From: $myemail\n"; print MAIL "Subject: Attempted Hack!\n"; print MAIL "Someone has attempted to hack into your\n"; print MAIL "EasyList Admin area.\n\n"; print MAIL "Their IP was : $ENV{'REMOTE_ADDR'}\n"; print MAIL "Their guess was : $FORM{'password'}\n\n"; print MAIL "If they were close you should change your password now!\n\n"; print MAIL "This message is a security feature of your EasyList Script!\n\n"; close (MAIL); } } } if (!$FORM{'password'}) { print "Content-type: text/html\n\n"; print "EasyList Administration\n"; print "\n"; print "

EasyList Administration

\n"; print "\n"; print "\n"; print "
Admin Password :
\n"; print "Click here to Return.

\n"; print "\n"; } exit; }