<?php
include('../inc/conf.php');
ini_set('session.use_cookies', 'On');
ini_set('session.use_trans_sid', 'Off');
session_set_cookie_params(604800000, "/", SITE, false, false);
session_start();
if (!isset($_SESSION["uid"])){
echo "5";
exit;
}
if(isset($_POST['sum'])){
if(!empty($_POST['sum'])){
$uid = intval($_SESSION["uid"]);
$sum = preg_replace("#[^\.\-0-9]+#i",'',mysqli_real_escape_string($connect_db, $_POST["sum"]));
$nb = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT bal FROM t_users WHERE uid='$uid'"));
$nbal = $nb['bal'];
if ($nbal < $sum) { echo '3'; exit; }
if ($sum < 1) { echo '2'; exit; }
$dt = time();
$sume = $sum*$prcsum;
$jack = $sum*$prcjack;
mysqli_query($connect_db, "INSERT INTO `t_play` (usr,sum,dt) VALUES ('$uid','$sum','$dt')");
mysqli_query($connect_db, "UPDATE `t_users` SET `bal` = `bal`-'$sum' WHERE uid = '$uid'");
mysqli_query($connect_db, "UPDATE `t_data` SET `nowg` = `nowg`+'$sume', `jack` = `jack`+'$jack' LIMIT 1");
$isp = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT endgame FROM t_data LIMIT 1"));
if ($isp['endgame'] == 0) {
$how = mysqli_num_rows(mysqli_query($connect_db, "SELECT id FROM t_play GROUP BY `usr`"));
$ptime = $timemin*60;
if ($how > 1) { $dte = time()+$ptime; mysqli_query($connect_db, "UPDATE `t_data` SET `ngame` = `ngame`+1, `endgame` = '$dte' LIMIT 1"); }
}
echo '1';
} else { echo '0'; }
} else { echo '6'; }
?>