<?php
session_start();
define("PATH", $_SERVER['DOCUMENT_ROOT']);
include(PATH."/core/func.php");
include(PATH."/core/db.php");
include(PATH."/core/set.php");
include(PATH."/core/define.php");
include(PATH."/core/defineset.php");

db_connect();
if(isset($_POST["id"]))
{

	$res = db_query("SELECT * FROM `sapper_games_active` WHERE `id` = '".db_string($_POST["id"])."'");
	if(db_rows($res) != 0)
	{
		$row = db_assoc($res);
		$bank = round($row["summa"],2) * 1.9;
		$t = 300-(time()-$row['dat2']);
		$len = strlen($row["item2"]);
		if($row['dat2'] > time()-300)
		{
			echo "<script type='text/javascript'>game_open_dialog_cont(".$_POST["id"].", ".round($row["summa"],2).", ".$bank.", '".$row["login"]."', '".substr($row["item"], 0, $len)."', '".$row["item2"]."'); $('#game_last_do').show();
            $('.smr_bot_alert').show(); smr_set_timeout_sec(".$t.", ".$_POST["id"].");</script>";
        }
        else echo "<script type='text/javascript'>$('.sapper-".intval($_POST["id"])."').html('Игра не найдена!')</script>";
	} else {
		echo "<script type='text/javascript'>$('.sapper-".intval($_POST["id"])."').html('Игра не найдена!')</script>";
	}
}

db_close();