<?
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';


if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);


if ($ank['id']==0)
{
$ank=get_user($ank['id']);
$set['title']=$ank['nick'].' - анкета '; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut();
echo "<span class=\"status\">$ank[group_name]</span><br />\n";

if ($ank['ank_o_sebe']!=NULL)echo "<span class=\"ank_n\">О себе:</span> <span class=\"ank_d\">$ank[ank_o_sebe]</span><br />\n";




if(isset($_SESSION['refer']) && $_SESSION['refer']!=NULL && otkuda($_SESSION['refer']))
echo "<div class='foot'>&laquo;<a href='$_SESSION[refer]'>".otkuda($_SESSION['refer'])."</a><br />\n</div>\n";

include_once 'sys/inc/tfoot.php';
exit;
}

$ank=get_user($ank['id']);
if(!$ank){header("Location: /index.php?".SID);exit;}








$ank['rating']=intval(@mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$ank[id]'"),0));
$set['title']=$ank['nick'].' - Активность'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();


if ((!isset($_SESSION['refer']) || $_SESSION['refer']==NULL)
&& isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL &&
!ereg('info\.php',$_SERVER['HTTP_REFERER']))
$_SESSION['refer']=str_replace('&','&amp;',ereg_replace('^http://[^/]*/','/', $_SERVER['HTTP_REFERER']));


if (isset($_POST['rating']) && isset($user)  && $user['id']!=$ank['id'] && $user['balls']>=50 && mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$user[id]'"),0)>=0)
{
$new_r=min(max(@intval($_POST['rating']),-2),2);
mysql_query("DELETE FROM `user_voice2` WHERE `id_user` = '$user[id]' AND `id_kont` = '$ank[id]' LIMIT 1");

if ($new_r)
mysql_query("INSERT INTO `user_voice2` (`rating`, `id_user`, `id_kont`) VALUES ('$new_r','$user[id]','$ank[id]')");
$ank['rating']=intval(mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$ank[id]'"),0));
mysql_query("UPDATE `user` SET `rating` = '$ank[rating]' WHERE `id` = '$ank[id]' LIMIT 1");

if ($new_r>0)
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$user[nick] оставил положительный отзыв в [url=/who_rating.php]Вашей анкете[/url]', '$time')");
if ($new_r<0)
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$user[nick] оставил негативный отзыв в [url=/who_rating.php]Вашей анкете[/url]', '$time')");
if ($new_r==0)
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$user[nick] оставил нейтральный отзыв в [url=/who_rating.php]Вашей анкете[/url]', '$time')");



msg('Вы успешно проголосовали за анкету');
}
echo "<div class='rekl'>\n";
echo "<img src='/style/back.gif' alt='' class='icon'/>\n";
echo "<a href='/info.php?id=$ank[id]'>$ank[nick]</a><br />\n";
echo "</div>\n";
if (isset($user) && $user['id']==$ank['id'])
{
echo "<div class='tmn'>\n";

echo' <img src="/style/gorod/life.gif" alt="" class="icon"/> <a href="/gorod/life.php">Здоровье: <b>'.$ank['gorod_life'].'</b> %</a><br/>';

echo'<img src="/style/gorod/opyt.png" alt="" class="icon"/> <a href="/gorod/zadanie.php">Опыт в городе: <b>'.$user['gorod_opit'].'</b></a><br />';

echo'<img src="/style/gorod/many.gif" alt="" class="icon"/> <a href="/gorod/zadanie.php">Деньги города: <b>'.$user['gorod_money'].' $</b></a><br />';


echo'</div>';
}

if (isset($user) && $user['id']!=$ank['id'])

{

echo "<div class='tmn'>\n";
echo "<img src='/style/icons/many.gif' alt='' class='icon'/>\n";
echo "<b>LM:</b> <font color='red'>$ank[balls]</font><br />\n";

echo' <img src="/style/gorod/life.gif" alt="" class="icon"/> Здоровье: <b>'.$ank['gorod_life'].'</b> %<br/>';

echo'<img src="/style/gorod/opyt.png" alt="" class="icon"/> Опыт в городе: <b>'.$ank['gorod_opit'].'</b><br />';

echo'<img src="/style/gorod/many.gif" alt="" class="icon"/> Деньги города: <b>'.$ank['gorod_money'].' $</b><br />';

}
echo "</div>\n";

$isdom=mysql_query("SELECT * FROM `gorod_invent` WHERE `uid`='".$ank['id']."' AND `type`='dom'");
if(mysql_num_rows($isdom)>0){
$isdom=mysql_fetch_assoc($isdom);
echo "<div class='info_razd'>\n";
echo "<img src='/style/gorod/home.png' alt='' class='icon'/> \n";
echo 'Дом в городе: <font color="red">'.$isdom['name'].'</font><br/>';
echo "</div>\n";
};

$isavto=mysql_query("SELECT * FROM `gorod_invent` WHERE `uid`='".$ank['id']."' AND `type`='avto'");
if(mysql_num_rows($isavto)>0){
$isavto=mysql_fetch_assoc($isavto);
echo "<div class='info_razd'>\n";
echo "<img src='/style/gorod/cars.png' alt='' class='icon'/> \n";
echo 'Автомобиль города: <font color="red">'.$isavto['name'].'</font><br/>';
echo "</div>\n";
};

$ispu=mysql_query("SELECT * FROM `gorod_invent` WHERE `uid`='".$ank['id']."' AND `type`='pushka'");
if(mysql_num_rows($ispu)>0){
$ispu=mysql_fetch_assoc($ispu);
echo "<div class='info_razd'>\n";
echo "<img src='/style/gorod/12.png' alt='' class='icon'/> \n";
echo 'Оружие города: <font color="red">'.$ispu['name'].'</font> ['.$ispu['uron'].'%]<br/>';
echo "</div>\n";
};
//алгоритм
$act1 = $ank[lafes];
$act2 = $ank[lafes_g];
$act3 = $ank[lafes_f];
$act4 = $ank[komm_blog];
$act5 = $act1 + $act2 + $act3 + $act4;
echo "<div class='info_razd'>\n";
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Общая активность: <font color='red'><b>$act5</b></font><br /></a>\n";//вывожу обшее количество активности +++
echo "</div>\n";
echo "<div class='info_razd'>\n";
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Фраз в чате: <font color='red'>$ank[lafes]</font><br />\n";
echo "</div>\n";
echo "<div class='info_razd'>\n";
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Фраз в форуме: <font color='red'>$ank[lafes_f]</font><br />\n";
echo "</div>\n";
echo "<div class='info_razd'>\n";
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Фраз в беседке: <font color='red'>$ank[lafes_g]</font><br />\n";
echo "</div>\n";
echo "<div class='info_razd'>\n";
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Комм. в дневниках: <font color='red'>$ank[komm_blog]</font><br />\n";
echo "</div>\n";
echo "<div class='info_razd'>\n";
$k_them=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `id_user` = '$ank[id]'"),0);
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Тем в форуме: <font color='red'>$k_them</font><br />\n";
echo "</div>\n";
echo "<div class='info_razd'>\n";
$zakl3=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_zakl` WHERE `id_user` = '$ank[id]'"),0);
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Закладки: <font color='red'>$zakl3</font><br />\n";
echo "</div>\n";
echo "<div class='info_razd'>\n";
$mail3=mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `id_user` = '$ank[id]' OR `id_kont` = '$ank[id]'"),0);
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Письма: <font color='red'>$mail3</font><br />\n";
echo "</div>\n";
echo "<div class='info_razd'>\n";
$news_komm=mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_user` = '$ank[id]'"),0);
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Комментарии новостей: <font color='red'>$news_komm</font><br />\n";

echo "</div>\n";
echo "<div class='info_razd'>\n";
$obmennik3=mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_user` = '$ank[id]'"),0);
echo "<img src='/style/icons/2.png' alt='' class='icon'/> Файлы в обменнике: <font color='red'>$obmennik3</font><br />\n";
echo "</div>\n";
echo "<div class='rekl'>\n";
echo "<img src='/style/back.gif' alt='' class='icon'/>\n";
echo "<a href='/prof.php?id=$ank[id]'>Назад ($ank[nick])</a><br />\n";
echo "</div>\n";
include_once '../sys/inc/tfoot.php';
?>