<?php
	include("vars.php");
	include("db.php");
	include("operator.php");
	$your_name_value_two = "  saxeli";
	
if($_SERVER['REQUEST_METHOD'] == "POST")
{
	if($your_name && $your_name_result && $mobile_number && $prefix != "" && $sms_geo_result && $user_ip)
	{
		$your_name_value = $your_name_result." >";
		$your_name_value_two = $your_name;
		//
		$dline = strlen($sms_geo_result);
		if($dline < $dline_count)
		{
			$sms_geo_result = $sms_geo_result.$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_geo";
				include($sfile_url);
				$msg = "<font face='Tahoma,Arial,Verdana' size='1'>SMS</font>-i gagzavnilia, ".$sms_startnumber[$prefix].$mobile_number." (".$send_time.")";
			}
			else
			{
				$msg = "dRes sakmarisia <font face='Tahoma,Arial,Verdana' size='1'>SMS</font>-ebis gagzavna";
			}
		}
		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_geo";
			include($sfile_url);
			$msg = "<font face='Tahoma,Arial,Verdana' size='1'>SMS</font>-i gagzavnilia,  ".$sms_startnumber[$prefix].$mobile_number." (".$send_time.")";
		}
		
	}
	else
	{
		$msg = "<font face='Tahoma,Arial,Verdana' size='1'>SMS</font>-i ar gaigzavna";
	}
}
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_geo.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="geo">
		<input type=text class="in_geo" name="your_name" size="16" value="<?=$your_name_value_two?>" maxlength="10" onfocus="input_empty('your_name','saxeli');">&nbsp;
		<!--<select name="prefix" class="in_geo">
		<option value="00">prefiqsi</option>
		<?php
			include("prefix.php");
		?>
		</select>-->&nbsp;
		<input type=text class="in_geo" name="mobile_number" size="25" value="  nomeri" maxlength="10" onfocus="input_empty('mobile_number','nomeri');"></td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="geo">
		<textarea name="sms_geo" cols="43" rows="6" class="in_geo" onfocus="input_empty('sms_geo','teqsti');" ondblclick="text_replace();"  onfocus="text_replace();"  onkeypress="text_replace();"  onkeydown="text_replace();"  onkeyup="text_replace();"  onchange="text_replace();"  onblur="text_replace();"><?php if(@$i2 != ""){echo(@$i2);}else{echo('teqsti');}?></textarea>
		<input type="hidden" name="sms_geo_result" value="">
		<input type="hidden" name="your_name_result" value="">
		<input type="hidden" name="sta_geo" id="sta_geo" value="geo">
		</td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="geo">
		&nbsp;<input type=button class="bu_geo3" name="send" value="gagzavna" style="cursor:hand;" onclick="send_geo();">&nbsp;&nbsp;
		<input type=text class="in_geo" name="symbols_number" size="5" value="" maxlength="3" readonly>&nbsp;
		</td>
	</tr>
	<tr>
		<td width="10">&nbsp;</td>
		<td width="287" class="geo_s" align="center">&nbsp;<?=@$msg?><?php include("redirect.php");?></td>
	</tr>
</table>
</form>
</body>

</html>