<?
if(isset($_GET['friend']))
{
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)==0)
{
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)!=0)mysql_querll("DELETE FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
mysql_querll("INSERT INTO `kolhoz_friends` SET `id_user` = '$ku[id]', `id_ank` = '$ank[id]'");
//echo "INSERT INTO `kolhoz_friends` SET `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'";
}
else mysql_querll("DELETE FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
echo mysql_error();
}
elseif(isset($_GET['blacklist']))
{
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)==0)
{
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)!=0)mysql_querll("DELETE FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
mysql_querll("INSERT INTO `kolhoz_blacklist` SET `id_user` = '$ku[id]', `id_ank` = '$ank[id]'");
}
else mysql_querll("DELETE FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
echo mysql_error();
}
echo "<div class='event'><h1>".($ank['id']==$ku['id']?"Общение":"<a href='?user=$ank[id]'>$anku[nick]</a> / Общение")."</h1></div>";
echo "<div class='content'><div class='block'><ul>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='img/icons/pencil.png'> <a href='?mail&new_msg=$ank[id]'>Написать</a></li>";
echo "<li><img alt='' width='16' height='16' src='img/icons/mail_filter_all.png'> <a href='?mail".($ank['id']!=$ku['id']?"&history=$ank[id]":null)."'>Переписка</a></li>";
if($ku['status']==3)echo "<li><img alt='' width='16' height='16' src='img/icons/money.png'> ".($ku['rating']>=$ank['rating']?"<a href='?perevod=$ank[id]'>":null)."Переслать монеты".($ku['rating']>=$ank['rating']?"</a>":null)."</li>";
if($ank['id']!=$ku['id'] && $ku['status']==3)echo "<li><img alt='' width='16' height='16' src='img/icons/ruby.png'> <a href='?perevod2=$ank[id]'>Переслать рубины</a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='img/icons/gift_plus.png'> <a href='?presents=$ank[id]&do'>Подарить</a></li>";
echo "<li><img alt='' width='16' height='16' src='img/icons/gift.png'> <a href='?presents=$ank[id]'>Подарки</a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='img/icons/favorite.png'> <a href='?communication=$ank[id]&friend'><span>".(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]' LIMIT 1"),0)==0?"В друзья":"Из друзей")."</span></a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='img/icons/ignore.png'> <a href='?communication=$ank[id]&blacklist'><span>".(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]' LIMIT 1"),0)==0?"В игнор":"Отменить игнор")."</span></a></li>";
echo "</ul></div>";
include_once 'inc/foot.php';
?>