#!/usr/local/bin/perl5 -w # # majordomo # # Build a form with some fields preset. The generated form will # allow most of the options which majordomo allows. # # This puts up a fairly simple screen to be filled out. # This also takes a query string which can be used to # fill in some defaults, as well as limit the options available. # # Parameters: # The first parameter is the name of the mailing list # and host. Something like: # oracle-bugs:peak.org # # The next set of parameters are those to avoid displaying # fields. They are: # -s -u -h -i -I -w -W -l -g # -s No subscribe # -u No unsubscribe # -h No help # -i No info # -I No index # -w No which # -W No who # -l No lists # -g No get # # The parameter "ro" says that the fields for mailing # list name and machine name cannot be changed. # # The next parameter is for color: # bgcolor=COLOR # If specified, this will be used as the background color. # Note that case is significant. The "bgcolor" must be all # lower case leters. # # The next parameter is for the next link off of the # majordomo2 page: # link=http://www.... # # Note that if I were to rewrite this program it would look # quite different. CGI.pm may have been one of those choices. # # Written by Dave Regan # 24 June 1996 # This program is in the Public Domain. # Do what you want with it. # ### ### Configuration ### $DefaultHost = "peak.org"; # Default mail server ### ### Main program ### HTMLhead("Marjordomo meets the web"); $Vars{'bgcolor'} = "#FFFFFF"; $Vars{'link'} = ""; $| = 1; ParseQueryString(); # printenv(); print "\n"; $Vars[0] = "" if (!defined($Vars[0])); ($mlist, $host) = split(/[:\@]/, $Vars[0]); DisplayForm($mlist, $host); HTMLterm(); exit 0; ### ### DisplayForm ### ### Build a form for the user to fill in. ### sub DisplayForm { local($mlist, $host) = @_; print "

This form will let you communicate with any majordomo mailing list server.\n"; $mlist = "" if (!defined($mlist)); $host = "" if (!defined($host)); if ($mlist ne "") { $host = $DefaultHost if ($host eq ""); if (!defined($Vars{'ro'})) { print "The current mailing list ($mlist on host $host)\n"; print "is selected as a default, but you\n"; print "can alter the mailing list name or host if you want.\n"; } } # print "You must enter your email address and your full name.\n"; print "You must enter your email address.\n"; print "

\n"; print "You can select any of the majordomo commands, and you can choose to select\n"; print "several of them.\n"; print "

\n"; print "

\n"; print "\n"; print "\n"; print "
\n"; print "
\n";
    print "Email address:   

\n"; # print "Real Name:

\n"; if (!defined($Vars{'ro'})) { print "Mailing List:

\n"; print "Host:

\n"; } else { print "Mailing List: $mlist

\n"; print "Host: $host

\n"; } print "

\n"; print "

\n"; if (!defined($Vars{'-s'})) { print " "; print "Subscribe -- Subscribe to the specified mailing list.
\n"; } if (!defined($Vars{'-u'})) { print ""; print "Unsubscribe -- Unsubscribe from the specified mailing list.
"; } if (!defined($Vars{'-h'})) { print " "; print "Help -- Get a help message from Majordomo.
\n"; } if (!defined($Vars{'-i'})) { print " "; print "Info -- Get information on the specified mailing list.
\n"; } if (!defined($Vars{'-I'})) { print " "; print "Index -- Return an index of files you can \"get\" for the specified list.
\n"; } if (!defined($Vars{'-w'})) { print " "; print "Which -- Find out which lists you are on for the specified host.
\n"; } if (!defined($Vars{'-W'})) { print " "; print "Who -- Find out who is on the specified list.
\n"; } if (!defined($Vars{'-l'})) { print " "; print "Lists -- Get an index of the mailing lists available on the specified host.
\n"; } if (!defined($Vars{'-g'})) { print " "; print "Get -- Get a file from the archive associated with the specified mailing list.
\n"; print "
\n";
	print "Filename:        (for get command)

\n"; print "

\n"; } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; } ### ### HTMLhead ### ### Put out a HTML header ### sub HTMLhead { local($title) = @_; print "Content-type: text/html\n\n"; print "$title\n"; } ### ### HTMLterm ### ### Put out the end of an HTML body. ### sub HTMLterm { print "\n"; } ### ### ParseQueryString ### ### Break apart a query string. ### This probably will need to be smarter. ### It should unescape values. ### ### A special hack is that the variables are also put into ### an ordered list for backwards compatibility. ### sub ParseQueryString { my($field, @fields, $name, $value); return if (!defined($ENV{'QUERY_STRING'}) || $ENV{'QUERY_STRING'} eq ""); @fields = split(/\&/, $ENV{'QUERY_STRING'}); for $field (@fields) { ($name, $value) = split(/=/, $field, 2); $value = "" if (!defined($value)); $Vars{$name} = unquote($value); push(@Vars, "$field"); } } ### ### printenv ### ### Display the environment. ### This assumes that we can write on stdout. This may not ### be true if we haven't written the header line yet. ### sub printenv { local(@env, $var); @env = `printenv`; for $var (@env) { print "$var
\n"; } } ### ### unquote ### ### Unescape a CGI form variable. ### There are better ways to do this. ### sub unquote { my($raw) = @_; my($code, @pieces, $piece); $raw =~ s/\+/ /mg; @pieces = split(/%/, $raw); for ($piece = 1; $piece <= $#pieces; $piece++) { $pieces[$piece] =~ s/^%//; $code = substr($pieces[$piece], 0, 2); $code = hex($code); $pieces[$piece] = sprintf("%c%s", $code, substr($pieces[$piece], 2)); } return join("", @pieces); } ### ### untaint ### ### Pass over a string. ### This is somewhat cheating. ### sub untaint { local($var) = @_; $var =~ m#^(.*)$#; return $1; }