#!/usr/local/bin/perl -- # -*- Perl -*-
# Way cool user singular mailing list subscription maintenance cgi-bin
# for Majordomo
# Written by Wesley J. Ho
# adapted from code originally written
# by Ronald S. Woan (woan@austin.ibm.com)
#
# Form input variables:
# $action
# $name
# $email

#########################################
########## begin main program ###########

push(@INC,"/usr/local/lib/perl");
require 'cgi-lib.pl';

&ReadParse;

#print &PrintHeader; 
#print $in{"email"}, $in{"name"}, $in{"action"}; 

if (!$in{"email"})  
    { &inputError;
      exit(0);
    }

&majordomoAction($in{"action"}, $in{"email"}, $in{"name"});
&actionSuccess;

exit(0);


########## end main program ###########
#######################################


#
# supplemental procedures
#

sub inputError{
print &PrintHeader;
print <<"EOM"; 
<head>
<title>Subscription Request Error</title>
</head>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000"  ALINK="#ff0000" VLINK="#9999FF">

<!-- begin ibmhead ------------------------------------------------>

<table border="0" cellpadding="0" cellspacing="0" width="600"> 

<tr>	<td rowspan="2" valign="top" align="left"><img
	src="/images/mast/headeribmlogo.gif" alt="IBM" width="108" 
	height="54"></td><td valign="top" align="left"><a
	href="http://www.ibm.com/search">
        <img src="/images/mast/headersearchoff.gif" border="0" alt="SEARCH" 
	width="79" height="25" name="SEARCH"></a></td>
	<td rowspan="2" valign="top" 
	align="left"><img src="/images/mast/headertitlers6000.gif" 
	alt="RS/6000" width="267" height="54"></td><td rowspan="2" 
	valign="top" align="left" width=144><applet codebase="/Vegas/full"
	code="Vegas" width=144 height=54><param name="config"
	value="/Vegas/RS6000.2.config"><param name="firstchunk"
	value="nochunk"><param name="startup"
	value="/Vegas/images2/generic.gif"><!--#include 
	virtual=
        "/Vegas/Vegas.cgi/?config=/Vegas/RS6000.2.config&cgichunk=nochunk"
        --></applet></td>
</tr>
<tr>	<td valign="top" align="left" nowrap><a href="/sitemap.html"> 
        <img src="/images/mast/headermapoff.gif" 
	alt="MAP" width="79" height="29" name="MAP" border=0></a></td></tr>
<tr>	<td colspan="4" valign="top" align="left"><img
        src="/images/mast/headershadowwhite.gif" alt="IBM" width="600"
        height="13"></td>
</tr>
</table>
<!-- end ibmhead--------------------------------------------------------- -->

<table border=0 width=600 cellspacing=5>
<tr>
<td valign=top align=left>
<table border=0>
<tr>
<td><a href="/"><img src="/images/navigation/home.gif" border=0 
alt="RS/6000"></a></td>
</tr>
<tr>
<td><a href="/solutions/"><img src="/images/navigation/subnavsolutions.gif"
border=0 alt="Solutions"></a></td>
</tr>
<tr>
<td><a href="/hardware/"><img src="/images/navigation/subnavhardwarehere.gif"
border=0 alt="Hardware"></a></td>
</tr>
<tr>
<td><a href="/software/"><img src="/images/navigation/subnavsoftware.gif"
border=0 alt="Software"></a></td>
</tr>
<tr>
<td><a href="/support/"><img src="/images/navigation/subnavsupport.gif"
border=0 alt="Support"></a></td>
</tr>
<tr>
<td><a href="/resource/"><img src="/images/navigation/subnavresource.gif"
border=0 alt="ReSource"></a></td>
</tr>
</table>

</td>
<td>
<h2>Subscription Request Error</h2>

<li>
Email address must be specified. 

<p>
Use your browser's <b>back</b> function to return to the form.<br>
<a href="/support/micro/">Click Here</a> to exit.

</td>
</tr>
</table>

<hr noshade size=1>

<font size=2>
<a href="http://www.rs6000.ibm.com/">RS/6000</a> |
<a href="/solutions/">Solutions</a> |
<a href="/hardware/">Hardware</a> | 
<a href="/software/">Software</a> | 
<a href="/support/">Support</a> | 
<a href="/resource/">ReSource</a> |
<a href="/sitemap.html">sitemap</a> 

<br>

<a href="http://www.ibm.com/">IBM</a> |
<a href="http://www.ibm.com/Orders/">Order</a> |
<a href="http://www.ibm.com/search/">Search</a> |
<a href="http://www.ibm.com/assist/call-ibm.html">Contact IBM</a> |
<a href="http://www.ibm.com/Finding/">Help</a> |
<a href="http://www.ibm.com/copyright.html">&#169;</a> |
<a href="http://www.ibm.com/trademarks.html">&#174;</a> 

<br>
<br>

<font size=2><a href="http://www.ibm.com/copyright.html">&#169
Copyright</a> IBM Corp. 1994, 1995, 1996, 1997. All rights reserved. </font>
<br>

<!-- hhmts start -->
<!-- hhmts end -->

</font>


</body>
</html>
EOM
}


sub actionSuccess {
print &PrintHeader;
print <<"EOM"; 
<head>
<title>Micro Code mailing list</title>
</head>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000"  ALINK="#ff0000" VLINK="#9999FF">

<!-- Begin ibmhead ------------------------------------------------>
<table border="0" cellpadding="0" cellspacing="0" width="600"> 

<tr>	<td rowspan="2" valign="top" align="left"><img
	src="/images/mast/headeribmlogo.gif" alt="IBM" width="108" 
	height="54"></td><td valign="top" align="left">
        <a href="http://www.ibm.com/search"><img
	src="/images/mast/headersearchoff.gif" border="0" alt="SEARCH" 
	width="79" height="25" name="SEARCH"></a></td>
	<td rowspan="2" valign="top" 
	align="left"><img src="/images/mast/headertitlers6000.gif" 
	alt="RS/6000" width="267" height="54"></td><td rowspan="2" 
	valign="top" align="left" width=144><applet codebase="/Vegas/full"
	code="Vegas" width=144 height=54><param name="config"
	value="/Vegas/RS6000.2.config"><param name="firstchunk"
	value="nochunk"><param name="startup"
	value="/Vegas/images2/generic.gif"><!--#include 
	virtual=
        "/Vegas/Vegas.cgi/?config=/Vegas/RS6000.2.config&cgichunk=nochunk"
        --></applet></td>
</tr>
<tr>	<td valign="top" align="left" nowrap><a href="/sitemap.html">
	<img src="/images/mast/headermapoff.gif" 
	alt="MAP" width="79" height="29" name="MAP" border=0></a></td></tr>
<tr>	<td colspan="4" valign="top" align="left"><img
        src="/images/mast/headershadowwhite.gif" alt="IBM" width="600"
        height="13"></td>
</tr>
</table>
<!-- end ibmhead--------------------------------------------------------- -->
 


<table border=0 width=600 cellspacing=5>
<tr>
<td valign=top align=left>
<table border=0>
<tr>
<td><a href="/"><img src="/images/navigation/home.gif" border=0 
alt="RS/6000"></a></td>
</tr>
<tr>
<td><a href="/solutions/"><img src="/images/navigation/subnavsolutions.gif"
border=0 alt="Solutions"></a></td>
</tr>
<tr>
<td><a href="/hardware/"><img src="/images/navigation/subnavhardware.gif"
border=0 alt="Hardware"></a></td>
</tr>
<tr>
<td><a href="/software/"><img src="/images/navigation/subnavsoftware.gif"
border=0 alt="Software"></a></td>
</tr>
<tr>
<td><a href="/support/"><img src="/images/navigation/subnavsupporthere.gif"
border=0 alt="Support"></a></td>
</tr>
<tr>
<td><a href="/resource/"><img src="/images/navigation/subnavresource.gif"
border=0 alt="ReSource"></a></td>
</tr>
</table>
</td>
<td>
<h2 align=center><center>
Request to be added or removed from the<br> 
mailing list successfully sent!
</center></h2><br>
<p>
<a href="/support/micro/">Click Here</a> to exit.
</center>
</td></tr></table>

<!-- end ibmbody -->

<hr noshade size=1>

<font size=2>
<a href="http://www.rs6000.ibm.com/">RS/6000</a> |
<a href="/solutions/">Solutions</a> |
<a href="/hardware/">Hardware</a> | 
<a href="/software/">Software</a> | 
<a href="/support/">Support</a> | 
<a href="/resource/">ReSource</a> |
<a href="/sitemap.html">sitemap</a> 

<br>

<a href="http://www.ibm.com/">IBM</a> |
<a href="http://www.ibm.com/Orders/">Order</a> |
<a href="http://www.ibm.com/search/">Search</a> |
<a href="http://www.ibm.com/assist/call-ibm.html">Contact IBM</a> |
<a href="http://www.ibm.com/Finding/">Help</a> |
<a href="http://www.ibm.com/copyright.html">&#169;</a> |
<a href="http://www.ibm.com/trademarks.html">&#174;</a> 

<br>
<br>

<font size=2><a href="http://www.ibm.com/copyright.html">&#169
Copyright</a> IBM Corp. 1994, 1995, 1996, 1997. All rights reserved. </font>
<br>

<!-- hhmts start -->
<!-- hhmts end -->

</font>


</body>
</html>
EOM
}


sub majordomoAction {
    local ($action, $email, $name) = @_;
    $mailcommand = "|/usr/lib/sendmail majordomo";
    open(MAIL, $mailcommand);
    if ($name) 
       { print MAIL "From: \"" . $name . "\" <" . $email . ">\n";}
#      { print MAIL "From: " . $name . " (" . $email . ")\n"; } 
    else 
       { print MAIL "From: " . $email . "\n"; }
    print MAIL "Reply-To: " . $email . "\n";
    print MAIL "Subject: Subscription request for micro\n\n";
    if ($name) 
       { print MAIL $action . " micro " . $email . " (" . $name . ")\n"; } 
    else 
       { print MAIL $action . " micro " . $email . "\n"; }
    close(MAIL);
    return;
}

