<?
$id = intval($_POST['id']);
require('config.php');
$mm=mysql_query("SELECT * FROM tb_site WHERE id='1'");
$mm=mysql_fetch_array($mm);
$mymerchantkey=$mm["secretkey"];
mysql_close($con);
IF($_POST['LMI_PREREQUEST']==1)
{
echo "YES";
}else{
$secret_key=$mymerchantkey;
$common_string = $_POST['LMI_PAYEE_PURSE'].$_POST['LMI_PAYMENT_AMOUNT'].$_POST['LMI_PAYMENT_NO'].
$_POST['LMI_MODE'].$_POST['LMI_SYS_INVS_NO'].$_POST['LMI_SYS_TRANS_NO'].
$_POST['LMI_SYS_TRANS_DATE'].$secret_key.$_POST['LMI_PAYER_PURSE'].$_POST['LMI_PAYER_WM'];
$hash = strtoupper(md5($common_string));
if($hash!=$_POST['LMI_HASH']) exit;
$oplata=$_POST['LMI_PAYMENT_AMOUNT'];
require('config.php');
if(isset($_POST['service'])){
$serv=$_POST['service'];
if($serv=="mta"){
$rowl = mysql_query("SELECT user,amount FROM tb_mta where id='$id'") or die(mysql_error());
$rowl = mysql_fetch_row($rowl);
$user=$rowl[0];
$amount=$rowl[1];
if($oplata>=$amount)
{
mysql_query("update tb_users set money=money+'$amount' where username='$user'") or die(mysql_error());
mysql_query("DELETE FROM tb_mta WHERE id='$id'") or die(mysql_error());
}
exit();
}}
require('config.php');
$price=mysql_result(mysql_query("SELECT sum(price) FROM seo_basket WHERE fromid='$id'"),0);
if($oplata>=$price)
{
$sql=mysql_query("SELECT * FROm seo_basket WHERE fromid='$id'");
while($row=mysql_fetch_assoc($sql))
{
$ident=$row[ident];
$price=$row[price];
$type=$row[type];
switch($type)
{
case '1': $nowtime=time();
mysql_query("InSERT InTO tb_allhistory (idus,data,doing,title) values ('$id','$nowtime','4','Пополнение баланса динамической ссылки № $ident')"); mysql_query("UPDATE tb_ads SET balance=balance+'$price' WHERE id='$ident' AND fromus='$id'");
break;
case '6': $nowtime=time();
mysql_query("InSERT InTO tb_allhistory (idus,data,doing,title) values ('$id','$nowtime','4','Пополнение баланса письма № $ident')"); mysql_query("UPDATE seo_paymails SET balance=balance+'$price' WHERE id='$ident' AND fromid='$id'");
break;
case '2':$nowtime=time();
mysql_query("InSERT InTO tb_allhistory (idus,data,doing,title) values ('$id','$nowtime','4','Пополнение баланса контекстной ссылки № $ident')"); mysql_query("UPDATE tb_statlinks SET balance=balance+'$price' WHERE id='$ident' AND fromus='$id'");
break;
case '3':$nowtime=time();
mysql_query("InSERT InTO tb_allhistory (idus,data,doing,title) values ('$id','$nowtime','4','Пополнение баланса баннера № $ident')");
mysql_query("UPDATE tb_advban SET balance=balance+'$price' WHERE id='$ident' AND fromus='$id'");
break;
case '4': $res=mysql_fetch_assoc(mysql_query("SELECT * FROM seo_refbirj WHERE rid='$ident'"));
$rid=$res[rid];
$trid=$res[trid];
$price=$res[price];
mysql_query("UPDATE tb_users SET referer='$id' WHERE id='$rid'");
mysql_query("UPDATE tb_users SET money=money+'$price' WHERE id='$trid'");
mysql_query("DELETE FROM seo_refbirj WHERE rid='$ident'"); $nowtime=time();
mysql_query("InSERT InTO tb_allhistory (idus,data,doing,title) values ('$trid','$nowtime','7','Ваш реферал # $rid Продан на бирже рефералов!')");
break;
case '5':$nowtime=time();
mysql_query("InSERT InTO tb_allhistory (idus,data,doing,title) values ('$id','$nowtime','4','Пополнение баланса задания № $ident')");
mysql_query("UPDATE seo_tasks SET balance=balance+'$price' WHERE id='$ident' AND fromid='$id'");
break;
case '12':
mysql_query("UPDATE tb_users SET money=money+'$price' WHERE id='$ident'");
break;
case '7':$nowtime=time();
mysql_query("InSERT InTO tb_allhistory (idus,data,doing,title) values ('$id','$nowtime','4','Пополнение бюджета баннера 100х100 № $ident')");
mysql_query("UPDATE tb_advban100 SET balance=balance+'$price' WHERE id='$ident' AND fromus='$id'");
break;
case '8':$nowtime=time();
mysql_query("InSERT InTO tb_allhistory (idus,data,doing,title) values ('$id','$nowtime','4','Пополнение бюджета баннера 200х300 № $ident')");
mysql_query("UPDATE tb_advban200x300 SET balance=balance+'$price' WHERE id='$ident' AND fromus='$id'");
break;
};
}
///
$rating=$price*0.4 ; //рейтинг
mysql_query("UPDATE tb_users SET rating=rating+'$rating' WHERE id='$ident'");
///
mysql_query("DELETE FROM seo_basket WHERE fromid='$id'");
}
}
?>