rendered paste body<?
include('config.inc.php');
$connection = mysql_connect($db_server, $db_user, $db_password) or die("Could not connect : " . mysql_error());
mysql_select_db($db_name) or die("Could not select database");
$today = getdate();
$query = "SELECT COUNT(*) FROM mailinglist_subscribers WHERE confirmed = '1'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$row = mysql_fetch_array($result);
if (get_magic_quotes_gpc() == 1) // Quotes in the message are automatically being escaped
{
$message = stripslashes($_POST[message]);
$subject = strip_tags(stripslashes($_POST[subject]));
}
else
{
$message = $_POST[message];
$subject = strip_tags($_POST[subject]);
}
if (isset($queue_size))
{
$str = "$_POST[month]/$_POST[date]/$_POST[year] $_POST[hour]:$_POST[minute]$_POST[ampm]";
$utime = strtotime($str);
}
else
{
$utime = time();
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Send Message</title>
<script>
var previewed = false;
function loadtemplate()
{
window.open("loadtemplate.php", "template", 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=625,height=400,left=390,top=262');
}
function ownertest(form)
{
win=window.open('','myWin','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=350,height=100,left=390,top=262');
form.target='myWin';
form.method='POST';
form.action='owner_test.php';
return false;
}
function besure(tz)
{
if(document.form1.message.value.length > 0)
{
<?
if (isset($queue_size))
{
echo <<<EOT
if (document.form1.subject.value.length == 0)
{
alert('WARNING: The subject line is empty. Please enter a subject for your message.');
document.form1.subject.focus();
return false;
}
if(document.form1.minute.value < 10)
{
queue_minute = '0' + document.form1.minute.value;
}
else
{
queue_minute = document.form1.minute.value;
}
var queue_date = document.form1.month.value+'/'+document.form1.date.value+'/'+document.form1.year.value+' @ '+
document.form1.hour.value+':'+queue_minute+' '+document.form1.ampm.value;
var confirm_text = 'You are about to send your message.\\nIt will be queued for \
delivery on or about: '+queue_date+' '+tz+'.\\nAre you SURE you want to continue?';
EOT;
echo "\n";
}
else
{
echo "var confirm_text = 'You are about to send your message.\\nAre you SURE you want to continue?'\n";
}
?>
if (previewed == false)
{
if (confirm('This message has not been previewed. It is recommended that you preview your message before sending. Continue anyway?'))
{
return confirm(confirm_text);
}
else
{
return false;
}
}
else
{
return confirm(confirm_text);
}
}
else
{
alert('Message area is empty - no message will be sent.');
return false;
}
}
function msg_change()
{
previewed = false;
}
<?
if($_POST[preview])
{
echo "previewed = true;";
}
?>
var url = "datetime.php"; // script to return current date/time
var memcounturl = "membercount.php"; // script to return current confirmed member count
function handleHttpResponse() // Update the date/time
{
if (http.readyState == 4)
{
document.getElementById('datetime').innerHTML = http.responseText;
}
}
function handlemembercountHttpResponse() // Update the confirmed member count
{
if (http1.readyState == 4)
{
document.getElementById('mc').innerHTML = http1.responseText;
}
}
function updatedatetime()
{
http.open("GET", url, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
setTimeout("updatedatetime()",60000);
}
function updatemembercount()
{
http1.open("GET", memcounturl, true);
http1.onreadystatechange = handlemembercountHttpResponse;
http1.send(null);
setTimeout("updatemembercount()",10000);
}
function getHTTPObject()
{
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E)
{
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object for the date/time - updated every 60 seconds
var http1 = getHTTPObject(); // We create the HTTP Object for the member count - updated every 10 seconds
function updatedays()
{
var months = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
document.forms[0].date.options[0] = null;
for (var w = 0; w < document.forms[0].date.length; w++)
{
document.forms[0].date.options[0] = null;
}
for (var x = 0; x < months[document.forms[0].month.selectedIndex]; x++)
{
document.forms[0].date.options[x] = new Option(x+1);
}
}
</script>
<style type="text/css" media="screen">@import "css/basic.css";</style>
<style type="text/css" media="screen">@import "css/tabs.css";</style>
</head>
<body>
<h1>Simple Mailing List</h1>
<?
if($_POST[submit_send] And strlen($_POST[message]) > 0)
{
// Send mail
// if sent and archived, print confirmation
$query = "SELECT address FROM mailinglist_subscribers WHERE confirmed = '1'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$sent_count = mysql_num_rows($result);
$bcc = "";
while ($row = mysql_fetch_assoc($result))
{
$bcc .= "$row[address],";
}
$subscribers = substr($bcc, 0, -1);
$to = $owner_email;
// $message = wordwrap($message, $columns, "\n");
$sent_date = time();
if ($_POST[format] == 1)
{
$texthtml = "html";
}
else
{
$texthtml = "text";
}
$message = addslashes($message);
$query = "INSERT INTO mailinglist_messages (subject,message,created,queued,count,format) VALUES ('$subject','$message','$sent_date','$utime','$sent_count','$texthtml')";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$message_id = mysql_insert_id();
if (isset($queue_size))
{
$address_query = "SELECT address FROM mailinglist_subscribers WHERE confirmed = '1'";
$address_result = mysql_query($address_query) or die("Query failed : " . mysql_error());
while ($address_row = mysql_fetch_assoc($address_result))
{
$queue_insert_query = "INSERT INTO mailinglist_queue (message_id,address,send_after) VALUES ('$message_id','$address_row[address]','$utime')";
$queue_insert_result = mysql_query($queue_insert_query) or die("Query failed : " . mysql_error());
}
echo "<p><b><font color=Green>Your message has been queued for delivery and archived.</font></b> You can view the delivery progress in the <a href=archives.php>Archives</a>.</p>";
}
else
{
$message = stripslashes($message);
$message .= "\n\n\n\nYou are receiving this message because you have opted in to the $list_name list.";
$message .= " To unsubscribe, please follow this link: $unsub_url";
if ($_POST[format] == 1)
{
$boundary = md5(uniqid(time()));
$headers = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: multipart/alternative;" . PHP_EOL;
$headers .= " boundary=\"$boundary\"" . PHP_EOL;
$send_message = "you shouldn't see this ever" . PHP_EOL . PHP_EOL;
$send_message .= "--$boundary" . PHP_EOL;
$send_message .= "Content-type: text/plain;" . PHP_EOL;
$send_message .= "Content-Transfer-Encoding: 7bit" . PHP_EOL . PHP_EOL;
$send_message .= strip_tags($message) . "" . PHP_EOL;
$send_message .= "--$boundary" . PHP_EOL;
$send_message .= "Content-type: text/html;" . PHP_EOL;
$send_message .= "Content-Transfer-Encoding: 7bit" . PHP_EOL . PHP_EOL;
$send_message .= $message . "" . PHP_EOL;
$send_message .= "--$boundary--" . PHP_EOL;
}
else
{
$send_message = $message;
}
$headers .= "From: $owner_email" . PHP_EOL . "Reply-To: $owner_email" . PHP_EOL . "Bcc: $subscribers" . PHP_EOL . "X-Mailer: NotOneBit.com Simple Mailer";
if(mail($to, $subject, $send_message, $headers))
{
echo "<p><b><font color=Green>Your message has been successfully sent and archived.</font></b> You can view the message in the <a href=archives.php>Archives</a>.</p>";
}
else
{
echo "<p><b><font color=Red>Unable to send message. Check your server's error log for details.</font></b></p>";
}
}
}
?>
<div id="header">
<ul id="primary">
<li><span>Send Message</span></li>
<ul id="secondary">
<li><a href="javascript:loadtemplate();">Load A Template</a></li>
</ul>
<li><a href="members.php">Members</a></li>
<li><a href="archives.php">Archives</a></li>
<li><a href="blacklist.php">Blacklist</a></li>
<li><a href="help.php">Help</a></li>
</ul>
</div>
<div id="main">
<div id="contents">
<h2>Send A Message</h2>
<p class="note">Compose your message in plain text or HTML below. HTML messages are sent in <acronym title="Multipurpose Internet Mail Extensions">MIME</acronym>
format so that if a recipient cannot view the HTML email, they will see a plain text version automatically.</p>
<div align="center">
<center>
<?
if($_POST[format] == 1)
{
$plain_selected = "";
$html_selected = " selected";
}
else
{
$plain_selected = " selected";
$html_selected = "";
}
?>
<script>setTimeout("updatemembercount()",10000);</script>
<form method="POST" action="send.php" name="form1">
<p class="message">If sent now, message will be delivered to <span id="mc"><?=$row[0]?></span> subscribers. Send as
<select size="1" name="format" onChange="document.form1.submit()">
<option value="0"<?=$plain_selected?>>Plain text</option>
<option value="1"<?=$html_selected?>>HTML (plain text version will be created)</option>
</select></p>
<p></p>
<?
if ($_POST[format] == 1)
{
echo "<p class=\"message\">Type or paste your HTML in the message area below:</p>";
}
if ($_POST[submit_send])
{
$message = stripslashes($message);
}
if ($_GET[t])
{
$filename = "templates/" . $_GET[t];
$handle = fopen($filename, "r");
$template = fread($handle, filesize($filename));
fclose($handle);
$message = $template;
}
?>
<p class="message">Subject <input type="text" name="subject" size="50" value="<?=$subject?>"></p>
<p class="message"><textarea rows="20" name="message" cols="75" id="msg_area" onChange="msg_change()"><?=$message?></textarea></p>
<?
if(($_POST[preview] Or $_POST[submit_send]) And strlen($message) > 0)
{
$columns = 75;
echo "<p>Preview (wrapping at column $columns):<table border=\"1\" style=\"border-collapse: collapse; border: 1px solid #C0C0C0\"><tr><td>\n";
echo "<div style=\"padding: 4; height: 200px; width:576px; background-color: #DEDEDE; overflow: auto;\">\n";
if ($_POST[format] == 0) // plain text
{
echo wordwrap(nl2br(htmlspecialchars($message)), $columns, "<br />");
}
else // html
{
echo $message;
}
echo "</div></td></tr></table></p>";
}
if (isset($queue_size) And !$_POST[submit_send])
{
echo "<script>setTimeout(\"updatedatetime()\",60000);</script>";
echo "<p class=\"note\">Date/time on server: <span id=\"datetime\">";
include('datetime.php');
echo "</span> <a href=\"javascript:void(0)\" onmouseover=\"updatedatetime()\">(mouseover to refresh)</a></p>\n";
?>
<table border="0" id="table1" cellpadding="2">
<tr>
<td rowspan="2"><img src="clock.gif" align="absbottom"></td>
<td colspan="4">Schedule message to be delivered beginning on or about:</td>
</tr>
<tr>
<td align="right">Date: </td>
<td><select size="1" name="month" onChange="updatedays();">
<?
$months = array("1" => "January","2" => "February","3" => "March","4" => "April","5" => "May","6" => "June","7" => "July",
"8" => "August","9" => "September","10" => "October","11" => "November","12" => "December",);
$flag = false;
foreach ($months as $key => $val)
{
if ($_POST[month] == $key)
{
echo "<option value=\"$key\" selected>$val</option>\n";
$flag = true;
}
elseif ($today[mon] == $key And !$flag)
{
echo "<option value=\"$key\" selected>$val</option>\n";
}
else
{
echo "<option value=\"$key\">$val</option>\n";
}
}
?>
</select><select size="1" name="date">
<?
$flag = false;
for($i=1;$i<=31;$i++)
{
if ($_POST[date] == $i)
{
echo "<option value=\"$i\" selected>$i</option>\n";
$flag = true;
}
elseif ($today[mday] == $i And !$flag)
{
echo "<option value=\"$i\" selected>$i</option>\n";
}
else
{
echo "<option value=\"$i\">$i</option>\n";
}
}
?>
</select><select size="1" name="year">
<?
$flag = false;
for($i=$today[year];$i<=$today[year]+5;$i++)
{
if ($_POST[year] == $i)
{
echo "<option value=\"$i\" selected>$i</option>\n";
$flag = true;
}
elseif ($today[year] == $i And !$flag)
{
echo "<option value=\"$i\" selected>$i</option>\n";
}
else
{
echo "<option value=\"$i\">$i</option>\n";
}
}
?>
</select></td>
<td align="right"> Time: </td>
<td><select size="1" name="hour">
<?
$curr_hour = date("g");
$flag = false;
for($i=1;$i<=12;$i++)
{
if ($_POST[hour] == $i)
{
echo "<option value=\"$i\" selected>$i</option>\n";
$flag = true;
}
elseif ($curr_hour == $i And !$flag)
{
echo "<option value=\"$i\" selected>$i</option>\n";
}
else
{
echo "<option value=\"$i\">$i</option>\n";
}
}
?>
</select><select size="1" name="minute">
<?
$flag = false;
for($i=0;$i<=59;$i++)
{
if ($i < 10) $min = "0".$i; else $min = $i;
if (isset($_POST[minute]) And $_POST[minute] == $i)
{
echo "<option value=\"$i\" selected>$min</option>\n";
$flag = true;
}
elseif ($today[minutes] == $i And !$flag)
{
echo "<option value=\"$i\" selected>$min</option>\n";
}
else
{
echo "<option value=\"$i\">$min</option>\n";
}
}
?>
</select><select size="1" name="ampm">
<?
$flag = false;
if ($_POST[ampm] == "AM")
{
echo "<option selected>AM</option>\n";
echo "<option>PM</option>\n";
$flag = true;
}
elseif ($_POST[ampm] == "PM")
{
echo "<option>AM</option>\n";
echo "<option selected>PM</option>\n";
$flag = true;
}
elseif (date("A") == "AM" And !$flag)
{
echo "<option selected>AM</option>\n";
echo "<option>PM</option>\n";
}
else
{
echo "<option>AM</option>\n";
echo "<option selected>PM</option>\n";
}
?>
</select></td>
</tr>
</table>
<?
}
if (!$_POST[submit_send])
{
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="200"> </td>
<td width="200" align="center">
<input type="submit" value="Preview Message" name="preview" onClick="this.form.target='';this.form.action='send.php';"> <input type="submit" value="Send Message" name="submit_send" onClick="this.form.target=''; this.form.action='send.php'; return besure('<?=Date("T")?>');"></td>
<td width="200" align="right">
<input type="submit" value="Send Message To List Owner ONLY" name="owner_test" onClick="ownertest(this.form)"></td>
</tr>
</table>
<?
}
?>
</form>
</center>
</div>
</div>
</div>
<p align="center" class="message"><a href="http://www.notonebit.com">© 2006 NotOneBit.com</a></p>
</body>
</html>