<?php
##########################################
# ~ Разработка отдельных модулей ~~~~~~~ #
# ~ и написание скриптов на php (c)KoT ~ #
# ~ ICQ: 7675072 ~~~~~~~~~~~~~~~~~~~~~~~ #
# ~ Site: 4atlove.ru ~~~~~~~~~~~~~~~~~~~ #
# ~ E-mail: notefree@bk.ru ~~~~~~~~~~~~~ #
##########################################

require( "../config.php" );
$align = 'center';
$title = 'Игровой автомат';
aut();
head();

echo '<br/><form method="POST" action="?">
      <input type="submit" class="ibutton" name="start" value="start"/>
	  </form><br/>';

if (isset($_POST['start'])) {
/*
$array = array(0 => '1', 1 => '2', 2 => '3', 3 => '4', 4 => '5', 5 => '6');

 for($i = 0; $i < 3; $i++) {
 $rand = mt_rand($array[$i], 6);
 echo '<img src="avt/' . $rand . '.png" alt="$"/> ';
 }
*/

if ($user['rur'] < 100) {
echo 'Вам не хватает еще минимум ' . (100 - $user['rur']) . 'р.<br/>';
foot();
exit();
}

$rand_1 = mt_rand(1, 6);
$rand_2 = mt_rand(1, 6);
$rand_3 = mt_rand(1, 6);

if ($rand_1 == 1 && $rand_2 == 1 && $rand_3 == 1) {
$i = '<b style="color:blue"><blink>ДЖЕКПОТ</blink></b>';
$m = 10000;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
}
elseif ($rand_1 == 2 && $rand_2 == 2 && $rand_3 == 2) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 2000;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 3 && $rand_2 == 3 && $rand_3 == 3) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 1700;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 4 && $rand_2 == 4 && $rand_3 == 4) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 1500;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 5 && $rand_2 == 5 && $rand_3 == 5) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 1200;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 6 && $rand_2 == 6 && $rand_3 == 6) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 1000;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 1 && $rand_2 == 1 || $rand_1 == 1 && $rand_3 == 1 || $rand_2 == 1 && $rand_3 == 1) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 600;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 2 && $rand_2 == 2 || $rand_1 == 2 && $rand_3 == 2 || $rand_2 == 2 && $rand_3 == 2) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 500;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 3 && $rand_2 == 3 || $rand_1 == 3 && $rand_3 == 3 || $rand_2 == 3 && $rand_3 == 3) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 300;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 4 && $rand_2 == 4 || $rand_1 == 4 && $rand_3 == 4 || $rand_2 == 4 && $rand_3 == 4) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 100;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 5 && $rand_2 == 5 || $rand_1 == 5 && $rand_3 == 5 || $rand_2 == 5 && $rand_3 == 5) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 50;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
elseif ($rand_1 == 6 && $rand_2 == 6 || $rand_1 == 6 && $rand_3 == 6 || $rand_2 == 6 && $rand_3 == 6) {
$i = '<b style="color:green">Выигрыш</b>';
$m = 25;
mysql_query("UPDATE users SET rur = rur + '".(int)$m."' WHERE id = '$user[id]'");
echo '<form method="POST" action="?">
      <input type="submit" class="ibutton" name="risk" value="риск"/>
	  <input type="hidden" name="nums" value="' . (int)$m . '"/>
	  </form><br/>';
}
else
{
$i = '<b style="color:red">Проигрыш</b>';
$m = 100;
mysql_query("UPDATE users SET rur = rur - '".(int)$m."' WHERE id = '$user[id]'");
}

echo '<img src="avt/' . $rand_1 . '.png" alt="$"/> | 
      <img src="avt/' . $rand_2 . '.png" alt="$"/> | 
	  <img src="avt/' . $rand_3 . '.png" alt="$"/>
	  <br/><br/>
	  ' . $i . ': ' . $m . '
	  <br/><br/>
	  <a href="?"><u>Закончить игру</u></a><br/>';
}

if (isset($_POST['risk'])) {
 $rand_num = mt_rand(1, 3);
 if ($rand_num == 1 || $rand_num == 2) {
 echo '<b style="color:red">Неудача</b> - ' . (int)$_POST['nums'] * 3 . '<br/>';
 $itog = $_POST['nums'] * 3;
 mysql_query("UPDATE `users` SET `rur` = `rur` - '".(int)$itog."' WHERE `id` = '$user[id]'");
 }
elseif ($rand_num == 3) {
 echo '<b style="color:green">Удача</b> + ' . (int)$_POST['nums'] * 3 . '<br/>';
 $itog = $_POST['nums'] * 3;
 mysql_query("UPDATE `users` SET `rur` = `rur` + '".(int)$itog."' WHERE `id` = '$user[id]'");
 }
}

echo '<hr/>';

echo "<a href=\"index.php?\">игры</a><br/>";
echo "<a href=\"../enter.php?\">Прихожая</a><br/>";
foot( );
?>