$dnum = date(Ymd)*4;
$from = $_GET['fr'];
if($from == ""){
$from = $_POST['fr'];
}
if($from != $dnum){
echo("<<<<Restricted Area>>>>" .
"
Sorry, you must Log In to view this Page
");
exit();
}
$usrn = $_GET['usrn'];
if($usrn == ""){
$usrn = $_POST['usrn'];
}
if($usrn == ""){
echo("<<<<Restricted Area>>>>" .
"
Problem with your username. Please Log In again.
");
exit();
}
$dtnum = date(Ymd);
$today = date("F j, Y");
$subject = $_POST['subject'];
if($subject == ""){
echo("Missing a Subject.
Please go back and correct.
");
exit();
}
$greeting = $_POST['greeting'];
$message = $_POST['message'];
if($message == ""){
echo("No Message.
Please go back and correct.
");
exit();
}
$out = array("\"","\'");
$in = array(""","’");
$mess = str_replace($out, $in, $message);
$messo = nl2br($mess);
$link_ex = $_POST['link_ex'];
$link = $_POST['link'];
$closing = $_POST['closing'];
$bizlist = $_POST[bizlist];
$bizcount = count($bizlist);
if($bizcount > 1){
$bizzes = implode(':',$bizlist);
}else{
$bizzes = $bizlist[0];
}
$reps = $_POST['reps'];
$dbcnx = @mysql_connect('mysql.plainhost.com', 'ecosmar_ecosmart', 'ecoman1');
mysql_select_db('ecosmar_friendly', $dbcnx);
$checkit = mysql_query("SELECT ID from ml_temp WHERE subject='$subject'");
if(!$checkit){
echo("Could not check for message status".mysql_error()."
");
}else{
$numrows = mysql_num_rows($checkit);
$new = mysql_fetch_array($checkit);
$oldMID = $new['ID'];
}
if($numrows < 1){
$setit = mysql_query("INSERT INTO ml_temp SET subject='$subject',greeting='$greeting',message='$mess',link_ex='$link_ex',link='$link',closing='$closing',dtnum='$dtnum'");
if(!$setit){
echo("Email message not saved.
".mysql_error()."
");
}
$query = mysql_query("SELECT LAST_INSERT_ID()");
mysql_query( $query );
$MID = mysql_insert_id();
}else{
$MID = $oldMID;
$setup = mysql_query("UPDATE ml_temp SET subject='$subject',greeting='$greeting',message='$mess',link_ex='$link_ex',link='$link',closing='$closing',dtnum='$dtnum' WHERE subject='$subject'");
if(!$setup){
echo("Email message not updated.
".mysql_error()."
");
}
}
mysql_select_db('ecosmar_contacts', $dbcnx);
$oot = mysql_query("SELECT address FROM em_out");
if(!$oot){
echo("Could not check out list.
".mysql_error()."
");
}else{
while($row = mysql_fetch_array($oot)){
$em_out[] = $row['address'];
}
}
foreach($bizlist as $value){
$getit = mysql_query("SELECT first_Name,Name,email FROM con_main WHERE biztype='$value' AND mkt='1' ORDER BY Name");
if(!$getit){
echo("Could not retrieve $value list.
".mysql_error()."
");
}else{
while($ok = mysql_fetch_array($getit)){
$first_Name = $ok[0];
if($first_Name == ""){
$nofirst = "on";
}elseif($first_Name == "n/a" or $first_Name == "N/A"){
$nofirst = "on";
}elseif(ereg(" ", $first_Name)){
$splode = explode(" ", $first_Name);
$first_Name = $splode[0];
$nofirst = "off";
}
$Name = $ok[1];
$namnum = strlen($Name);
if($Name == "" or $namnum < 2){
$nolast = "on";
}elseif($Name == "n/a" or Name == "N/A"){
$nolast = "on";
}elseif(ereg(" ", $Name)){
$lsplode = explode(" ", $Name);
$Name = $lsplode[0];
$nofirst = "off";
}
$email = $ok[2];
if($email == ""){
$noemail = "on";
}
if(ereg("@", $email)){
$noemail = "off";
}else{
$noemail = "on";
}
if($nofirst != "on" and $nolast != "on" and $noemail != "on"){
if(!in_array($email, $em_out)){
$listoa[] = $first_Name." ".$Name." ".$email;
}
}
}
}
}
if($reps == '1'){
mysql_select_db('ecosmar_website', $dbcnx);
$repcheck = mysql_query("SELECT usrn,email FROM psw");
if(!$repcheck){
echo("Could not retrieve Rep List.
".mysql_error()."
");
}else{
while($row = mysql_fetch_array($repcheck)){
$repusrn = $row[0];
$repemail = $row[1];
$listoa[] = $repusrn." ".$repemail;
}
}
}
$lista = array_unique($listoa);
$listcount = count($lista);
if($listcount > 30){
$warn = 'on';
$tonot = "Too many recipients.
TO list has been shortened to the first 30.
";
$listleft = array_slice($lista, 30);
$lista = array_slice($lista, 0, 30);
}
?>
Eco-$mart Mail-room
Email to Eco-$mart Contacts
©2007 - Data Base Interface - Custom Built at:
|