<?
if(isset($_GET['friend']))
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)==0)
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)!=0)mysql_query("DELETE FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
mysql_query("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_query("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_query("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)==0)
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)!=0)mysql_query("DELETE FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
mysql_query("INSERT INTO `kolhoz_blacklist` SET `id_user` = '$ku[id]', `id_ank` = '$ank[id]'");
}
else mysql_query("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='images/icons/pencil.png'> <a href='?mail&new_msg=$ank[id]'>Написать</a></li>";
echo "<li><img alt='' width='16' height='16' src='images/icons/mail_filter_all.png'> <a href='?mail".($ank['id']!=$ku['id']?"&history=$ank[id]":null)."'>История переписки</a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='images/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='images/icons/ruby.png'> <a href='?perevod2=$ank[id]'>Переслать</a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='images/icons/gift_plus.png'> <a href='?presents=$ank[id]&do'>Подарить</a></li>";
echo "<li><img alt='' width='16' height='16' src='images/icons/gift.png'> <a href='?presents=$ank[id]'>Подарки</a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='images/icons/favorite.png'> <a href='?communication=$ank[id]&friend'><span>".(mysql_result(mysql_query("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='images/icons/ignore.png'> <a href='?communication=$ank[id]&blacklist'><span>".(mysql_result(mysql_query("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';
?>