File: //home/awaldron/public_html/archive/5a_orig/maillist.php
<?php
error_reporting(0);
if(phpversion() >= "4.2.0") {
extract($HTTP_POST_VARS);
extract($HTTP_GET_VARS);
}
require("_header.php");
//////////////////////////////////////////////////////////////////////////////////////
function login() {
echo "<form action=\"maillist.php\" method=\"post\">\n";
echo "<center><P><table border=0>\n";
echo "<tr><td class=\"text\" align=\"right\"><b>Username:</b></td><td class=\"text\"><input type=\"text\" name=\"username\" size=20 maxlength=10></td></tr>\n";
echo "<tr><td class=\"text\" align=\"right\"><b>Password:</b></td><td class=\"text\"><input type=\"password\" name=\"password\" size=20 maxlength=10></td></tr>\n";
echo "</table>\n";
echo "<input type=\"hidden\" name=\"stage\" value=\"compose\">\n";
echo "<input type=\"submit\" value=\"Login\">\n";
echo "</form></center>\n";
}
//////////////////////////////////////////////////////////////////////////////////////
function email_error() {
echo "<P><center><b>The email address you entered is not valid.<br>Please return to the previous page and try again.</b></center>\n";
require("_footer.php");
exit;
}
//////////////////////////////////////////////////////////////////////////////////////
?>
<P><center><img src="images/t_maillist.gif"></center>
<?php
$datapath = "cgi-bin/maillist/mail.txt";
if ($stage == "confirm") {
if ($process == "add") {
trim($email);
if (!eregi("^[a-zA-Z0-9_\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email)) {
email_error();
}
$exists = 0;
$addys = file($datapath);
for ($z=0; $z<count($addys); $z++) {
if (strcasecmp(trim($email), trim($addys[$z])) == 0) {
$exists = 1;
}
}
if ($exists == 0) {
$fp = fopen($datapath, "a");
$addline = trim($email) . "\n";
fwrite($fp,$addline);
fclose($fp);
echo "<P><center><b>" . trim($email) . "<br>Thank you for joining the Fifth Ace Entertainment Mailing List!</b><br>You will be receiving our latest newsletter shortly!</center>\n";
} elseif ($exists == 1) {
echo "<P><center><b>That email address already exists on our list.</b></center>\n";
} else {
echo "<P><center><b>An error has occurred. Please contact the webmaster.</b></center>\n";
}
} elseif ($process == "delete") {
trim($email);
if (!eregi("^[a-zA-Z0-9_\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email)) {
email_error();
}
$found = 0;
$addys = file($datapath);
$fp = fopen($datapath, "w");
for ($i=0; $i<count($addys); $i++) {
if (strcasecmp(trim($email), trim($addys[$i])) == 0) {
$found = 1;
} else {
$addline = trim($addys[$i]) . "\n";
fwrite($fp,$addline);
}
}
fclose($fp);
if ($found == 1) {
echo "<P><center><b>" . trim($email) . "<br>You have been successfully removed from our mailing list.</b><br>Please visit Fifth Ace Entertainment again sometime.</center>\n";
} else {
echo "<P><center><b>That email address could not be found in our mailing list.</b><br>Please try again.\n";
echo "<form action=\"maillist.php\" method=\"get\">\n";
echo "<br><br><br><b>Enter your email address below:</b>\n";
echo "<br><input type=\"text\" name=\"email\" size=\"50\" maxlength=\"64\">\n";
echo "<input type=\"hidden\" name=\"stage\" value=\"confirm\">\n";
echo "<input type=\"hidden\" name=\"process\" value=\"delete\">\n";
echo "<P><input type=\"submit\" value=\"Unsubscribe\">\n";
echo "</form>\n";
echo "</center><br>\n";
}
} else {
echo "<P><center><b>An error has occurred. Please contact the webmaster.</b></center>\n";
}
}
//////////////////////////////////////////////////////////////////////////////////////
elseif ($stage == "compose") {
if ($username == "dkoch" && $password == "flowers41") {
if ($process == "sendmail") {
// SEND EMAILS
$addys = file($datapath);
$additional_headers = "From: $from <$reply>\n" . "Reply-To: $reply";
$mailctr = 0;
for ($x=0; $x<=count($addys); $x++) {
$address = trim($addys[$x]);
if (eregi("^[a-zA-Z0-9_\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $address)) {
$message = $body;
//$message = $body . "\n\n\n\n-----------------------------------------------------------\n"
// . "To Unsubscribe to this mailing list, follow the URL below:\n"
// . "http://www.5thace.com/maillist.php?email=$address&stage=confirm&process=delete\n";
$message = stripslashes($message);
$subject = stripslashes($subject);
if (mail($address, $subject, $message, $additional_headers)) {
$mailctr++;
}
}
}
echo "<center><P>The newsletter has successfully been sent out to " . $mailctr . " of " . count($addys) . " subscribers.<br><br>\n";
} else {
$addys = file($datapath);
echo "<center>\n";
echo "<P><b>There are now " . count($addys) . " email addresses in the mailing list.\n";
echo "<br><a href=\"maillist.php?stage=view_list\" class=\"text\"><span class=\underline\"><FONT onmouseover=\"this.style.color='#FF0000'\" onmouseout=\"this.style.color='#000000'\">View the Email List</font></span></a>\n";
echo "<P><form action=\"maillist.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"stage\" value=\"compose\">\n";
echo "<input type=\"hidden\" name=\"process\" value=\"sendmail\">\n";
echo "<input type=\"hidden\" name=\"username\" value=\"" . $username . "\">\n";
echo "<input type=\"hidden\" name=\"password\" value=\"" . $password . "\">\n";
echo "<P><b>FROM:</b> <input type=\"text\" name=\"from\" size=\"65\" maxlength=\"128\" value=\"Fifth Ace Entertainment\">\n";
echo "<br><b>REPLY-TO:</b> <input type=\"text\" name=\"reply\" size=\"65\" maxlength=\"128\" value=\"dkoch@5thace.com\">\n";
echo "<br><b>SUBJECT:</b> <input type=\"text\" name=\"subject\" size=\"65\" maxlength=\"128\">\n";
echo "<P><b>BODY:</b>\n";
echo "<br><textarea name=\"body\" rows=25 cols=65 wrap=on></textarea>\n";
echo "<P><input type=\"submit\" value=\"--- Send Out Emails ---\"></form>\n";
echo "</form>\n";
echo "<hr width=\"95%\" color=\"CC0000\">\n";
echo "<P><table border=0><tr>\n";
echo "<td class=\"text\" align=center>\n";
echo "<form action=\"maillist.php\" method=\"get\">\n";
echo "<b>Add an Address to the List</b>\n";
echo "<br><input type=\"text\" name=\"email\" size=\"50\" maxlength=\"64\">\n";
echo "<input type=\"hidden\" name=\"stage\" value=\"confirm\">\n";
echo "<input type=\"hidden\" name=\"process\" value=\"add\">\n";
echo "<br><input type=\"submit\" value=\"Add Email\"></form>\n";
echo "</td><td class=\"text\" align=center>\n";
echo "<form action=\"maillist.php\" method=\"get\">\n";
echo "<b>Remove an Address from the List</b>\n";
echo "<br><input type=\"text\" name=\"email\" size=\"50\" maxlength=\"64\">\n";
echo "<input type=\"hidden\" name=\"stage\" value=\"confirm\">\n";
echo "<input type=\"hidden\" name=\"process\" value=\"delete\">\n";
echo "<br><input type=\"submit\" value=\"Remove Email\"></form>\n";
echo "</td></tr></table><br>\n";
}
} else {
login();
}
}
//////////////////////////////////////////////////////////////////////////////////////
else if ($stage == "view_list") {
echo "<center><P>Addresses currently in the Mailing List:</P>\n";
$addys = file($datapath);
$per_col = (floor((count($addys)/2))+1);
echo "<P><table border=0 cellspacing=15><tr>\n";
echo "<td class=\"text\" valign=top>\n";
for ($i=0; $i <= count($addys); $i++) {
echo $addys[($i-1)] . "<br>\n";
if (($i % $per_col) == 0 ) { echo "</td><td class=\"text\" valign=top>\n"; }
}
echo "</td>\n";
echo "</tr></table>\n";
echo "</center><br>\n";
}
//////////////////////////////////////////////////////////////////////////////////////
else {
echo "<center><P>Join the Fifth Ace Entertainment Mailing List to get all the latest information regarding upcoming events, parties, new merchandise, bar and club appearances and much much more...\n";
echo "<form action=\"maillist.php\" method=\"get\">\n";
echo "<br><br><br><b>Enter your email address below:</b>\n";
echo "<br><input type=\"text\" name=\"email\" size=\"50\" maxlength=\"64\">\n";
echo "<input type=\"hidden\" name=\"stage\" value=\"confirm\">\n";
echo "<input type=\"hidden\" name=\"process\" value=\"add\">\n";
echo "<P><input type=\"submit\" value=\"Subscribe!\">\n";
echo "</form>\n";
echo "</center><br>\n";
}
require("_footer.php");
?>