<?php
if (!defined('UC_SYSOP'))
	die('Direct access denied.');
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ru">
<head>
<title><?= $title ?></title>
<link rel="stylesheet" href="./themes/<?=$ss_uri."/".$ss_uri?>.css" type="text/css">
<link rel="icon" href="/favicon (2).ico" type="image/x-icon">
<script language="javascript" type="text/javascript" src="js/spoiler.js"></script>
<script language="javascript" type="text/javascript" src="js/resizer.js"></script>
<!--<script language="javascript" type="text/javascript" src="js/tooltips.js"></script>-->
<script language="javascript" type="text/javascript" src="js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="js/blocks.js"></script>
<script language="javascript" type="text/javascript" src="js/lightbox.js"></script>
<script type="text/javascript">

<!--

var ExternalLinks_InNewWindow = '1';

function initSpoilers(context) {
	var context = context || 'body';
	$('div.spoiler-head', $(context))
		.click(function(){
		    var ctx = $(this).next('div.spoiler-body');
			var code = ctx.children('textarea').text();
			if (code) {
			    ctx.children('textarea').replaceWith(code);
			    initSpoilers(ctx);
			}
			$(this).toggleClass('unfolded');
            $(this).next('div.spoiler-body').slideToggle('fast');
            $(this).next('div.spoiler-body').next().slideToggle('fast');
		});
}

$(document).ready(function(){
	initSpoilers('body');
	$(function() {$('a[@rel*=lightbox]').lightBox();});
});

//-->
</script>
<link rel="alternate" type="application/rss+xml" title="Последние торренты" href="<?=$DEFAULTBASEURL?>/rss.php">
<link rel="shortcut icon" href="<?=$DEFAULTBASEURL;?>/favicon.ico" type="image/x-icon" />
</head>
<body>

<!-- /////// some vars for the statusbar;o) //////// -->

<? if ($CURUSER) { ?>

<?

$uped = mksize($CURUSER['uploaded']);
$downed = mksize($CURUSER['downloaded']);

if ($CURUSER["downloaded"] > 0) {
	$ratio = $CURUSER['uploaded'] / $CURUSER['downloaded'];
	$ratio = number_format($ratio, 3);
	$color = get_ratio_color($ratio);
	if ($color)
		$ratio = "<font color=$color>$ratio</font>";
} elseif ($CURUSER["uploaded"] > 0)
	$ratio = "Inf.";
else
	$ratio = "---";

$medaldon = $warn = '';

if ($CURUSER['donor'] == "yes")
	$medaldon = "<img src=\"pic/star.gif\" alt=\"Донор\" title=\"Донор\">";
if ($CURUSER['warned'] == "yes")
	$warn = "<img src=\"pic/warned.gif\" alt=\"Предупрежден\" title=\"Предупрежден\">";

//// check for messages ////////////////// 
        $res1 = sql_query("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " AND location=1") or print(mysql_error()); 
        $arr1 = mysql_fetch_row($res1);
        $messages = $arr1[0];
        /*$res1 = sql_query("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " AND location=1 AND unread='yes'") or print(mysql_error()); 
        $arr1 = mysql_fetch_row($res1);
        $unread = $arr1[0];*/
        $res1 = sql_query("SELECT COUNT(*) FROM messages WHERE sender=" . $CURUSER["id"] . " AND saved='yes'") or print(mysql_error()); 
        $arr1 = mysql_fetch_row($res1);
        $outmessages = $arr1[0];
        if ($unread)
                $inboxpic = "<img height=\"16px\" style=\"border:none\" alt=\"inbox\" title=\"Есть новые сообщения\" src=\"pic/pn_inboxnew.gif\">"; 
        else
                $inboxpic = "<img height=\"16px\" style=\"border:none\" alt=\"inbox\" title=\"Нет новых сообщений\" src=\"pic/pn_inbox.gif\">";

$res2 = sql_query("SELECT COUNT(*) FROM peers WHERE userid=" . $CURUSER["id"] . " AND seeder='yes'") or print(mysql_error());
$row = mysql_fetch_row($res2);
$activeseed = $row[0];

$res2 = sql_query("SELECT COUNT(*) FROM peers WHERE userid=" . $CURUSER["id"] . " AND seeder='no'") or print(mysql_error());
$row = mysql_fetch_row($res2);
$activeleech = $row[0];

//// end

?>

<!-- //////// start the statusbar ///////////// -->

</table>

<? } else {?>

<br />

<? } ?>

<div id="plashka">
<div class="plashka-logo">

<div id="logoTracker"><a href="/"><img alt="" src="/themes/TBDev/images/logo.png"></a></div>
<div id="fineInput"><form action="browse.php" method="get"><input type="text" name="search" placeholder="Поиск..." id="inSearch" maxlength="100" value=""><input type="submit" id="goSearch" value=""></form></div>
<div class="clear"></div>

</div>
</div>

<p>
<center><img alt="" src="/themes/TBDev/images/top-plashka-united.png"></center>
<?php

$w = "width=\"980px\"";
//if ($_SERVER["REMOTE_ADDR"] == $_SERVER["SERVER_ADDR"]) $w = "width=984";

?>
<div id="container">
<div id="bodyContainer">

<table class="mainouter" align="left" <?=$w; ?> cellspacing="0" cellpadding="8">

<!------------- MENU ------------------------------------------------------------------------>

<? $fn = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], "/") + 1); ?>

<td class="lc" valign="top" width="155">
<?

show_blocks("l");

if ($messages) {
                $message_in = "<span class=\"smallfont\">&nbsp;<a href=\"message.php\">$inboxpic</a> $messages " . sprintf($tracker_lang["new_pm"], $unread) . "</span>";
                if ($outmessages)
                        $message_out = "<span class=\"smallfont\">&nbsp;<a href=\"message.php?action=viewmailbox&box=-1\"><img height=\"16px\" style=\"border:none\" alt=\"" . $tracker_lang['outbox'] . "\" title=\"" . $tracker_lang['outbox'] . "\" src=\"pic/pn_sentbox.gif\"></a> $outmessages</span>";
                else
                        $message_out = "<span class=\"smallfont\">&nbsp;<a href=\"message.php?action=viewmailbox&box=-1\"><img height=\"16px\" style=\"border:none\" alt=\"" . $tracker_lang['outbox'] . "\" title=\"" . $tracker_lang['outbox'] . "\" src=\"pic/pn_sentbox.gif\"></a> 0</span>";
        }
        else {
                $message_in = "<span class=\"smallfont\">&nbsp;<a href=\"message.php\"><img height=\"16px\" style=\"border:none\" alt=\"".$tracker_lang['inbox']."\" title=\"".$tracker_lang['inbox']."\" src=\"pic/pn_inbox.gif\"></a> 0</span>";
                if ($outmessages)
                        $message_out = "<span class=\"smallfont\">&nbsp;<a href=\"message.php?action=viewmailbox&box=-1\"><img height=\"16px\" style=\"border:none\" alt=\"" . $tracker_lang['outbox'] . "\" title=\"" . $tracker_lang['outbox'] . "\" src=\"pic/pn_sentbox.gif\"></a> $outmessages</span>";
                else
                        $message_out = "<span class=\"smallfont\">&nbsp;<a href=\"message.php?action=viewmailbox&box=-1\"><img height=\"16px\" style=\"border:none\" alt=\"" . $tracker_lang['outbox'] . "\" title=\"" . $tracker_lang['outbox'] . "\" src=\"pic/pn_sentbox.gif\"></a> 0</span>";
        }

if ($CURUSER) {

	$userbar = "<table width=\"100%\"><tr><td><center><img src=\"" . ( $CURUSER["avatar"] ? $CURUSER["avatar"] : "./themes/$ss_uri/images/default_avatar.png" ) . "\" width=\"130\" alt=\"".$tracker_lang['avatar']."\" title=\"".$tracker_lang['avatar']."\" border=\"0\" /></td></tr></center>

	<tr><td><font color=\"black\"><b>".$tracker_lang['downloaded'].":</b>&nbsp;$downed</font></td></tr>
	<tr><td><font color=\"black\"><b>".$tracker_lang['uploaded'].":</b>&nbsp;$uped</font></td></tr>
	<tr><td><font color=\"black\"><b>Бонус 3Mb/час:</b></font>&nbsp;<a href=\"mybonus.php\" class=\"online\">$CURUSER[bonus]</a></td></tr>
	<tr><td><font color=\"black\"><b>".$tracker_lang['ratio'].":</b>&nbsp;$ratio</font></td></tr>
	<tr><td><font color=\"black\"><b>Ваш класс:</b></font>&nbsp;Думаем над этим :)</td></tr>
	<tr><td><center> <a href=\"userdetails.php?id=".$CURUSER["id"]."\" title=\"Профиль\" class=\"margin-r-5px\"><img width=\"32px\" height=\"32px\" src=\"/themes/TBDev/images/profile.png\"/></a>  <a href=\"my.php\" title=\"Мои настройки\" class=\"margin-r-5px\"><img width=\"32px\" height=\"32px\" src=\"/themes/TBDev/images/setting.png\"/></a>  <a href=\"message.php\" title=\"Почтовый ящик\" class=\"margin-r-5px\"><img width=\"32px\" height=\"32px\" src=\"/themes/TBDev/images/message.png\"/></a>  <a href=\"mytorrents.php\" title=\"Мои торренты\" class=\"margin-r-5px\"><img width=\"32px\" height=\"32px\" src=\"/themes/TBDev/images/torrent.png\"/></a>  <a href=\"friends.php\" title=\"Друзья\" class=\"margin-r-5px\"><img width=\"32px\" height=\"32px\" src=\"/themes/TBDev/images/friends.png\"/></a> </center></td></tr>
	
	<tr><td><div align=\"right\"><a href=\"logout.php\">Выход</a></div></td></tr></table>
	";
} else {
	$userbar = '<center><form method="post" action="takelogin.php">
<br />
'.$tracker_lang['username'].': <br />
<input type="text" size=20 name="username" /><br />
'.$tracker_lang['password'].': <br />

<input type="password" size=20 name="password" /><br />
<input type="submit" value="'.$tracker_lang['login'].'!" class=\"btn\"><br /><br />
</form></center>
<a class="menu" href="signup.php"><center>'.$tracker_lang['signup'].'</center></a>';
}

if ($CURUSER['override_class'] != 255) $usrclass = "&nbsp;<img width=\"15px\" height=\"15px\" src=\"/themes/TBDev/images/warning.png\" title=".get_user_class_name($CURUSER['class'])." alt=".get_user_class_name($CURUSER['class']).">&nbsp;";

elseif(get_user_class() >= UC_MODERATOR) $usrclass = "&nbsp;<a href=\"setclass.php\"><img width=\"15px\" height=\"15px\" src=\"/themes/TBDev/images/warning.png\" title=\"".get_user_class_name($CURUSER['class'])."\" alt=\"".get_user_class_name($CURUSER['class'])."\" border=\"0\"></a>&nbsp;";

	blok_menu(( $CURUSER ? "<a href=\"$DEFAULTBASEURL/userdetails.php?id=" . $CURUSER["id"] . "\">" . $CURUSER["username"] . "</a>&nbsp;".$usrclass."&nbsp;" : "гость" ) . $medaldon . $warn , $userbar , "155");

	
if ($CURUSER) {	
	
	$kategory = "
	<ul id=\"menuCategor\" class=\"ulBlockMenu\">
	<li><span><b><font color=\"#9E1E48\">Xbox 360</font></b></span></li>
	<ul></ul>
	<li><span><span class=\"red-1 margin-r-5px\">-</span><a class=\"font-10-px font-bold-no\" title=\"Перейти в раздел &laquo;Xbox 360 Игры&raquo;\" href=\"/browse.php?search=&incldead=0&cat=19\">Xbox 360 Игры</a></span></li>
	<li><span><span class=\"red-1 margin-r-5px\">-</span><a class=\"font-10-px font-bold-no\" title=\"Перейти в раздел &laquo;Xbox 360 GOD&raquo;\" href=\"/browse.php?search=&incldead=0&cat=20\">Xbox 360 GOD</a></span></li>
	<li><span><span class=\"red-1 margin-r-5px\">-</span><a class=\"font-10-px font-bold-no\" title=\"Перейти в раздел &laquo;Xbox 360 Arcade&raquo;\" href=\"/browse.php?search=&incldead=0&cat=21\">Xbox 360 Arcade</a></span></li>
	<li><span><span class=\"red-1 margin-r-5px\">-</span><a class=\"font-10-px font-bold-no\" title=\"Перейти в раздел &laquo;Xbox 360 DLC&raquo;\" href=\"/browse.php?search=&incldead=0&cat=22\">Xbox 360 DLC</a></span></li>
	<li><span><span class=\"red-1 margin-r-5px\">-</span><a class=\"font-10-px font-bold-no\" title=\"Перейти в раздел &laquo;Прочее&raquo;\" href=\"/browse.php?search=&incldead=0&cat=18\"><font color=\"#878787\">много всякой всячины</font></a></span></li>
	</ul>
	";

	blok_menu("Категории", $kategory , "155");
	
	$mainmenu = "
	<table width=\"100%\">
	<tr><td><a href=\"mybonus.php\"><center>".$tracker_lang['my_bonus']."</center></a></td></tr>
	<tr><td><a href=\"invite.php\"><center>".$tracker_lang['invite']."</center></a></td></tr>
	<tr><td><a href=\"topten.php\"><center>".$tracker_lang['topten']."</center></a></td></tr>
	<tr><td><a href=\"users.php\"><center>".$tracker_lang['users']."</center></a></td></tr>
	<tr><td><a href=\"subnet.php\"><center>".$tracker_lang['neighbours']."</center></a></td></tr>
	</table>
	";

	blok_menu($tracker_lang['main_menu'], $mainmenu , "155");



	$usermenu = "
	<table width=\"100%\">
	<tr><td><a href=\"formats.php\"><center>".$tracker_lang['formats']."</center></a></td></tr>
	</table>
	";

	blok_menu("Инструкции", $usermenu , "155");



	$bt_clients = "
	<table width=\"100%\">
	<tr><td><a href=\"admincp.php\"><center>Админка</center></a></td></tr>
	<tr><td><a href=\"users.php\"><center>Список пользователей</center></a></td></tr>
	<tr><td><a href=\"staffmess.php\"><center>Массовое ЛС</center></a></td></tr>
	<tr><td><a href=\"ipcheck.php\"><center>Двойники по IP</center></a></td></tr>
	<tr><td><a href=\"staff.php\"><center>Дополнительные функции</center></a></td></tr>
	</table>
	";
	
	if (get_user_class() >= UC_MODERATOR)
	blok_menu("Админ. панель", $bt_clients , "155");
}
?>
</td>
<td class="lc" align="center" valign="top" class="outer" style="padding-top: 5px; padding-bottom: 5px">

<div id="contentBlock" class="float-right"><ul align="center" id="ulNav">
<li><a class="nav1" href="/"></a></li>
<li><a class="nav2" href="/browse.php"></a></li>
<li><a class="nav3" href="/upload.php"></a></li>
<li><a class="nav4" href="/bookmarks.php"></a></li>
<li><a class="nav5" href="/topten.php"></a></li>
<li><a class="nav6" href="/forum.php"></a></li>
<li><a class="nav7" href="/"></a></li>
<li><a class="nav8" href="/"></a></li></ul>
<div class="clear"></div><br>

<?

if ($CURUSER) {
	if ($unread) {
		print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red'>\n");
		print("<b><a href=\"message.php\"><font color=white>".sprintf($tracker_lang['new_pms'],$unread)."</font></a></b>");
		print("</td></tr></table></p>\n");
	}
}

if (COOKIE_SALT == 'default') {
    print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=orange><tr><td style='padding: 10px; background: orange'>\n");
    print("<b><font color=white>Администратор, измени COOKIE_SALT в include/init.php прежде, чем выпустить трекер в сеть!</font></b>");
    print("</td></tr></table></p>\n");
}

if ($CURUSER['override_class'] != 255 && $CURUSER) { // Second condition needed so that this box isn't displayed for non members/logged out members.
	print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=green><tr><td style='padding: 10px; background: green'>\n");
	print("<b><a href=\"$DEFAULTBASEURL/restoreclass.php\"><font color=white>".$tracker_lang['lower_class']."</font></a></b>");
	print("</td></tr></table></p>\n");
}

show_blocks('c');