<?

//////////////Скрипт не продавать
//////////////установка, выполнить запрос
 ///////// `aa1` int(11) DEFAULT NULL,
////////  `aa2` int(11) NOT NULL DEFAULT '0',
 ///////////// `aa3` int(11) NOT NULL DEFAULT '0',




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';
only_reg();$set['title']='Гаремы'; // заголовок страницы
include_once 'sys/inc/thead.php';
title();
aut();
$act=htmlspecialchars(trim($_GET['act']));
$oke = htmlspecialchars(trim($_GET['oke']));
$ids = intval($_GET['id']);
if($act == "reyt")
{


$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `aa2` > '0'"), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `user` WHERE `aa2` > '0' ORDER BY `aa2` DESC LIMIT $start, $set[p_str]");

if ($k_post==0)
{

echo "Нет гаремов((\n";

}
while ($ank = mysql_fetch_array($q))
{
if($num==1){ echo "<div class='rowup'>";
$num=0;}
else
{echo "<div class='rowdown'>";
$num=1;}


avatar2($ank['id']);

echo "".online($ank['id'])." ";

echo " <a href='/info.php?id=$ank[id]'><span style=\"color:$ank[ncolor]\">$ank[nick]</span></a> ";

if ($ank['rating']>=551 && $ank['rating']<=1080){echo "<img src='/img/medal_bronze.gif' alt=''/>";
}else
if ($ank['rating']>=1081 && $ank['rating']<=2050){echo "<img src='/img/medal_bronze.gif' alt=''/> <img src='/img/medal_silver.gif' alt=''/>";
}else{
if ($ank['rating']>=5000)echo "<img src='/img/medal_bronze.gif' alt=''/> <img src='/img/medal_silver.gif' alt=''/> <img src='/img/medal_gold.gif' alt=''/>";}
echo "<br/>";

if ($ank['pol']==1)
echo "(Муж)";
else
echo "(Жен)";

if ($ank['ank_d_r']!=NULL && $ank['ank_m_r']!=NULL && $ank['ank_g_r']!=NULL){
$ank['ank_age']=date("Y")-$ank['ank_g_r'];
if (date("n")<$ank['ank_m_r'])$ank['ank_age']=$ank['ank_age']-1;
elseif (date("n")==$ank['ank_m_r']&& date("j")<$ank['ank_d_r'])$ank['ank_age']=$ank['ank_age']-1;
echo ",$ank[ank_age] лет";
}
if ($ank['ank_city']!=NULL)echo ",$ank[ank_city]";
echo "<br/>";
echo "<a href='garem.php?act=garem&id=".$ank['id']."'>В гареме</a> <strong>".$ank['aa2']."</strong> чел.<br />\n";
echo'</div>';
}
if ($k_page>1)str("?act=reyt&",$k_page,$page);
} else if($act == "reytg") {
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `aa3` > '0'"), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `user` WHERE `aa3` > '0' ORDER BY `aa3` DESC LIMIT $start, $set[p_str]");

if ($k_post==0)
{

echo "Нет украденных((\n";

}
while ($ank = mysql_fetch_array($q))
{
if($num==1){ echo "<div class='rowup'>";
$num=0;}
else
{echo "<div class='rowdown'>";
$num=1;}


avatar2($ank['id']);

echo "".online($ank['id'])." ";

echo " <a href='/info.php?id=$ank[id]'><span style=\"color:$ank[ncolor]\">$ank[nick]</span></a> ";

if ($ank['rating']>=551 && $ank['rating']<=1080){echo "<img src='/img/medal_bronze.gif' alt=''/>";
}else
if ($ank['rating']>=1081 && $ank['rating']<=2050){echo "<img src='/img/medal_bronze.gif' alt=''/> <img src='/img/medal_silver.gif' alt=''/>";
}else{
if ($ank['rating']>=5000)echo "<img src='/img/medal_bronze.gif' alt=''/> <img src='/img/medal_silver.gif' alt=''/> <img src='/img/medal_gold.gif' alt=''/>";}
echo "<br/>";

if ($ank['pol']==1)
{
echo "(Муж)";
$a = '';
} else {
echo "(Жен)";
$a = 'a';
}
if ($ank['ank_d_r']!=NULL && $ank['ank_m_r']!=NULL && $ank['ank_g_r']!=NULL){
$ank['ank_age']=date("Y")-$ank['ank_g_r'];
if (date("n")<$ank['ank_m_r'])$ank['ank_age']=$ank['ank_age']-1;
elseif (date("n")==$ank['ank_m_r']&& date("j")<$ank['ank_d_r'])$ank['ank_age']=$ank['ank_age']-1;
echo ",$ank[ank_age] лет";
}
if ($ank['ank_city']!=NULL)echo ",$ank[ank_city]";
echo "<br/>";
echo "Украден".$a.": <strong>".$ank['aa3']."</strong> раз.<br />\n";
echo'</div>';
}
if ($k_page>1)str("?act=reytg&",$k_page,$page);
} else if($act == "garem") {
$kl=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = $ids"),0);
if ($kl==0)
{
echo "Нет таково пользователя<br/>";
include_once 'sys/inc/tfoot.php'; exit;
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `aa1` = '$ids'"), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `user` WHERE `aa1` = '$ids' ORDER BY `aa3` DESC LIMIT $start, $set[p_str]");
$ankers = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ids LIMIT 1"));
echo "<div class='str'>- За 30 украденных человек Вы получаете статус <strong>Король и Королева</strong> гаремов, и коронку возле ника.<br/>- Если Вас украли более 30-ти раз, то Вы получаете статус <strong>Суперский парень</strong> и <strong>Суперская девушка</strong>.</div>\n";
echo "<div class='str'>Гарем <strong>".$ankers['nick']."</strong></div>\n";
if ($k_post==0)
{

echo "Нет украденных((\n";

}
while ($ank = mysql_fetch_array($q))
{
if($num==1){ echo "<div class='rowup'>";
$num=0;}
else
{echo "<div class='rowdown'>";
$num=1;}


avatar2($ank['id']);

echo "".online($ank['id'])." ";

echo " <a href='/info.php?id=$ank[id]'><span style=\"color:$ank[ncolor]\">$ank[nick]</span></a> ";

if ($ank['rating']>=551 && $ank['rating']<=1080){echo "<img src='/img/medal_bronze.gif' alt=''/>";
}else
if ($ank['rating']>=1081 && $ank['rating']<=2050){echo "<img src='/img/medal_bronze.gif' alt=''/> <img src='/img/medal_silver.gif' alt=''/>";
}else{
if ($ank['rating']>=5000)echo "<img src='/img/medal_bronze.gif' alt=''/> <img src='/img/medal_silver.gif' alt=''/> <img src='/img/medal_gold.gif' alt=''/>";}
echo "<br/>";

if ($ank['pol']==1)
{
echo "(Муж)";
$a = '';
} else {
echo "(Жен)";
$a = 'a';
}
if ($ank['ank_d_r']!=NULL && $ank['ank_m_r']!=NULL && $ank['ank_g_r']!=NULL){
$ank['ank_age']=date("Y")-$ank['ank_g_r'];
if (date("n")<$ank['ank_m_r'])$ank['ank_age']=$ank['ank_age']-1;
elseif (date("n")==$ank['ank_m_r']&& date("j")<$ank['ank_d_r'])$ank['ank_age']=$ank['ank_age']-1;
echo ",$ank[ank_age] лет";
}
if ($ank['ank_city']!=NULL)echo ",$ank[ank_city]";
echo "<br/>";
echo "Украден".$a.": <strong>".$ank['aa3']."</strong> раз.<br />\n";
echo'</div>';
}
if ($k_page>1)str("?act=garem&id=".$ids."&",$k_page,$page);
} else if($act == "kraz") {
if($ank['pol'] == $user['pol'])
{
echo 'Разрешено красть только людей противоположного пола!';
include_once 'sys/inc/tfoot.php';
exit;
}
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ids LIMIT 1"));
if($ank['aa3'] == 0)
{
$cena = 250;
} else if($ank['aa3'] == 1) {
$cena = 350;
} else {
$cena = (($ank['aa3']*100)+250);
}
if($oke == 'ok')
{
if($user['balls'] < $cena)
{
echo 'У вас недостаточно баллов!';
include_once 'sys/inc/tfoot.php';
exit;
}
if ($user['pol']==1)
{
$a = '';
} else {
$a = 'a';
}
if ($ank['pol']==1)
{
$apt = 'его';
} else {
$apt = 'её';
}
$msgno = 'Вас украли в гарем к '.$user['nick'].' весёлого новоселья ;)';
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$ank['id']."', '".$msgno."', '".$time."')");
mysql_query("UPDATE `user` SET `balls` = `balls`-$cena, `aa2` = `aa2`+1 WHERE `id` = '".$user['id']."';");
mysql_query("UPDATE `user` SET `aa3` = `aa3`+1, `aa1` = '".$user['id']."' WHERE `id` = '".$ank['id']."';");
if(intval($ank['aa1']) != 0)
{
mysql_query("UPDATE user SET aa2=aa2-1 WHERE id='".$ank['aa1']."';");
$msgn = 'Пользователь '.$user['nick'].' украл'.$a.' у вас из гарема жителя: '.$ank['nick'].', удачи отвоевать '.$apt.' обратно ;)';
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$ank['aa1']."', '".$msgn."', '".$time."')");
}
echo 'Удачно!) Желаем вам большой гарем)))';
} else {
echo '<div class="str">Вы хотите украсть <a href="info.php?id='.$ids.'"><strong>'.$ank['nick'].'</strong></a><br />
Стоимость: <strong>'.$cena.'</strong> баллов.<br />
<a href="garem.php?act=kraz&oke=ok&id='.$ids.'"><strong>Украсть</strong></a></div>';
}
} else {
echo '<div class="str"><img src="/style/themes/green/graph/garem.gif" alt="i"/> <a href="garem.php?act=reyt">Рейтинг гаремов</a><br/>';
echo '<img src="/style/themes/green/graph/garem.gif" alt="i"/> <a href="garem.php?act=reytg">Рейтинг украденных</a></div>';
}
include_once 'sys/inc/tfoot.php';
?>
