<?php
include "chkuser.php";
include "includefilemng.php"; 
set_time_limit(0);
$site_main_path = "http://s216436709.onlinehome.us/newheronoswork/";

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Control Panel </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="ssi.css" rel="stylesheet" type="text/css">
<script src="includenp/functions.js"></script>
<script language="javascript">

function IsEmpty(aTextField)
{
   if ((aTextField.length==0) || (aTextField==null))
   {
      return true;
   }
   else
    { 
		return false;
	}
}	
function validateForm()
{

if(IsEmpty(document.form1.subject.value))
{	
	 errMsg = errMsg + "Please enter subject\n";
	 document.form1.subject.focus();
	 document.form1.subject.select();
	 errCount = errCount +1;
}


if(IsEmpty(document.form1.message.value))
{	
	 errMsg = errMsg + "Please enter mail\n";
	 document.form1.message.focus();
	 document.form1.message.select();
	 errCount = errCount +1;
}


if(errCount > 0)
{
	alert (errMsg);
	return false;
}
}
</script>

</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center">
  <tr>
    <td width="1%"  bgcolor="#C9C9C9"></td>
	<td width="98%"><?php include_once "top.php";?></td>
	<td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
   <td width="1%"  bgcolor="#C9C9C9"></td>
    <td width="98%"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="centertable">
      <tr>
        <td><table width="80%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="59%" height="50"></td>
            <td width="41%"></td>
          </tr>
          <tr>
            <td colspan="2">
			
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <table width="100%"  border="0" cellpadding="2" cellspacing="0">
              
                  <tr>
                    <td width="100%" align="center">
		
				<TABLE class=table cellSpacing=3 cellPadding=3 width="98%" align=center border=0>
                      
						 
		
                   
                    <TR valign="top" class="trbg">
                      <TD colspan="7" align=center>
	<?php
	include "conn.php";
	$sql = "SELECT * FROM admin";
	    $result = mysql_query($sql); 
	    $row = mysql_fetch_object($result);
	    $sendemailid = $row->sendemailid; 	 
	
	//$maii_from="info@herons-walk.com";
	$maii_from=$sendemailid;
	
	$mailtype=$_POST['mailtype'];
	$mail_subject=$_POST['subject'];
	
	if($mailtype=="text"){	
	$mail_body=$_POST['message'];	
	}	
	if($mailtype=="html"){
	$mail_body=stripslashes($_POST['txtContent']);
	}
	
	$headers="MIME-Verson: 1.0\n";
	$headers .="Content-Type: text/html;charset=iso-8859-1\n";
    $headers .="From: ".$maii_from;
	
	
	
	
	/*$headers="MIME-Verson:1.0\r\n";
	$headers = $headers . "Content-Type: text/html;charset=iso-8859-1\r\n";
	$headers = $headers . "Content-Transfer-Encoding: 8bit\r\n";
	$headers = $headers . "From: info@herons-walk.com\r\n";
	$headers =$headers. "X-Priority: 3\n";
	$headers =$headers. "X-MSMail-Priority: Normal\n";
	$headers =$headers. "X-Mailer: PHP\n";*/	
	//HTML type mail	
	/*if($mailtype=="html"){			
	$mail_subject = $_POST['subject'];
	$contents=stripslashes($_POST['txtContent']);
	$mail_body=$contents."\n"; 		
	$headers="MIME-Verson:1.0\r\n";
	$headers = $headers . "Content-Type: text/html;charset=iso-8859-1\r\n";
	$headers = $headers . "Content-Transfer-Encoding: 8bit\r\n";
	$headers = $headers . "From: info@herons-walk.com\r\n";	
	$headers = $headers. "X-Priority: 3\n";
	$headers = $headers. "X-MSMail-Priority: Normal\n";
	$headers = $headers. "X-Mailer: PHP\n";	
	}*/
	
	
	$sqld = "SELECT * FROM subscribedusers";
	$resultd=mysql_query($sqld); 
	$i=0;	
	while($rowd=mysql_fetch_object($resultd))
	{
	$mail_to=$rowd->email;	
	mail($mail_to,$mail_subject,$mail_body,$headers);
	$i++;
	}		
	
	?>
<?php echo $i; ?><span class="titleheading"> Mails Sent...</span></TD>
                    </TR>
                    <TR valign="top" class="trbg">
                      <TD colspan="7" align=center>&nbsp;</TD>
                    </TR>
                    <TR valign="top" class="trbg">
                      <TD colspan="7" align=center>&nbsp;</TD>
                    </TR>
                    <TR valign="top" class="trbg">
                      <TD colspan="7" align=center><a href="htmlmail.php" class="bigblueTxt"></a></TD>
                      </TR>
                </TABLE>
				
				
			</td>
                  </tr>
           
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
    <td  bgcolor="#C9C9C9" width="1%"></td>
	<td><?php include_once "footer.php";?></td>
	<td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
</table>
</body>
</html>
