<?php

# Реально работает только хранилище и мастерская?

ob_start("ob_gzhandler");
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
include "config.php";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '" . mysql_real_escape_string($_SESSION['uid']) . "' LIMIT 1;"));
include "functions.php";
$klan = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `short` = '" . mysql_real_escape_string($user['klan']) . "' LIMIT 1;"));
$polno = array();
$polno = unserialize($klan['vozm']);
?>

<HTML>
<HEAD>
    <link rel=stylesheet href="css/main.css">
    <meta charset="utf-8">
    <SCRIPT LANGUAGE="JavaScript" SRC="js/selectlogin.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="js/dialog_029_ru.js"></SCRIPT>
    <STYLE>
        FORM {
            margin: 0;
            padding: 0;
        }

        B {
            color: #003388;
        }

        .dtz {
            display: none;
        }

        body {
            background-color: #dedede;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
            text-align: left;
            font-size: 12px;
            margin-left: 0px;
        }

        td.off {
            background-image: url(i/klan/zamok/klan_img_08.jpg);
        }
    </style>

    <SCRIPT language="JavaScript">
        function w(login, id, align, klan, level, boss, titul, online, block, city, color, icon, rank) {
            var s = '';
            var oTable = document.getElementById('users_table');
            var oTr = oTable.tBodies[0].appendChild(document.createElement('tr'));
            oTr.style.display = (online ? 'block' : 'none');
            oTr.tag = online;
            var oTd = document.createElement('td');
            oTd.width = 400;

            if (!color) color = '000000';
            var icon = '';

            if (!icon || icon == klan) {
                if (klan) {
                    icon = '<IMG SRC="i/klan/' + klan + '.gif" WIDTH=24 HEIGHT=15 ALT="">';
                }
            } else {
                icon = '<IMG SRC="http://img.combats.com/i/misc/tituls/' + icon + '.gif" ALT="">';
            }
            if (block != '' && block != '0') icon = '';
            if (online != 0) {
                if (city != "") {
                    s += '<IMG style="filter:gray()" SRC=i/lock.gif WIDTH=20 HEIGHT=15 ALT="В другом городе">';
                } else {
                    s += '<a href="javascript:top.AddToPrivate(\'' + login + '\',true)"><IMG SRC=i/lock.gif WIDTH=20 HEIGHT=15 ALT="Приватно"></a>';
                }
            } else {
                s += '<IMG SRC="i/offline.gif" WIDTH=20 HEIGHT=15 BORDER=0 ALT="Нет в клубе">';
            }
            if (city != "") {
                s += '<img src="http://img.combats.com/i/misc/forum/fo' + city + '.gif" width=17 height=15>';
            }
            s += ' <IMG SRC=i/align' + align + '.gif WIDTH=12 HEIGHT=15>';
            if (klan != '') {
                s += '<IMG SRC="i/klan/' + klan + '.gif" WIDTH=24 HEIGHT=15 ALT="">'
            }
            s += '<a href="javascript:top.AddTo(\'' + login + '\')" style="COLOR: #003388;">';
            if (online != 0) {
                s += login;
            } else {
                s += '<FONT color=gray><strong>' + login + '</strong>'
            }
            s += '</a>[' + level + ']<a href=/inf.login?' + id + ' target=_blank><IMG SRC=i/inf.gif WIDTH=12 HEIGHT=11 ALT="Информация о персонаже"></a> ';
            oTd.innerHTML = s;
            oTr.appendChild(oTd);
            var oTd = document.createElement('td');
            oTd.align = 'right';
            s = icon;
            if (block != '' && block != '0') {
                s += ' <font color=red><b>заблокирован</b></font> &nbsp; ';
            } else {
                if (boss != '' && boss != '0') {
                    s += ' <b><font color=' + color + '>глава клана</font></b> &nbsp; '
                }
                else {
                    if (titul != '') {
                        s += '<b><font color=' + color + '>' + titul + '</font></b> &nbsp; '
                    }
                }
            }
            if (online == 0) {
                s += '</FONT>'
            }
            ;
            oTd.innerHTML = s;
            oTr.appendChild(oTd);
            var oTd = document.createElement('td');
            s = '';
            oTd.innerHTML = s;
            oTr.appendChild(oTd);
        }

        var TkTZ = '';

        function setTZ(nm, m) {
            if (TkTZ != '') {
                if (!m) document.all(TkTZ).className = 'tz';
                document.all('d' + TkTZ).style.display = 'none';
                document.getElementById(TkTZ.substr(2)).className = 'off';
            }
            TkTZ = nm || 'TZ14';
            document.getElementById(TkTZ.substr(2)).className = 'on';
            if (!m) document.all(TkTZ).className = 'tzSet';
            document.all('d' + TkTZ).style.display = 'inline';
        }

        function mout(obj) {
            if (TkTZ != '' && obj.id != document.getElementById(TkTZ.substr(2)).id) {
                obj.className = 'off';
            }
        }
     </SCRIPT>
</HEAD>
<body background="i/klan/zamok/klan_img_44.jpg">
<div id="mmoves3"
     style="background-color:#FFFFCC; visibility:hidden; z-index: 101; overflow:visible; position:absolute; border-color:#666666; border-style:solid; border-width: 1px; padding: 2px;"></div>
<div id=hint4 class=ahint></div>
<div id=hint3 class=ahint></div>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td height="18" valign="bottom"><img src="i/klan/zamok/klan_img_03.jpg" width="75" height="18"></td>
        <td width="1062" valign="bottom">&nbsp;</td>
        <td width="63" align="right" valign="bottom"><img src="i/klan/zamok/klan_img_0113.jpg" width="59" height="18"
                                                          alt="Вернуться" onmouseover="this.style.cursor = 'hand';"
                                                          onclick="location.href='city.php?strah=1'" title="Вернуться"/>
        </td>
    </tr>
    <tr>
        <td height="32"><img src="i/klan/zamok/klan_s3r3_07.jpg" width="75" height="32"></td>
        <td width="100%" background="i/klan/zamok/klan_img_08.jpg">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr valign=middle>
                    <th height="32"><IMG SRC="/i/klan/<?= $klan['name'] ?>.gif" WIDTH=24 HEIGHT=15></th>
                    <th width="44"><img src="i/klan/zamok/klan_img_09.jpg" width="44" height="32"></th>
                    <td class="off" onmouseover="this.className='on'" onclick="setTZ('TZ7', 1)" onmouseout="mout(this)"
                        id="7"><a href="#">Мастерская</a>
                    </th>
                    <th width="44"><img src="i/klan/zamok/klan_img_13.jpg" width="44" height="32"></th>

                    <td class="off" onmouseover="this.className='on'" onclick="setTZ('TZ17', 1)" onmouseout="mout(this)"
                        id="17"><a href="#">Оружейка</a></td>
                    <th width="44"><img src="i/klan/zamok/klan_img_17.jpg" width="44" height="32"></th>
                    <td class="off" onmouseover="this.className='on'" onclick="setTZ('TZ13', 1)" onmouseout="mout(this)"
                        id="13"><a href="#">
                            <nobr>Абилки</nobr>
                        </a></td>
                    <th width="44"><img src="i/klan/zamok/klan_img_09.jpg" width="44" height="32"></th>
                    <td class="off" onmouseover="this.className='on'" onclick="setTZ('TZ14', 1)" onmouseout="mout(this)"
                        id="14"><a href="#">Колодец</a>
                    </th>
                    <th width="44"><img src="i/klan/zamok/klan_img_11.jpg" width="44" height="32"></th>
                    <td class="off" onmouseover="this.className='on'" onclick="setTZ('TZ11', 1)" onmouseout="mout(this)"
                        id="11"><a href="#">Дипломатия</a></td>

                    <?php echo '<th><img src="http://img.combats.com/i/misc/clans/klan_img_15.jpg" width="44" height="32"></th>
<td class="off" onmouseover="this.className=\'on\'" onclick="setTZ(\'TZ12\', 1)" id="12" onmouseout="mout(this)"><a href="#">Дипломатия </a></td>';
                    ?>

                    <th width="44"><img src="i/klan/zamok/klan_img_19.jpg" width="44" height="32"></th>
                    <td class="off" onmouseover="this.className='on'" onclick="setTZ('TZ18', 1)" onmouseout="mout(this)"
                        id="18"><a href="#">Права</a></td>
                    <th width="44"><img src="i/klan/zamok/klan_img_21.jpg" width="44" height="32"></th>
                    <td class="off" onmouseover="this.className='on'" onclick="setTZ('TZ15', 1)" onmouseout="mout(this)"
                        id="15"><a href="#">О клане</a></td>
                    <th width="44"><img src="i/klan/zamok/klan_img_23.jpg" width="44" height="32"></th>
                    <td class="off" onmouseover="this.className='on'" onclick="setTZ('TZ16', 1)" onmouseout="mout(this)"
                        id="16"><a href="#">Управление</a></td>
                </tr>
            </table>
        </td>
        <td align="right" background="i/klan/zamok/klan_img_08.jpg"><img src="i/klan/zamok/klan_img_25.jpg" width="15"
                                                                         height="32"></td>
    </tr>
    <tr>
        <td background="i/klan/zamok/klan_img_28.jpg" height="12" colspan="5"><img src="i/klan/zamok/klan_img_27.jpg"
                                                                                   width="75" height="12"></td>
    </tr>
    <tr>
        <td background="i/klan/zamok/klan_img_44.jpg" colspan="5">

            <table cellspacing=0 cellpadding=0 width=100%>
                <tr>
                    <td colspan=2><FONT COLOR=red></FONT>&nbsp;</td>
                </tr>
            </table>
            <div class=dtz ID=dTZ11>
                <FIELDSET>
                    <LEGEND><H4>Дипломатия</H4></LEGEND>
                    Дипломатия в разработке...
                </FIELDSET>
            </div>


            <div class=dtz ID=dTZ17>
                <FIELDSET>
                    <LEGEND><H4>Хранилище</H4></LEGEND>
                    <?php
                    //////Хранилище by Thunder(c)

                    if ($_GET['back']) {
                        $it = mysql_fetch_array(mysql_query("SELECT * FROM `clanstorage` WHERE  `owner`='" . mysql_real_escape_string($user['id']) . "', `id` = '" . mysql_real_escape_string($_GET['back']) . "';"));

                        err("<script>setTZ('TZ17', 1)</script>Вы забрали вещь из хранилища.");
                        mysql_query("UPDATE `inventory` SET `owner` = '" . mysql_real_escape_string($user['id']) . "' WHERE `id` = '" . mysql_real_escape_string($it['id_it']) . "';");
                        mysql_query("DELETE FROM `clanstorage` WHERE `id` = '" . mysql_real_escape_string($_GET['back']) . "';");

                        echo "<script>setTZ('TZ17', 1)</script>";
                    }
                    // положить шмотку
                    if ($_GET['add']) {
                        $it = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `setsale` = 0 AND `owner` ='" . mysql_real_escape_string($user['id']) . "' AND `id` = '" . mysql_real_escape_string($_GET['add']) . "';"));
                        if ($it['owner'] == $user['id']) {
                            $skoka = mysql_num_rows(mysql_query("SELECT id FROM `clanstorage` WHERE `klan` = '" . mysql_real_escape_string($user['klan']) . "' ;"));
                            if ($klan['clanlevel'] < 1 && $skoka >= 1) {
                                err("Количество вещей превышает лимит Вашего клана.");
                            } elseif ($klan['clanlevel'] = 1 && $skoka >= 10) {
                                err("Количество вещей превышает лимит Вашего клана.");
                            } elseif ($klan['clanlevel'] = 2 && $skoka >= 30) {
                                err("Количество вещей превышает лимит Вашего клана.");
                            } else {
                                err("Вы положили вещь в хранилище.");
                                mysql_query("UPDATE `inventory` SET `owner` = '' WHERE `id` = '" . mysql_real_escape_string($it['id']) . "';");
                                mysql_query("insert `clanstorage` (`id_it`,`owner`,`klan`) values (" . mysql_real_escape_string($it['id']) . "," . mysql_real_escape_string($user['id']) . ",'" . mysql_real_escape_string($user['klan']) . "');");
                            }
                            echo "<script>setTZ('TZ17', 1)</script>";
                        }
                    }
                    ?>
                    <table width=100% cellpadding=5>
                        <tr>
                            <td>
                                <TABLE width=100% cellpadding=0 cellspacing=0>
                                    <TR bgcolor=#A0A0A0>
                                        <? $data = mysql_query("SELECT * FROM `clanstorage` WHERE `klan` = '" . mysql_real_escape_string($user['klan']) . "' ;");
                                        $tekush = mysql_num_rows($data);
                                        if ($klan['clanlevel'] = 0) {
                                            $vsego = 0;
                                        } elseif ($klan['clanlevel'] = 1) {
                                            $vsego = 10;
                                        } elseif ($klan['clanlevel'] = 2) {
                                            $vsego = 30;
                                        } elseif ($klan['clanlevel'] = 3) {
                                            $vsego = 50;
                                        } else {
                                            $vsego = 50;
                                        }
                                        $oryg_level = $klan['o_level'];
                                        ?>

                                        <TD width=50%>
                                            <table width=100%>
                                                <tr>


                                                    <td width=50%>В хранилище <?= $tekush ?>/<?= $vsego ?></td>
                                                    <td><!--Передачи 0/200-->
                                                        Уровень Оружейки <B><?= $oryg_level ?></B></td>
                                                </tr>
                                            </table>
                                        </TD>
                                        <TD>В рюкзаке</TD>
                                    </TR>
                                    <TR>
                                        <TD valign=top><!--Рюкзак-->
                                            <TABLE WIDTH=100% CELLSPACING=1 CELLPADDING=2 BGCOLOR=A5A5A5>
                                                <?php

                                                if (!$_GET['do']) {
                                                    echo '<TABLE BORDER=0 WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">';
                                                    while ($it = mysql_fetch_array($data)) {
                                                        $row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '" . mysql_real_escape_string($it['id_it']) . "' LIMIT 1;"));
                                                        $row['count'] = 1;
                                                        if ($i == 0) {
                                                            $i = 1;
                                                            $color = '#C7C7C7';
                                                        } else {
                                                            $i = 0;
                                                            $color = '#D5D5D5';
                                                        }
                                                        echo "<TR bgcolor={$color}><TD align=center width=20%><IMG SRC=\"i/sh/{$row['img']}\" BORDER=0>
					<BR><small>
                    Положил:<BR> " . nick::id($it['owner'])->full(1) . " <BR></small>";
                                                        ?>

                                                        <A HREF="?back=<?= $it['id'] ?>">забрать</A><BR>
                                                        </TD>
                                                        <?php
                                                        echo "<TD valign=top>";
                                                        showitem($row);
                                                        echo "</TD></TR>";
                                                    }
                                                    echo "</TABLE></TD><TD valign=top><!--Рюкзак-->
					<TABLE WIDTH=100% CELLSPACING=1 CELLPADDING=2 BGCOLOR=A5A5A5>";
                                                }
                                                $data = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . mysql_real_escape_string($_SESSION['uid']) . "' AND `dressed` = 0  AND `setsale`=0  AND `bs`=0  AND `podzem`=0  AND `type`<50 ORDER BY `update` DESC; ");
                                                while ($row = mysql_fetch_array($data)) {
                                                    $row['count'] = 1;
                                                    if ($i == 0) {
                                                        $i = 1;
                                                        $color = '#C7C7C7';
                                                    } else {
                                                        $i = 0;
                                                        $color = '#D5D5D5';
                                                    }
                                                    echo "<TR bgcolor={$color}><TD align=center style='width:150px'><IMG SRC=\"i/sh/{$row['img']}\" BORDER=0>";
                                                    ?>

                                                    <BR><A HREF="?add=<?= $row['id'] ?>&sid=&sale=1">положить</A><?


                                                    ?>
                                                    </TD>
                                                    <?php
                                                    echo "<TD valign=top>";
                                                    showitem($row);
                                                    echo "</TD></TR>";
                                                }
                                                echo "</table>";
                                                ?>
                                                </TD>
                                                </TR>

                                            </TABLE>
                                        </TD>
                                    </TR>
                                </TABLE>
                            </td>
                        </tr>
                    </table>


                    <br>

            </div>
            <div class=dtz ID=dTZ12>
                <FIELDSET>
                    <LEGEND><H4>Клановые войны</H4></LEGEND>
                    Клановые войны в разработке...
                </FIELDSET>

            </div>

            <div class=dtz ID=dTZ13>
                <FIELDSET>
                    <LEGEND><H4>Реликты клана</H4></LEGEND>
                    Реликты клана в процессе разработки...
                </FIELDSET>
            </div>
            <div class=dtz ID=dTZ14>
                <FIELDSET>
                    <LEGEND><H4>Колодец</H4></LEGEND>
                    Колодец в процессе разработки...
                </FIELDSET>
            </div>
            <div class=dtz ID=dTZ18>
                <FIELDSET>
                    <LEGEND><H4>Ваши права в клане</H4></LEGEND>
                    Права в процессе разработки...
                </FIELDSET>
            </div>

            <div class=dtz ID=dTZ7>
                <FIELDSET>
                    <LEGEND><H4>Мастерская</H4></LEGEND>

                    <?php


                    if ($_GET['mf']) {
                        $row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `type` < 12 AND `type` != 3 AND `owner` = '{$_SESSION['uid']}' AND `dressed` = 0 AND `id` = '{$_GET['mf']}' AND `name` NOT LIKE '% (мф)%'  LIMIT 1;"));
                        if ($user['money'] < $row['cost'] OR !$row) {
                            $err = "<font color=red><b>У вас не хватает денег на модификацию.</b></font>";
                        } else {
                            srand(make_seed());
                            $type = rand(1, 4);
                            $mfintel = round($user['intel'] / 5 - 10);
                            if ($mfintel > -1) {
                                $mfintel = -1;
                            }
                            $statintel = round($user['intel'] / 25 - 2);
                            if ($statintel > -1) {
                                $statintel = -1;
                            }
                            $nstatintel = round(2 - $user['intel'] / 25);
                            if ($nstatintel < 1) {
                                $statintel = 1;
                            }
                            srand(make_seed());
                            $mf1 = rand($mfintel, 10);
                            srand(make_seed());
                            $mf2 = rand($mfintel, 10);
                            srand(make_seed());
                            $st1 = rand($statintel, 2);
                            srand(make_seed());
                            $st2 = rand(-2, $nstatintel);
                            srand(make_seed());
                            $min = rand($statintel, 2);
                            srand(make_seed());
                            $max = rand($statintel, 4);


                            switch ($type) {
                                case 1:
                                    // крит
                                    $mfkrit = $mf1;
                                    $mfantiuvorot = $mf2;
                                    $inta = $st1;
                                    $hp = rand(0, 15);
                                    $ninta = $st2;
                                    break;
                                case 2:
                                    // ловкость
                                    $mfuvorot = $mf1;
                                    $mfantikrit = $mf2;
                                    $lovk = $st1;
                                    $hp = rand(1, 15);
                                    $nlovk = $st2;
                                    break;
                                case 3:
                                    // сила
                                    $mfminu = $min;
                                    $mfmaxu = $max;
                                    $sila = $st1;
                                    $hp = rand(6, 20);
                                    $nsila = $st2;
                                    break;
                                case 4:
                                    // вынос
                                    $nvinos = $st2;
                                    $mfantikrit = $mf1;
                                    $bron1 = rand(0, 3);
                                    $bron2 = rand(0, 3);
                                    $bron3 = rand(0, 3);
                                    $bron4 = rand(0, 3);
                                    $hp = rand(0, 15);
                                    break;
                            }
                            if ($row["ghp"] !== 0) {
                                $hp = true;
                                $shans = rand(7, 9);
                                if ($shans == 7) {
                                    print"shans0";
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $hp = $row["ghp"] / 2;
                                    if ($ssh == 77) {
                                        $hp = $row["ghp"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `ghp` = `ghp`-'" . (int)$hp . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 50);
                                    $hp = $shans;
                                }
                                if ($shans == 9) {
                                    $hp = rand(1, 25);
                                    if (($row["ghp"] - $hp) < 0) {
                                        $hp = $row["ghp"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `ghp` = `ghp`-'" . (int)$hp . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }
                            } else $hp == 0;

//////начала БРОНИ////
                            if ($row["bron1"] != 0) {
                                $bron1 = true;
                                $shans = rand(7, 9);
                                if ($shans == 7) {
                                    print"shans0";
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $bron1 = $row["bron1"] / 2;
                                    if ($ssh == 77) {
                                        $bron1 = $row["bron1"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `bron1` = `bron1`-'" . (int)$bron1 . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 15);
                                    $born1 = $shans;
                                }
                                if ($shans == 9)
                                    $bron1 = rand(1, 5);
                                if (($row["bron1"] - $bron1) < 0) {
                                    $bron1 = $row["bron1"];
                                }

                                if (mysql_query("UPDATE `inventory` SET  `bron1` = `bron1`-'" . (int)$bron1 . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                            } //made 100%(c)Thunder

                            else $bron1 = 0;

/////брон2//////
                            if ($row["bron2"] != 0) {
                                $bron2 = true;
                                $shans = rand(7, 9);
                                if ($shans == 7) {
                                    print"shans0";
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $bron2 = $row["bron2"] / 2;
                                    if ($ssh == 77) {
                                        $bron = $row["bron2"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `bron2` = `bron2`-'" . (int)$bron1 . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 50);
                                    $bron2 = $shans;
                                }
                                if ($shans == 9) {
                                    $bron2 = rand(1, 25);
                                    if (($row["bron2"] - $bron2) < 0) {
                                        $bron2 = $row["bron2"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `bron1` = `bron2`-'" . (int)$bron2 . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }///////бронь2 конец made (c)Thunder

                                ;
                            } else $bron2 = 0;
                            if ($row["bron3"] != 0) {
                                $bron3 = true;

                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $bron = $row["bron3"] / 2;
                                    if ($ssh == 77) {
                                        $bron = $row["bron3"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `bron3` = `bron3`-'" . (int)$bron3 . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 15);
                                    $bron3 = $shans;
                                }
                                if ($shans == 9) {
                                    $bron3 = rand(1, 15);
                                    if (($row["bron3"] - $bron3) < 0) {
                                        $bron3 = $row["bron3"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `bron1` = `bron1`-'" . (int)$bron3 . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }
////made (c)Thunder
                            } else $bron3 = 0;

                            if ($row["bron4"] != 0) {
                                $bron4 = true;

                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $bron4 = $row["bron4"] / 2;
                                    if ($ssh == 77) {
                                        $bron4 = $row["bron4"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `bron4` = `bron4`-'" . (int)$bron4 . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 15);
                                    $bron4 = $shans;
                                }
                                if ($shans == 9) {
                                    $bron4 = rand(1, 15);
                                    if (($row["bron4"] - $bron4) < 0) {
                                        $bron4 = $row["bron4"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `bron4` = `bron4`-'" . (int)$bron4 . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }

                            } else $bron4 = 0;
///made(c)Thunder
                            if ($row["mfkrit"] != 0) {
                                $mfkrit = true;

                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $mfkrit = $row["mfkrit"] / 2;
                                    if ($ssh == 77) {
                                        $mfkrit = $row["mfkrit"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `mfkrit` = `mfkrit`-'" . (int)$mfkrit . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 15);
                                    $mfkrit = $shans;
                                }
                                if ($shans == 9) {
                                    $mfkrit = rand(1, 15);
                                    if (($row["mfkrit"] - $mfkrit) < 0) {
                                        $mfkrit = $row["mfkrit"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `mfkrit` = `mfkrit`-'" . (int)$mfkrit . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }

                            } else $mfkrit = 0;
///(c) made, test (c)Thunder
                            if ($row["mfakrit"] != 0) {
                                $mfakrit = true;
                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $mfakrit = $row["mfakrit"] / 2;
                                    if ($ssh == 77) {
                                        $mfakrit = $row["mfakrit"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `mfakrit` = `mfakrit`-'" . (int)$mfakrit . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 18);
                                    $mfakrit = $shans;
                                }
                                if ($shans == 9) {
                                    $mfakrit = rand(1, 10);
                                    if (($row["mfakrit"] - $mfakrit) < 0) {
                                        $mfakrit = $row["mfakrit"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `mfakrit` = `mfakrit`-'" . (int)$mfakrit . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }

                            } else $mfakrit = 0;

                            if ($row["mfuvorot"] != 0) {
                                $mfuvorot = true;
                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $mfuvorot = $row["mfuvorot"] / 2;
                                    if ($ssh == 77) {
                                        $mfuvorot = $row["mfuvorot"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `mfuvorot` = `mfuvorot`-'" . (int)$mfuvorot . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 18);
                                    $mfuvorot = $shans;
                                }
                                if ($shans == 9) {
                                    $hp = rand(1, 5);
                                    if (($row["mfuvorot"] - $mfuvorot) < 0) {
                                        $mfuvorot = $row["mfuvorot"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `mfuvorot` = `mfuvorot`-'" . (int)$mfuvorot . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }

                            } else $mfuvorot = 0;
                            if ($row["mfauvorot"] != 0) {
                                $mfauvorot = true;
                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $mfauvorot = $row["mfauvorot"] / 2;
                                    if ($ssh == 77) {
                                        $mfauvorot = $row["mfauvorot"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `mfauvorot` = `mfauvorot`-'" . (int)$mfauvorot . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 18);
                                    $mfauvorot = $shans;
                                }
                                if ($shans == 9) {
                                    $mfauvorot = rand(1, 5);
                                    if (($row["mfauvorot"] - $mfauvorot) < 0) {
                                        $$mfauvorot = $row["mfauvorot"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `mfauvorot` = `mfauvorot`-'" . (int)$mfauvorot . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }

                            } else $mfauvorot = 0;
                            if ($row["mfantiuvorot"] != 0) {
                                $mfantiuvorot = true;
                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $mfantiuvorot = $row["mfantiuvorot"] / 2;
                                    if ($ssh == 77) {
                                        $mfantiuvorot = $row["mfantiuvorot"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `mfantiuvorot` = `mfantiuvorot`-'" . (int)$mfantiuvorot . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 18);
                                    $mfantiuvorot = $shans;
                                }
                                if ($shans == 9) {
                                    $mfantiuvorot = rand(1, 5);
                                    if (($row["mfantiuvorot"] - $mfantiuvorot) < 0) {
                                        $mfantiuvorot = $row["mfantiuvorot"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `mfantiuvorot` = `mfantiuvorot`-'" . (int)$mfantiuvorot . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }

                            } else $mfantiuvorot = 0;


                            if ($row["gsila"] != 0) {
                                $sila = true;

                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $sila = $row["gsila"] / 2;
                                    if ($ssh == 77) {
                                        $sila = $row["gsila"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `gsila` = `gsila`-'" . (int)$sila . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 8);
                                    $sila = $shans;
                                }
                                if ($shans == 9) {
                                    $sila = rand(1, 5);
                                    if (($row["gsila"] - $sila) < 0) {
                                        $sila = $row["gsilat"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `gsila` = `gsila`-'" . (int)$sila . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }

                            } else $sila = 0;
                            if ($row["glovk"] != 0) {
                                $lovk = true;
                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $lovk = $row["glovk"] / 2;
                                    if ($ssh == 77) {
                                        $lovk = $row["glovk"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `glovk` = `glovk`-'" . (int)$lovk . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 8);
                                    $lovk = $shans;
                                }
                                if ($shans == 9) {
                                    $lovk = rand(1, 5);
                                    if (($row["glovk"] - $lovk) < 0) {
                                        $lovk = $row["gslovk"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `glovk` = `glovk`-'" . (int)$lovk . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }


                            } else $lovk = 0;


                            if ($row["gunta"] != 0) {
                                $inta = true;

                                $shans = rand(7, 9);
                                if ($shans == 7) {
////ебаний фифти-фифти
                                    $ssh = rand(77, 78);
                                    $inta = $row["gunta"] / 2;
                                    if ($ssh == 77) {
                                        $inta = $row["gunta"] / 2;
                                    }
                                    if ($ssh == 78) {
                                        if (mysql_query("UPDATE `inventory` SET  `gunta` = `gunta`-'" . (int)$inta . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                    }

                                }///shans 77
                                if ($shans == 8) {
                                    $shans = rand(1, 8);
                                    $inta = $shans;
                                }
                                if ($shans == 9) {
                                    $inta = rand(1, 5);
                                    if (($row["gunta"] - $inta) < 0) {
                                        $inta = $row["gunta"];
                                    }

                                    if (mysql_query("UPDATE `inventory` SET  `gunta` = `gunta`-'" . (int)$inta . "' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) ;
                                }

                            } else $inta = 0;
                            /*if($row["nvinos"]!=0){ $nvinos=true;

                            $shans=rand(7,9);
                            if ($shans==7) {
                            ////ебаний фифти-фифти
                            $ssh=rand(77,78);
                            $nvinos=$row["nvinos"]/2;
                            if ($ssh==77) {
                            $nvinos=$row["nvinos"]/2;
                            }
                            if ($ssh==78) { if(mysql_query("UPDATE `inventory` SET  `nvinos` = `nvinos`-'".(int)$nvinos."' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;"));}

                            }///shans 77
                            if ($shans==8) {
                            $shans=rand(1,50);
                            $nvinos=$shans;
                            }
                            if ($shans==9) {
                            $nvinos=rand(1,25);
                            if (($row["nvinos"]-$nvinos)<0) {$nvinos=$row["nvinos"];}
                            ////made by Thunder(c)
                            if(mysql_query("UPDATE `inventory` SET  `nvinos` = `nvinos`-'".(int)$nvinos."' 		WHERE `id` = '{$_GET['mf']}' LIMIT 1;"));
                            }

                            }else $nvinos=0;
                            */
                            if (mysql_query("UPDATE `inventory` SET
							`ghp` = `ghp`+'" . (int)$hp . "',
							`bron1` = `bron1`+'" . (int)$bron1 . "',
							`bron2` = `bron2`+'" . (int)$bron2 . "',
							`bron3` = `bron3`+'" . (int)$bron3 . "',
							`bron4` = `bron4`+'" . (int)$bron4 . "',
							`mfkrit` = `mfkrit`+'" . (int)$mfkrit . "',
							`mfakrit` = `mfakrit`+'" . (int)$mfantikrit . "',
							`mfuvorot` = `mfuvorot`+'" . (int)$mfuvorot . "',
							`mfauvorot` = `mfauvorot`+'" . (int)$mfantiuvorot . "',
							`gsila` = `gsila`+'" . (int)$sila . "',
							`glovk` = `glovk`+'" . (int)$lovk . "',
							`ginta` = `ginta`+'" . (int)$inta . "',
							`nsila` = `nsila`+'" . (int)$nsila . "',
							`nlovk` = `nlovk`+'" . (int)$nlovk . "',
							`ninta` = `ninta`+'" . (int)$ninta . "',
							`nvinos` = `nvinos`+'" . (int)$nvinos . "',
							`cost` = `cost` + '" . round($row['cost'] / 2) . "',
							`name` = CONCAT(`name`, ' (мф)')
			WHERE `id` = '{$_GET['mf']}' LIMIT 1;")) {
                                //echo $row['cost'];
                                mysql_query("UPDATE `users` set `money` = `money`- '" . ($row['cost']) . "' WHERE id = {$_SESSION['uid']}");
                                mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','Моцифицирована вещь \"" . $row['name'] . "\" id:(cap" . $row['id'] . ") [" . $newduration . "/" . $row['maxdur'] . "] у \"" . $user['login'] . "\" за " . round($onecost, 2) . " кр. ',1,'" . time() . "');");
                                $err = "<font color=red><b>Вещь модифицирована.</b></font>";
                            }

                        }
                    }

                    ?>

                    <TABLE BORDER=0 WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">
                        <?


                        $data = mysql_query("SELECT * FROM `inventory` WHERE `type` < 12 AND `type` != 3 AND `owner` = '{$_SESSION['uid']}' AND `dressed` = 0 AND `name` NOT LIKE '% (мф)%' AND `name` NOT LIKE '%Букет%' AND `setsale`=0 ORDER by `update` DESC; ");
                        while ($row = mysql_fetch_array($data)) {
                            $row['count'] = 1;
                            if ($i == 0) {
                                $i = 1;
                                $color = '#C7C7C7';
                            } else {
                                $i = 0;
                                $color = '#D5D5D5';
                            }
                            echo "<TR bgcolor={$color}><TD align=center ><IMG SRC=\"i/sh/{$row['img']}\" BORDER=0>";
                            ?>
                            <BR>
                            <small>
                                <A HREF="?mf=<?= $row['id'] ?>"
                                   onclick="if(!confirm('Вы действительно хотите модифицировать эту вещь?')){ return false;}">Модифицировать
                                    за <?= $row['cost'] ?> кр.</A><BR>
                            </small>
                            </TD>
                            <?php
                            echo "<TD valign=top>";
                            showitem($row);
                            echo "</TD></TR>";
                        }

                        //////////end of REPAIR

                        ?>
                    </table>
                </FIELDSET>
            </div>

            <div class=dtz ID=dTZ15>
                <FIELDSET>
                    <LEGEND><H4>О клане</H4></LEGEND>
                    О клане в процессе разработки...
                </FIELDSET>

            </div>
            <div class=dtz ID=dTZ16>
                <FIELDSET>
                    <LEGEND><H4>Управление</H4></LEGEND>
                    Управление в процессе разработки...
                </FIELDSET>
            </div>
        </td>
    </tr>
</table>
</BODY>
</HTML>