<?php
	include("vars.php");
	include("db.php");
	
if($_SERVER['REQUEST_METHOD'] == "POST")
{
	if($your_subject == "" || $your_subject == "  Subject")
	{
		$your_subject = "No subject";
	}
	if($email_from == "" || $email_from == "  Your email")
	{
		$email_from = $email_from_var;
		$email_status = " YOU DO NOT NEED TO REPLY THIS EMAIL.";
	}
	if($your_subject_result == "" || $your_subject_result == "  Subject")
	{
		$your_subject_result = "No subject";
	}
	if($your_subject && $your_subject_result && $email_to && $email_text && $email_text_result && $user_ip)
	{
		//
		$msg = "";
		mysql_query("DELETE FROM secure WHERE event_date <> '$event_date'");
		$result = mysql_query("SELECT * FROM secure WHERE user_ip = '$user_ip'",$db);
		if($myrow = mysql_fetch_array($result))
		{
			$email_count = $myrow["email_count"];
			$email_count = $email_count + 1;
			if($email_count < $max_email)
			{
				mysql_query("UPDATE secure SET email_count = '$email_count' WHERE user_ip = '$user_ip'");
				// email total
				$result = mysql_query("SELECT * FROM sms_statics",$db);
				if($myrow = mysql_fetch_array($result))
				{
					$email_total = $myrow["email_total"];
					$email_total = $email_total + 1;
					mysql_query("UPDATE sms_statics SET email_total = '$email_total'");
				}
				//
				//mail();
				include("send_email_config.php");
				$svariant = "send_email";
				include($sfile_url);
				$msg = "Email has sent (".$email_to.") (".$send_time.")";
			}
			else
			{
				$msg = "Email has not sent";
			}
		}
		else
		{
			mysql_query("INSERT INTO secure values('','$user_ip','','','','1','$event_date')");
			// email total
			$result = mysql_query("SELECT * FROM sms_statics",$db);
			if($myrow = mysql_fetch_array($result))
			{
				$email_total = $myrow["email_total"];
				$email_total = $email_total + 1;
				mysql_query("UPDATE sms_statics SET email_total = '$email_total'");
			}
			//
			//mail();
			include("send_email_config.php");
			$svariant = "send_email";
			include($sfile_url);
			$msg = "Email has sent (".$email_to.") (".$send_time.")";
		}
		
	}
	else
	{
		$msg = "Email has not sent";
	}
}
mysql_close();
?>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
<link href="../js_css/iframe.css" rel="stylesheet">
</head>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" bgcolor="#1AB9F1">
<script language="javascript" src="../js_css/javascript.js"></script>
<form name="form1" action="<?=$_SERVER['REQUEST_URI']?>" method="POST">
<table border="0" width="297" id="table1" cellspacing="0" cellpadding="0">
	<tr>
		<td height="19" colspan="2" width="297">
		<img border="0" src="../img/title/send_email.jpg" width="196" height="19"></td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="eng"><input type=text class="in_eng" name="your_subject" size="15" value="  Subject" maxlength="10" onfocus="input_empty('your_subject','Subject');" style="color:#DDDDDD">&nbsp;</td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="eng">
		<input type=text class="in_eng" name="email_to" size="21" value="  Email" maxlength="30" onfocus="input_empty('email_to','Email');">&nbsp;
		<input type=text class="in_eng" name="email_from" size="20" value="  Your email" maxlength="30" onfocus="input_empty('email_from','Your email');" style="color:#DDDDDD">&nbsp;</td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="eng">
		<textarea name="email_text" cols="43" rows="6" class="in_eng" onfocus="input_empty('email_text','Text');" ondblclick="text_replace_email();"  onfocus="text_replace_email();"  onkeypress="text_replace_email();"  onkeydown="text_replace_email();"  onkeyup="text_replace_email();"    onkeyup="text_replace_email();" onselect="text_replace_email();"  onblur="text_replace_email();" onclick="text_replace_email();"><?php if(@$i2 != ""){echo(@$i2);}else{echo('Text');}?></textarea>
		<input type="hidden" name="email_text_result" value="">
		<input type="hidden" name="your_subject_result" value="">
		<input type="hidden" name="sta_geo" id="sta_geo" value="eng">
		</td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="eng">
		&nbsp;<input type=button class="bu_eng3" name="send" value="Send" style="cursor:hand;" onclick="send_email();">&nbsp;&nbsp;
		<input type=text class="in_eng" name="symbols_number" size="5" value="" maxlength="3" readonly></td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="eng_s" align="center">&nbsp;<?=@$msg?></td>
	</tr>
</table>
</form>
</body>

</html>