[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [cobalt-users] web subscription to majordomo
- Subject: RE: [cobalt-users] web subscription to majordomo
- From: "Joseph A. Hurdt" <lists@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri Jan 2 09:44:01 2004
- List-id: Mailing list for users to share thoughts on Sun Cobalt products. <cobalt-users.list.cobalt.com>
> Does anyone have any scripts that work well with Majordomo giving web
> based sub/unsub access to users so the siteadmin doesn't have to
> maintain the list of subscribers?
I also have a script that works nicely for my needs. It is based upon
MajorForm and I do not claim rights to it. I have included the code for the
CGI Below...
---------------------------------------
BEGIN CODE SECTION
---------------------------------------
#!/usr/bin/perl
######################################################################
# listman.cgi - based on mduserform.cgi with additional #
# modifications by jhurdt #
# #
# mduserform.cgi - based on MajorForm 1.0 and old R Haller code - #
# modified by llynch@xxxxxxxxxxxxxxxxxxxx 9/1/00 #
# #
# MajorForm 1.0 - A tool to easily subscribe unsubscribe users to or #
# from a MajorDomo mailing list via a form. <caleb@xxxxxxxxxxx> #
######################################################################
##########################
# ADDITIONAL INFORMATION #
##########################
# listman looks for the following form elements...
# listname - The name of the list that you are modifying.
# You may choose to include this in a hidden field.
# address - The email address that you would like to subscribe or
# unsubscribe.
# action - The action field should return either 'subscribe' or
# 'unsubscribe' (without the single quotes).
# I like using radio buttons for this.
###########################
# DEFINE SYSTEM VARIABLES #
###########################
# Path to Sendmail
$mailprog = '/usr/sbin/sendmail -oi -t';
# The part after majordomo@
$host = 'YOURWEBSITE.COM';
###########
# PARSING #
###########
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Get the input
@pairs = split(/&/, $buffer); # Split the name-value
pairs (parsing)
# More Parsing
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$listname =$FORM{'listname'}; # The name of the list
# Validate the e-mail address
if ($FORM{'address'} eq "username\@some.host")
{
&bad_email;
exit;
} else {
$testmail = $FORM{'address'};
if ($testmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$testmail !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{
&evil_characters;
exit;
} else {
&thank_you;
}
}
# Open The Mail
open(MAIL, "|$mailprog") || die "Can't open $mailprog!\n";
print MAIL "To: majordomo\@$host\n";
print MAIL "From: $FORM{'address'}\n";
# Tell majordomo what to do
if ($FORM{'action'} eq "subscribe") {
print MAIL "subscribe $listname $FORM{'address'}\n ";
} else {
print MAIL "\n";
}
if ($FORM{'action'} eq "unsubscribe"){
print MAIL "unsubscribe $listname $FORM{'address'}\n ";
} else {
print MAIL "\n";
}
print MAIL "end\n"; # Feed mail an end & a blank
line
close (MAIL); # Close mail cleanly
} else {
# Display Error Message
print "Location: http://LOCATION TO ERROR PAGE/listerror.html\n\n";
}
sub bad_email{
print "Location: http://LOCATION TO ERROR PAGE/listerror.html\n\n";
}
sub evil_characters {
print "Location: http://LOCATION TO ERROR PAGE/listerror.html\n\n";
}
sub thank_you {
print "Location: http://LOCATION TO THANK YOU PAGE/listerror.html\n\n";
}
---------------------------------------
END CODE SECTION
---------------------------------------