<?php
#  Mod by : Marvin             
#  ICQ : 404969090

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/user.php';


$set['title']='Онлайн город'; // заголовок страницы

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

$gconf=mysql_fetch_array(mysql_query("SELECT * FROM `gorod_conf`"));

if(isset($user)){
if($gconf[0]['open']!=1){


echo '<b><font color="red">Бандит</font></b><br/>';

$sum=0;
$action=htmlspecialchars(trim($_GET['action']));


switch ($action){


default:
echo 'Любишь азарт? А выигрывая, чувствуешь адреналин? Играй и получай призы<br><br>';
 
echo'- <img src="bandit/1.gif" alt=""> <img src="bandit/2.gif" alt=""> <img src="bandit/3.gif" alt=""> -<br>';  
echo'- <img src="bandit/7.gif" alt=""> <img src="bandit/7.gif" alt=""> <img src="bandit/7.gif" alt=""> -<br>';  
echo'- <img src="bandit/4.gif" alt=""> <img src="bandit/5.gif" alt=""> <img src="bandit/6.gif" alt=""> -<br>';  
    
if($user['balls']<100){echo 'У тебя не достаточно баллов!';
}else{
echo '&#187; <a href="bandit.php?action=go">Играть</a></b><br>';    
};
break;



case 'go':

if ($user['balls']<100){
echo $user['nick'].', у тебя мало баллов. <br/>';
}else{
if(!$_SESSION['go'] || !$_SESSION['try']){
mysql_query("UPDATE `user` SET `balls`=`balls`-5 WHERE `id`='".$user['id']."'");
$_SESSION['go']='ok';
};
$num1 = mt_rand(1, 8);
$num2 = mt_rand(1, 8);
$num3 = mt_rand(1, 8);
$num4 = mt_rand(1, 8);
///////уменьшаем шанс выпадения 7 в центре
$num_a= mt_rand(1, 6);
$num_b= mt_rand(1, 8);
$num_d = array($num_a, $num_b);
$num_e = mt_rand(0, 1); 
$num5 = $num_d[$num_e];
///////
$num6 = mt_rand(1, 8);
$num7 = mt_rand(1, 8);
$num8 = mt_rand(1, 8);
$num9 = mt_rand(1, 8);

$rand = mt_rand(100, 999);

echo'- <img src="bandit/'.$num1.'.gif" alt=""> <img src="bandit/'.$num2.'.gif" alt=""> <img src="bandit/'.$num3.'.gif" alt=""> -<br>';
echo'- <img src="bandit/'.$num4.'.gif" alt=""> <img src="bandit/'.$num5.'.gif" alt=""> <img src="bandit/'.$num6.'.gif" alt=""> -<br>'; 
echo'- <img src="bandit/'.$num7.'.gif" alt=""> <img src="bandit/'.$num8.'.gif" alt=""> <img src="bandit/'.$num9.'.gif" alt=""> -<br>'; 

/////////////////////////////////линии//////////////////////////////
if ($num1 == 1 and $num2 == $num1 and $num3 == $num1) {echo'Вишенки-вехний ряд<br>'; $sum+="5";}
if ($num4 == 1 and $num5 == $num4 and $num6 == $num4) {echo'Вишенки-средний ряд<br>'; $sum+="10";}
if ($num7 == 1 and $num8 == $num7 and $num9 == $num7) {echo'Вишенки-нижний ряд<br>';  $sum+="5";}

if ($num1 == 2 and $num2 == $num1 and $num3 == $num1) {echo'Апельсины-вехний ряд<br>'; $sum+="10";}
if ($num4 == 2 and $num5 == $num4 and $num6 == $num4) {echo'Апельсины-средний ряд<br>'; $sum+="15";}
if ($num7 == 2 and $num8 == $num7 and $num9 == $num7) {echo'Апельсины-нижний ряд<br>'; $sum+="10";}

if ($num1 == 3 and $num2 == $num1 and $num3 == $num1) {echo'Виноград-вехний ряд<br>'; $sum+="15";}
if ($num4 == 3 and $num5 == $num4 and $num6 == $num4) {echo'Виноград-средний ряд<br>'; $sum+="25";}
if ($num7 == 3 and $num8 == $num7 and $num9 == $num7) {echo'Виноград-нижний ряд<br>'; $sum+="15";}

if ($num1 == 4 and $num2 == $num1 and $num3 == $num1) {echo'Бананы-вехний ряд<br>'; $sum+="25";}
if ($num4 == 4 and $num5 == $num4 and $num6 == $num4) {echo'Бананы-средний ряд<br>'; $sum+="35";}
if ($num7 == 4 and $num8 == $num7 and $num9 == $num7) {echo'Бананы-нижний ряд<br>'; $sum+="25";}

if ($num1 == 5 and $num2 == $num1 and $num3 == $num1) {echo'Яблоки-вехний ряд<br>'; $sum+="30";}
if ($num4 == 5 and $num5 == $num4 and $num6 == $num4) {echo'Яблоки-средний ряд<br>'; $sum+="50";}
if ($num7 == 5 and $num8 == $num7 and $num9 == $num7) {echo'Яблоки-нижний ряд<br>'; $sum+="30";}

if ($num1 == 6 and $num2 == $num1 and $num3 == $num1) {echo'BAR-вехний ряд<br>'; $sum+="50";}
if ($num4 == 6 and $num5 == $num4 and $num6 == $num4) {echo'BAR-средний ряд<br>'; $sum+="70";}
if ($num7 == 6 and $num8 == $num7 and $num9 == $num7) {echo'BAR-нижний ряд<br>'; $sum+="55";}

if ($num1 == 7 and $num2 == $num1 and $num3 == $num1) {echo'777-вехний ряд<br>'; $sum+="177";}
if ($num4 == 7 and $num5 == $num4 and $num6 == $num4) {echo'777-средний ряд<br>'; $sum+="777";}
if ($num7 == 7 and $num8 == $num7 and $num9 == $num7) {echo'777-нижний ряд<br>'; $sum+="177";}

if ($num1 == 8 and $num2 == $num1 and $num3 == $num1) {echo'$$$-вехний ряд<br>'; $sum+="60";}
if ($num4 == 8 and $num5 == $num4 and $num6 == $num4) {echo'$$$-средний ряд<br>'; $sum+="100";}
if ($num7 == 8 and $num8 == $num7 and $num9 == $num7) {echo'$$$-нижний ряд<br>'; $sum+="60";}

/////////////////////////////////столбцы//////////////////////////////


if ($num1 == 1 and $num4 == $num1 and $num7 == $num1) {echo'Вишенки-левый столбец<br>';  $sum+="5";}
if ($num2 == 1 and $num5 == $num2 and $num8 == $num2) {echo'Вишенки-средний столбец<br>';  $sum+="10";}
if ($num3 == 1 and $num6 == $num3 and $num9 == $num3) {echo'Вишенки-правый столбец<br>';  $sum+="5";}

if ($num1 == 2 and $num4 == $num1 and $num7 == $num1) {echo'Апельсины-левый столбец<br>'; $sum+="10";}
if ($num2 == 2 and $num5 == $num2 and $num8 == $num2) {echo'Апельсины-средний столбец<br>'; $sum+="15";}
if ($num3 == 2 and $num6 == $num3 and $num9 == $num3) {echo'Апельсины-правый столбец<br>'; $sum+="10";}

if ($num1 == 3 and $num4 == $num1 and $num7 == $num1) {echo'Виноград-левый столбец<br>'; $sum+="15";}
if ($num2 == 3 and $num5 == $num2 and $num8 == $num2) {echo'Виноград-средний столбец<br>'; $sum+="25";}
if ($num3 == 3 and $num6 == $num3 and $num9 == $num3) {echo'Виноград-правый столбец<br>'; $sum+="15";}

if ($num1 == 4 and $num4 == $num1 and $num7 == $num1) {echo'Бананы-левый столбец<br>'; $sum+="25";}
if ($num2 == 4 and $num5 == $num2 and $num8 == $num2) {echo'Бананы-средний столбец<br>'; $sum+="40";}
if ($num3 == 4 and $num6 == $num3 and $num9 == $num3) {echo'Бананы-правый столбец<br>'; $sum+="25";}

if ($num1 == 5 and $num4 == $num1 and $num7 == $num1) {echo'Яблоки-левый столбец<br>'; $sum+="40";}
if ($num2 == 5 and $num5 == $num2 and $num8 == $num2) {echo'Яблоки-средний столбец<br>'; $sum+="75";}
if ($num3 == 5 and $num6 == $num3 and $num9 == $num3) {echo'Яблоки-правый столбец<br>'; $sum+="40";}

if ($num1 == 6 and $num4 == $num1 and $num7 == $num1) {echo'BAR-левый столбец<br>'; $sum+="75";}
if ($num2 == 6 and $num5 == $num2 and $num8 == $num2) {echo'BAR-средний столбец<br>'; $sum+="100";}
if ($num3 == 6 and $num6 == $num3 and $num9 == $num3) {echo'BAR-правый столбец<br>'; $sum+="75";}

if ($num1 == 7 and $num4 == $num1 and $num7 == $num1) {echo'777-левый столбец<br>'; $sum+="100";}
if ($num2 == 7 and $num5 == $num2 and $num8 == $num2) {echo'777-средний столбец<br>'; $sum+="150";}
if ($num3 == 7 and $num6 == $num3 and $num9 == $num3) {echo'777-правый столбец<br>'; $sum+="100";}

if ($num1 == 8 and $num4 == $num1 and $num7 == $num1) {echo'$$$-левый столбец<br>'; $sum+="150";}
if ($num2 == 8 and $num5 == $num2 and $num8 == $num2) {echo'$$$-средний столбец<br>'; $sum+="200";}
if ($num3 == 8 and $num6 == $num3 and $num9 == $num3) {echo'$$$-правый столбец<br>'; $sum+="150";}

///////////////////// по диагонали /////////////////////////////////////////

if ($num1 == 1 and $num5 == $num1 and $num9 == $num1) {echo'Вишенки-по диагонали<br>';  $sum+="5";}
if ($num3 == 1 and $num5 == $num3 and $num7 == $num3) {echo'Вишенки-по диагонали<br>';  $sum+="5";}

if ($num1 == 2 and $num5 == $num1 and $num9 == $num1) {echo'Апельсины-по диагонали<br>';  $sum+="10";}
if ($num3 == 2 and $num5 == $num3 and $num7 == $num3) {echo'Апельсины-по диагонали<br>';  $sum+="10";}

if ($num1 == 3 and $num5 == $num1 and $num9 == $num1) {echo'Виноград-по диагонали<br>';  $sum+="15";}
if ($num3 == 3 and $num5 == $num3 and $num7 == $num3) {echo'Виноград-по диагонали<br>';  $sum+="15";}

if ($num1 == 4 and $num5 == $num1 and $num9 == $num1) {echo'Бананы-по диагонали<br>';  $sum+="25";}
if ($num3 == 4 and $num5 == $num3 and $num7 == $num3) {echo'Бананы-по диагонали<br>';  $sum+="25";}

if ($num1 == 5 and $num5 == $num1 and $num9 == $num1) {echo'Яблоки-по диагонали<br>';  $sum+="50";}
if ($num3 == 5 and $num5 == $num3 and $num7 == $num3) {echo'Яблоки-по диагонали<br>';  $sum+="50";} 

if ($num1 == 6 and $num5 == $num1 and $num9 == $num1) {echo'BAR-по диагонали<br>';  $sum+="100";}
if ($num3 == 6 and $num5 == $num3 and $num7 == $num3) {echo'BAR-по диагонали<br>';  $sum+="100";}

if ($num1 == 7 and $num5 == $num1 and $num9 == $num1) {echo'777-по диагонали<br>';  $sum+="150";}
if ($num3 == 7 and $num5 == $num3 and $num7 == $num3) {echo'777-по диагонали<br>';  $sum+="150";}

if ($num1 == 8 and $num5 == $num1 and $num9 == $num1) {echo'$$$-по диагонали<br>';  $sum+="333";}
if ($num3 == 8 and $num5 == $num3 and $num7 == $num3) {echo'$$$-по диагонали<br>';  $sum+="333";}


///////////////////// по диагонали /////////////////////////////////////////

if ($num1 == 1 and $num5 == $num1 and $num9 == $num1) {echo'Вишенки-по диагонали<br>';  $sum+="5";}
if ($num3 == 1 and $num5 == $num3 and $num7 == $num3) {echo'Вишенки-по диагонали<br>';  $sum+="5";}

if ($num1 == 2 and $num5 == $num1 and $num9 == $num1) {echo'Апельсины-по диагонали<br>';  $sum+="10";}
if ($num3 == 2 and $num5 == $num3 and $num7 == $num3) {echo'Апельсины-по диагонали<br>';  $sum+="10";}

if ($num1 == 3 and $num5 == $num1 and $num9 == $num1) {echo'Виноград-по диагонали<br>';  $sum+="15";}
if ($num3 == 3 and $num5 == $num3 and $num7 == $num3) {echo'Виноград-по диагонали<br>';  $sum+="15";}

if ($num1 == 4 and $num5 == $num1 and $num9 == $num1) {echo'Бананы-по диагонали<br>';  $sum+="25";}
if ($num3 == 4 and $num5 == $num3 and $num7 == $num3) {echo'Бананы-по диагонали<br>';  $sum+="25";}

if ($num1 == 5 and $num5 == $num1 and $num9 == $num1) {echo'Яблоки-по диагонали<br>';  $sum+="50";}
if ($num3 == 5 and $num5 == $num3 and $num7 == $num3) {echo'Яблоки-по диагонали<br>';  $sum+="50";} 

if ($num1 == 6 and $num5 == $num1 and $num9 == $num1) {echo'BAR-по диагонали<br>';  $sum+="100";}
if ($num3 == 6 and $num5 == $num3 and $num7 == $num3) {echo'BAR-по диагонали<br>';  $sum+="100";}

if ($num1 == 7 and $num5 == $num1 and $num9 == $num1) {echo'777-по диагонали<br>';  $sum+="150";}
if ($num3 == 7 and $num5 == $num3 and $num7 == $num3) {echo'777-по диагонали<br>';  $sum+="150";}

if ($num1 == 8 and $num5 == $num1 and $num9 == $num1) {echo'$$$-по диагонали<br>';  $sum+="333";}
if ($num3 == 8 and $num5 == $num3 and $num7 == $num3) {echo'$$$-по диагонали<br>';  $sum+="333";}


//------------------------------ Запись в профиль ----------------------------//
mysql_query("UPDATE `user` SET `balls`=`balls`+'$sum' WHERE `id`='".$user['id']."'");

echo'<br><b><a href="bandit.php?action=go&amp;rand='.$rand.'&amp;'.SID.'">Играть</a></b><br>';
break;

}
}
echo 'У вас '.$user[balls].' баллов<br/>';
echo'<a href="bandit_faq.php?'.SID.'">Правила игры</a><br/>';
 echo '<div class="msg"><a href="index.php">В город</a></div>';
}
 else
{
echo '<div class="msg">Город закрыт администратором!</div>';};

}else{
echo '<div class="msg">Город доступен только для авторизованых пользователей!</div>'; 
}; 

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