<?php
	include("vars.php");
	include("db.php");
	include("operator.php");
	$your_name_value_two = "  Name";
	
if($_SERVER['REQUEST_METHOD'] == "POST")
{
	if($your_name && $your_name_result && $mobile_number && $prefix != "" && $sms_eng_result && $user_ip && $sms_eng)
	{
		$your_name_value = $your_name." >";
		$your_name_value_two = $your_name;
		//
		$dline = strlen($sms_eng_result);
		if($dline < $dline_count)
		{
			$sms_eng = $sms_eng.$end_sms_text;
		}
		//
		//$headers = "From: ".$email_from_var." \n";
		//$mobile_email = "995".$prefix.$mobile_number."@sms.ge";
		$headers = "From: ".$email_from_var." \n";
		if($sms_fromemail[$prefix] != "")
		{
			$headers = "From: ".$sms_fromemail[$prefix]." \n";
		}
		$mobile_email = $sms_startnumber[$prefix].$mobile_number.$sms_smsgateway[$prefix];
		//
		if($sms_subject[$prefix] == 1)
		{
			$your_name_value = $mobile_number;
			$mobile_email = $sms_smsgateway[$prefix];
		}
		//
		$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))
		{
			$sms_count = $myrow["sms_count"];
			$sms_count = $sms_count + 1;
			if($sms_count < $max_sms_rn)
			{
				// check sms total
				if($prefix == 2 || $prefix == 3 || $prefix == 4)
				{
					mysql_query("UPDATE secure SET sms_count = '$sms_count' WHERE user_ip = '$user_ip'");
				}
				// sms total
				$result = mysql_query("SELECT * FROM sms_statics",$db);
				$myrow = mysql_fetch_array($result);
				$sms_total = $myrow["sms_total"];
				$sms_total = $sms_total + 1;
				mysql_query("UPDATE sms_statics SET sms_total = '$sms_total'");
				//
				//mail();
				$svariant = "sms_eng";
				include($sfile_url);
				$msg = "SMS has sent, ".$sms_startnumber[$prefix].$mobile_number." (".$send_time.")";
			}
			else
			{
				$msg = "SMS has not sent";
			}
		}
		else
		{
			mysql_query("INSERT INTO secure values('','$user_ip','1','','','','$event_date')");
			// sms total
			$result = mysql_query("SELECT * FROM sms_statics",$db);
			$myrow = mysql_fetch_array($result);
			$sms_total = $myrow["sms_total"];
			$sms_total = $sms_total + 1;
			mysql_query("UPDATE sms_statics SET sms_total = '$sms_total'");
			//
			//mail();
			$svariant = "sms_eng";
			include($sfile_url);
			$msg = "SMS has sent, ".$sms_startnumber[$prefix].$mobile_number." (".$send_time.")";
		}
		
	}
	else
	{
		$msg = "SMS 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-1251">
<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/sms_eng.jpg" width="196" height="19"></td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="eng">
		<select name="prefix" class="in_eng" onchange="onchange_max();">
		<option value="00">GSM Operator</option>
		<?php
			for($i=0;$i<count($sms_operator);$i++)
			{
				$selected = "";
				if($i == $prefix && $_SERVER['REQUEST_METHOD'] == "POST")
				{
					$selected = " selected ";
				}
				$inum = $i + 1;
				echo('<option value="'.$i.'" '.$selected.'>'.$inum.'. '.$sms_operator[$i].'</option>'."\n");
			}
		?>
		</select>
		<?php
			for($i=0;$i<count($sms_operator);$i++)
			{
				echo('<input type="hidden" name="counti'.$i.'" id="counti'.$i.'" value="'.$sms_numbercount[$i].'">'."\n");
			}
		?>
		</td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="eng">
		<input type=text class="in_eng" name="your_name" size="17" value="<?=$your_name_value_two?>" maxlength="10" onfocus="input_empty('your_name','Name');">&nbsp;
		<!--<select name="prefix2" class="in_eng">
		<option value="00">Prefix</option>
		<?php
			include("prefix.php");
		?>
		</select>-->
		<input type=text class="in_eng" name="mobile_number" size="24" value="  Number" maxlength="10" onfocus="input_empty('mobile_number','Number');"></td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="eng">
		<textarea name="sms_eng" cols="43" rows="6" class="in_eng" onfocus="input_empty('sms_eng','Text');" ondblclick="text_replace_eng();"  onfocus="text_replace_eng();"  onkeypress="text_replace_eng();"  onkeydown="text_replace_eng();"  onkeyup="text_replace_eng();"    onkeyup="text_replace_eng();" onselect="text_replace_eng();"  onblur="text_replace_eng();" onclick="text_replace_eng();"><?php if(@$i2 != ""){echo(@$i2);}else{echo('Text');}?></textarea>
		<input type="hidden" name="sms_eng_result" value="">
		<input type="hidden" name="your_name_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_eng();">&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?><?php include("redirect.php");?></td>
	</tr>
</table>
</form>
</body>

</html>