<?
require( "../config.php" );

$title='Казино';
aut( );
head( );
if (!isset($user['user'])) { exit('Привет!Неее...Тут лазейка прикрыта...');}
who_add( 0, "enter" );

$stavka=check($_POST['stavka']);
$id= $user['id'];
$posts = $user['posts'];
$gposts = $user['gposts'];
$krutim=mt_rand(1,58);
$bar1=mt_rand(0,3);
$bar2=mt_rand(2,4);
$bar3=mt_rand(5,7);
echo "<b>ОБДИРАЛОВКА</b><br />";

$action=check($_GET['action']);
switch ($action){
case 'itog':
if(!$stavka || $stavka<1){
echo "Пустые параметры!<br />\n";
}else if($stavka>$posts){

print "Ставка не должна превышать ".$posts." постов<br/>";

}else {

$num1 = rand(1, 9);
$num_a = rand(1, 6);
$num_b = rand(1, 6);
$num_c = rand(1, 9);
$num_d = array($num_a, $num_b, $num_c);
$num_e = rand(0, 2);
$num2 = $num_d[$num_e];
$num3 = rand(1, 9);
$balls_minus = ($stavka);
$balls_1 = ($stavka*5);
$balls_2 = ($stavka*2);
$balls_3 =($stavka*3);
$balls_4 =($stavka*4);
$balls_5 =($stavka*5);
$balls_6 =($stavka*6);
$balls_7 =($stavka*10);
$balls_8 =($stavka*8);
$balls_9 =($stavka*9);
$balls_73 =($stavka+$stavka+$stavka);
$balls_72 =($stavka+$stavka);

$rurm = $user['posts']-$balls_minus;
$gposts= $user['gposts']-$balls_minus;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
mysql_query('UPDATE `users` SET `gposts` = "'.$gposts.'" WHERE `id` = "'.$user['id'].'"');



echo "Выпали числа:<br/>";
print "[<img src=\"bandit/s$num1.gif\" alt=\"$num1\"/>]";
print "[<img src=\"bandit/s$num2.gif\" alt=\"$num2\"/>]";
print "[<img src=\"bandit/s$num3.gif\" alt=\"$num3\"/>]<br/>";

if ($num1 == 2 and $num2 == 2 and $num3 == 2)
{
$num = rand(1, 70);
$rurm = $user['posts']+$balls_2;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
$gposts= $user['gposts']+$balls_2;
mysql_query('UPDATE `users` SET `gposts` = "'.$gposts.'" WHERE `id` = "'.$user['id'].'"');


echo "<font color=\"red\">Вы выиграли ".$balls_3." постов!</font><br/>";
}
if ($num1 == 4 and $num2 ==4 and $num3 == 4)
{
$num = rand(1, 70);
$rurm = $user['posts']+$balls_4;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
$gposts= $user['gposts']+$balls_4;
mysql_query('UPDATE `users` SET `gposts` = "'.$gposts.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_3." постов!</font><br/>";
}
if ($num1 == 5 and $num2 == 5 and $num3 == 5)
{
$num = rand(1, 70);
$rurm = $user['posts']+$balls_5;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_3." постов!</font><br/>";
}
if ($num1 == 6 and $num2 == 6 and $num3 == 6)
{
$num = rand(1, 3);
$rurm = $user['posts']+$balls_6;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
$gposts= $user['gposts']+$balls_6;
mysql_query('UPDATE `users` SET `gposts` = "'.$gposts.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выйграли ".$balls_6." постов!</font><br/>";
}
if ($num1 == 8 and $num2 == 8 and $num3 == 8 )
{
$rurm = $user['posts']+$balls_8;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
$gposts= $user['gposts']+$balls_8;
mysql_query('UPDATE `users` SET `gposts` = "'.$gposts.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_8."  постов!</font><br/>";
}
if ($num1 == 9 and $num2 == 9 and $num3 == 9)
{
$rurm = $user['posts']+$balls_9;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
$gposts= $user['gposts']+$balls_9;
mysql_query('UPDATE `users` SET `gposts` = "'.$gposts.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_9." постов!</font><br/>";
}
if ($num1 == 1 and $num2 == 1 and $num3 == 1)
{
$num = rand(1, 50);
$rurm = $user['posts']+$balls_1;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
$gposts= $user['gposts']+$balls_1;
mysql_query('UPDATE `users` SET `gposts` = "'.$gposts.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_1." постов!</font><br/>";
}
if ($num1 == 3 and $num2 == 3 and $num3 == 3)
{
$num = rand(1, 70);
$rurm = $user['posts']+$balls_3;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_3." постов!</font><br/>";
}
if ($num1 == 7 and $num2 == 7 and $num3 == 7)
{
$rurm = $user['posts']+$balls_7;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_7." постов!</font><br/>";
}
if ($num2 == 7 and $num3 == 7)
{
$num = rand(1, 18);
$rurm = $user['posts']+$balls_20;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выйграли '.$balls_20.' постов!</font><br/>";
}
if ($num3 == 7)
{
$num = rand(1, 14);
$rurm = $user['posts']+$balls_73;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_73." постов!</font><br/>";
}

if ($num2 == 7)
{
$num = rand(1, 14);
$rurm = $user['posts']+$balls_72;
mysql_query('UPDATE `users` SET `posts` = "'.$rurm.'" WHERE `id` = "'.$user['id'].'"');
echo "<font color=\"red\">Вы выиграли ".$balls_72." постов!</font><br/>";
}


}
break;

default:
if($posts<"3"){
print "У Вас недостаточно постов для игры!<br/>";
print "Необходимо не менее 3 постов<br/>";
}else{
print "У Вас постов: <b>".$posts."</b><br/>";
print "Игровой баланс: <b>".$gposts."</b><br/>";
print "Ваша ставка:<br/>";
print "От 2 до ".$posts."<br/>";
echo '<form action="777.php?action=itog" method="post">';
print "<input name=\"stavka\" title=\"stavka\" maxlength=\"10\"/><br/>";
print "<input type=\"submit\" value=\"Кру барабан\" name=\"enter\"><br/>\n";

}
break;
}

if($action) print "<a href=\"777.php?\">сменить ставку</a><br/>";
echo "<a href=\"index.php?\">игры</a><br/>";
echo "<a href=\"../enter.php?\">Прихожая</a><br/>";
exit;
foot( );
?>