<?
require_once('conf/dbc.php');
require_once('conf/session_start.php');
$page_title='Покупка рублей';
require_once('conf/head.php');
 require_once('conf/top.php');
include_once 'PAYconfig.php';
header('location: paysuccess.php');
//------//
if (isset($_POST['id_shop']) && is_numeric($_POST['id_shop']) && isset($_POST['id_bill']) && is_numeric($_POST['id_bill']) && isset($_POST['summa']) && is_numeric($_POST['summa']) && isset($_POST['hash']))
	{
$sql=mysqli_query($dbc,"SELECT * FROM `worldkassa` WHERE `id_bill` = '".$_POST['id_bill']."'");
$data=$sql->fetch_assoc();
		if ($_POST['summa']<$data['summa']){echo'<font color=red>Подмену суммы пополнения</font>';
require_once('conf/navig.php');
require_once('conf/foot.php');
exit();	
	}
			elseif($_POST['hash']!=md5($hash.$id_shop.$_POST['id_bill'].$_POST['summa'])){echo'<font color=red>НЕ совпал хеш</font>';
require_once('conf/navig.php');
require_once('conf/foot.php');
exit();	
			}
}
$dpro = $pdo->query("SELECT FROM users WHERE id='".$data['id_user']."'")->fetch_assoc();
if($dpro['vip']==0){
$timepro = (time()+604800);}else{
$timepro = 604800;
}
$time=time();
$pdo->exec("UPDATE `worldkassa` SET `time_oplata` = '$time' WHERE `id` = '".$data['id']."'");
$pdo->exec("UPDATE `users` SET `money` = `money`+'".$data['rub']."' WHERE `id` = '".$data['id_user']."'");
if($data[rub]>199){
$pdo->exec("UPDATE `users` SET `vip` = '1', `viptime` = `viptime`+'".$timepro."' WHERE `id` = '".$data['id_user']."'");
$pdo->exec("UPDATE `users` SET `money` = `money`+'50' WHERE `id` = '".$data['id_user']."'");
}

require_once('conf/navig.php');
require_once('conf/foot.php');
?>