<?php
echo '<div class="nav2">';

// Гарем юзера
$count['garem'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `garem` WHERE `thief_id` = '" . $ank['id'] . "'"),0);
echo '<img src="/plugins/garem/style/img/garem.png" /> <a href="/plugins/garem/garem.php?id=' . $ank['id'] . '">Гарем</a> (' . $count['garem'] . ')<br />';

// Хозяин юзера
$you = mysql_fetch_assoc(mysql_query("SELECT * FROM `garem` WHERE `user_id` = '" . $ank['id'] . "'"));

if (isset($you['id']))
{
	// У кого в гареме
	$garem_us = get_user($you['thief_id']);
	echo '<img src="/plugins/garem/style/img/us_garem.png" /> <a href="/plugins/garem/garem.php?id=' . $you['thief_id'] . '">' . (isset($user) && $you['thief_id'] == $user['id'] ? 'У вас в гареме' : 'В гареме ' . $garem_us['nick']) . '</a><br />';
}

// Инфо о гареме и стоимости
$garem = mysql_fetch_array(mysql_query("select `cost` from `garem_stat` where `user_id` = '".$ank['id']."'"));

// Cтоимость кражи
if (!$garem['cost']) $cost = 150;
else $cost = $garem['cost'];

// Украсть в гарем
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `garem` WHERE `user_id` = '" . $ank['id'] . "'"),0) == 0 && isset($user) && $user['id'] != $ank['id'] && $user['pol'] != $ank['pol'])
echo '<a href="/plugins/garem/act.php?id=' . $ank['id'] . '&amp;act=theft">Украсть в гарем</a> - ' . $cost . ' балл.';

echo '</div>';
?>