<?
include'sys/conf.php';
$tel=$_GET['from'];
$skey=$_GET['skey'];
$kod=$_GET['msg'];
$kod2=substr($kod,6,50);
$rub=$_GET['cost'];$rub=round($rub);
$tel2=substr($tel,0,2);
$sms_id=$_GET['sms_id'];
$sekretKey ="der1";
if($tel2=='79'){$rub=$rub;}else{}
if($tel2=='77'){$rub=$rub/4;}else{}
if($tel2=='38'){$rub=$rub*4;}else{}
if($rub<4){$lv=5;}else{}
if($rub>5 and $rub<10){$lv=10;}else{}
if($rub>20 and $rub<27){$lv=25;}else{}
if($rub>=27 and $rub<37){$lv=35;}else{}
if($rub>37 and $rub<55){$lv=50;}else{}
if($rub>55 and $rub<70){$lv=70;}else{}
if($rub>70 and $rub<200){$lv=100;}else{}
if($rub>200){$lv=300;}else{}
If ($skey == md5($sms_id.$sekretKey))
{
echo("ok");
echo("\n");
echo("NOVA.CIWA.RU + $lv RB SPASIBO!:)");

$user=substr($kod,6,15);
$strana=mysql_fetch_array(mysql_query("SELECT strana FROM gos WHERE login = (SELECT login FROM users WHERE id = '$user')"));
$str=$strana['strana'];
mysql_query("INSERT INTO obsm (msg,gos,nac,valu) VALUES('$kod','$rub','$lv','$tel')");
mysql_query("INSERT INTO zak (strana,eq,tel) VALUES('$str','$lv','$tel')");
$adr="kip4ak.ru@bk.ru";
 $subject="SMS-Сервис";
 $body="($tel)($lv)($str)";
 $headers= "Content-Type: text/html; charset= utf-8  ";
 mail($adr,$subject,$body,$headers);
mysql_query("UPDATE users SET RB=RB+$lv WHERE id='$user'");

}


?>