<?php
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
include "config.php";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
include "functions.php";

if ($user['room'] != 650) {
    header("Location: main.php");
    die();
}

if ($user['battle'] != 0) {
    header('location: fbattle.php');
    die();
}
if ($_GET['id']) {
    echo "Пробуем перейти на выбранную замковую улицу...";
    $_SESSION["klan"] = $_GET['klan'];
    $a = $_GET['klan'];
    mysql_query("UPDATE `users`,`online` SET `users`.`room` = '651',`online`.`room` = '651' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}'");
    header("location: city.php");


} else {
?>
<HTML>
<HEAD>
    <link rel=stylesheet type="text/css" href="css/main.css">
    <meta content="text/html; charset=utf-8" http-equiv=Content-type>
    <META Http-Equiv=Cache-Control Content=no-cache>
    <meta http-equiv=PRAGMA content=NO-CACHE>
    <META Http-Equiv=Expires Content=0>
</HEAD>
<body leftmargin=5 topmargin=5 marginwidth=5 marginheight=5 bgcolor=#d4d4d4>
<table border=0 width=100% cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <FORM action="city.php?cp=1" method=GET>
    <tr>
        <td width="100%"><h3>Переход к клановым улицам</td>
        <td align=right width="50">
            <INPUT TYPE="submit" onclick="location.href('city.php?strah=1');" value="Вернуться" name="strah"></td>
    </tr>
    </FORM>
    </td></tr></table>
<table border=0 width=100% cellspacing="0" cellpadding="0" bgcolor="#A5A5A5">
    <tr>
        <td>
            <table border=0 width=100% cellspacing="0" cellpadding="3" bgcolor="#d4d2d2">
                <tr>
                    <td align="center" bgcolor="#A5A5A6"><b>На данный момент свои замки имеют такие кланы:</b></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td align="center"></td>
    </tr>
    <tr>
        <td align="center" width="100%"><!--Список клан улиц-->
            <table border="0" width="100%" cellpadding="2" cellspacing="1" bgcolor="c7c7c7">
                <tr>
                    <td width="100%" valign="top">
                        <?


                        $id = mysql_query("SELECT * FROM `clans` WHERE `zamok`='2';");
                        $clans = mysql_num_rows($id);       //считуем кол-во кланов

                        $check = mysql_query("SELECT * FROM `clans` WHERE `zamok` = '2';");

                        //$check="0";
                        while ($shor = mysql_fetch_array($check)) {

                            if ($shor)
                                $short = $shor['short'];    //получили название клана(короткое)
                            $id = $shor['id'];
                            $b = $shor['homepage'];

                            echo "<img src='i/klan/$short.gif'><b><a href='/encicl/index.php?section=99&page=clans1&clan=$short' target='_blank'>$short</b></a>";

                            echo '  <form action="ul_clans.php" method="GET">';
                            echo "<input name='klan' type='hidden' value='$id'>";
                            echo '
 <input type="submit" name="id" value=Перейти к замку1>
 </form><hr>
 ';


                        }
                        }
                        ?>
                        <center>
                            </FORM>
                    </td>
                    <td><img src="i/city/klans/klan_street_select.gif"/></td>
                </tr>
            </table>
    </tr>
</table>
</body>
</HTML>