<?php

// Copyright 2003 Sunwave Communications
// This script is designed to be used with the ezmlm-idx software to
// provide a web interface to send subscribe or unsubscribe requests
// on behalf of your mailing list members

// Please Note: this file should be saved with a .php file extension

// replace the following lines with your list's subscribe and unsubscribe e-mail addresses
$mysubscribe = "listname-subscribe@mydomain.com"; // your mailing list address for subscribing
$myunsubscribe = "listname-unsubscribe@mydomain.com"; // your mailing list address for unsubscribing

// optionally specify an admin e-mail to receive an informative
// notices when a user subscribes or unsubscribes. To activate,
// uncomment the following line and fill in the e-mail address.

// $myadmin = "me@mydomain.com";


if ($submit == 1) {

// set the date
$DATE = date('D M d, Y - H:i:s');

if ($email != "") {

if ($ACTION == "subscribe") {

$mailto = $mysubscribe;

} elseif ($ACTION == "unsubscribe") {

$mailto = $myunsubscribe;

} else {

print_html_box("You did not specify whether you wanted to subscribe or unsubscribe.");
exit();

}

mail($mailto, "Mailing List Request on $date", "User submitted a $ACTION request on $date from $PHP_SELF",
"From: $email\n");

if ($myadmin != "") {

mail($myadmin, "Mailing List Request on $date", "The address $email submitted a $ACTION request on $DATE from $PHP_SELF",
"From: $myadmin\n");

}

}

else {

print_html_box("You did not provide a valid e-mail address");
exit();

}

// tell them thanks
print_html_box("Thank you. A request has been submitted on your behalf to the mailing list manager. The mailing list manager
will send a confirmation message to your e-mail address. To complete this action, you will need to reply to the
the confirmation message when you receive it.

<BR> <BR>

Confirmation messages assure that nobody can change your subscription status except you.");

// exit now
exit();

}

?>

<FORM METHOD="POST" ACTION="<?php echo $PHP_SELF; ?>">

<INPUT TYPE=HIDDEN NAME="submit" VALUE="1">

<TABLE WIDTH=350 BORDER=1 CELLPADDING="0" CELLSPACING="0"> <TR> <TD>
<TABLE WIDTH=350 BORDER=0 CELLPADDING="10" CELLSPACING="0">

<TR>
<TD COLSPAN="2" BGCOLOR="#F3F3F3" ALIGN="CENTER"> <B> Our Mailing List </B> </TD>
</TR>
<TR>
<TD WIDTH="50%"> E-Mail Address </TD>
<TD WIDTH="50%"> <INPUT TYPE=TEXT NAME="email"> </TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="CENTER"> <INPUT TYPE=RADIO NAME=ACTION VALUE="subscribe"> Subscribe
&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE=RADIO NAME=ACTION VALUE="unsubscribe"> Unsubscribe
</TD>
</TR>

</TABLE>
</TR> </TD> </TABLE>

<BR>
<BR>

<INPUT TYPE="Submit" VALUE="Submit">

</FORM>

<?php

// subroutine to print a pretty message to
// the remote user

function print_html_box($message) {

print '
<BR>
<BR>
<CENTER>

<TABLE WIDTH=400 BORDER=1 CELLPADDING="0" CELLSPACING="0"> <TR> <TD>
<TABLE WIDTH=400 BORDER=0 CELLPADDING="10" CELLSPACING="0">
<TR>
<TD COLSPAN="2" BGCOLOR="#F3F3F3" ALIGN="LEFT"> ' . $message . ' </TD>
</TR>
</TABLE>
</TD></TR></TABLE>
</CENTER>';

}

?>