<?
include_once '../../../sys/inc/start.php';
include_once '../../../sys/inc/compress.php';
include_once '../../../sys/inc/sess.php';
include_once '../../../sys/inc/home.php';
include_once '../../../sys/inc/settings.php';
include_once '../../../sys/inc/db_connect.php';
include_once '../../../sys/inc/ipua.php';
include_once '../../../sys/inc/fnc.php';
include_once '../../../sys/inc/adm_check.php';
include_once '../../../sys/inc/user.php';

only_reg();

$key = abs(intval($_GET['key']));

if ($_SESSION['s_code'] == $key && isset($user))$dostup = true; else {header('Location: /index.php'); exit;}

$set['title'] = 'Новая добыча';

if ($_SESSION['s_rand'] == 10)
{
	$name = 'Курицу';
	$balls = 50;
}
elseif ($_SESSION['s_rand'] == 20)
{
	$name = 'Корову';
	$balls = 100;
}
elseif ($_SESSION['s_rand'] == 30)
{
	$name = 'Цыпленка';
	$balls = 50;
}
elseif ($_SESSION['s_rand'] == 40)
{
	$name = 'Лошадку';
	$balls = 100;
}
elseif ($_SESSION['s_rand'] == 50)
{
	$name = 'Поросенка';
	$balls = 100;
}
elseif ($_SESSION['s_rand'] == 60)
{
	$name = 'Ящерицу';
	$balls = 50;
}
elseif ($_SESSION['s_rand'] == 70)
{
	$name = 'Рыбку';
	$balls = 50;
}
elseif ($_SESSION['s_rand'] == 80)
{
	$name = 'Лису';
	$balls = 100;
}
elseif ($_SESSION['s_rand'] == 90)
{
	$name = 'Черепаху';
	$balls = 105;
}
elseif ($_SESSION['s_rand'] == 100)
{
	$name = 'Улитку';
	$balls = 50;
}

// Начисление
mysql_query("UPDATE `user` SET `balls` = `balls` + '$balls', `zagon_stat` = `zagon_stat` + '1' WHERE `id` = '" . $user['id'] . "'");

mysql_query("INSERT INTO `zagon` (`id_user`, `num`, `time`, `cena`) values('$user[id]', '$_SESSION[s_rand]', '$time', '$balls')"); 

$fortuna = 0;


include_once '../../../sys/inc/thead.php';
title();
aut();
err();

echo '<div class="foot">';
echo '<a href="/plugins/games/index.php">Онлайн игры</a> | <a href="/plugins/games/zagon/index.php">Скотный двор</a> | <b>Добыча</b>';
echo '</div>';

echo '<div class="mess">';
echo 'Вы поймали <img src="img/' . ($_SESSION['s_rand']) . '.png" alt="' . $name . '"/> <font color="blue">' . $name . '</font> вам начислено <font color="green">' . $balls . '</font> баллов';
echo '</div>';

echo '<div class="foot">';
echo '<a href="/plugins/games/index.php">Онлайн игры</a> | <a href="/plugins/games/zagon/index.php">Скотный двор</a> | <b>Добыча</b>';
echo '</div>';

// Обнуляем
$_SESSION['s_code'] = rand( 1111, 9999 );
$_SESSION['s_rand'] = null;

include_once '../../../sys/inc/tfoot.php';
?>