Размер файла: 4.73Kb
<?php
include_once("incs/conf.php");
include_once("incs/fmysql.php");
include_once("incs/fnc.php");
include_once("incs/head.php");
$id=fil($_GET['id']);
$act=fil($_GET['act']);
$p=fil($_GET['p']);
$f=fil($_GET['f']);
if($id==""){$id=$user[id];}
$my=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$id'"));
$ban_ok=$user[ban]-$time;
if($ban_ok>0){
echo "Вы забанены по причине:<br>";
echo "<b>$user[ban_prich]</b><br>";
echo "До окончания бана осталось: $ban_ok сек.<br>";
echo "Старайтесь больше не нарушать <a href=\"../rules.php\">правила</a> сайта!<br>";
include_once("incs/down.php");
}
switch($act){
case 'friend_add':
head("Друзья - Предложения дружбы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"friends.php?id=$my[id]\">Друзья</a> - Предложения дружбы</div>";
if($f == "yes" && $p!==""){
mysql_query("UPDATE `friends` SET `podtverd` = '1' WHERE `id` = '$p'");
}
if($f == "no" && $p!=""){
mysql_query("DELETE FROM `friends` WHERE `id` = '$p'");
}
$kol_friend = mysql_num_rows(mysql_query("SELECT id FROM `friends` WHERE `id_user` = '$my[id]' AND `podtverd` = '0' OR `id_friends` = '$my[id]' AND `podtverd` = '0'"));
if($kol_friend==0)
{
echo "Нет предложений дружбы";
}
if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($kol_friend/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages=1){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}
$fre=mysql_query("SELECT * FROM `friends` WHERE `podtverd` = '0' ORDER BY id DESC LIMIT $start, $end");
while ($friend = mysql_fetch_array($fre))
{
if($num==1){
echo "<div class='reki'>";
$num=0;
}else{
echo "<div class='rek'>";
$num=1;}
if($friend[id_user]==$my[id]){$frend=$friend[id_friends];}
else{$frend=$friend[id_user];}
$friends=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$frend'"));
if($friends[pol]==0){echo "<img src=\"img/0.png\" alt=\"image\"/>";}
if($friends[pol]==1){echo "<img src=\"img/1.png\" alt=\"image\"/>";}
echo "<a href=\"id$friends[id]\">$friends[nick]</a><br>";
echo "<a href='?id=$id&act=friend_add&f=yes&p=$friend[id]'>Принять</a> | <a href='?id=$id&act=friend_add&f=no&p=$friend[id]'>Отклонить</a></div>";
echo "</div>";
}
if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?id=$id&act=friend_add&page=$i'>$i</a></span>";
}}}
include_once("incs/down.php");
break;
case'del':
if($id!="" && $id!=0){
mysql_query("DELETE FROM `friends` WHERE
(`id_user` = '$id' AND `podtverd` = '1' AND `id_friends` = '$f') OR
(`id_friends` = '$id' AND `podtverd` = '1' AND `id_user` = '$f')");
}
break;
}
head("Друзья",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "Друзья</div>";
$kol_friends = mysql_num_rows(mysql_query("SELECT id FROM `friends` WHERE `id_user` = '$my[id]' AND `podtverd` = '1' OR `id_friends` = '$my[id]' AND `podtverd` = '1'"));
if($kol_friends==0)
{
echo "Нет друзей";
}
if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($kol_friends/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}
$fre=mysql_query("SELECT * FROM `friends` WHERE `id_friends` = '$id' AND `podtverd` = '1' OR `id_user` = '$id' AND `podtverd` = '1' ORDER BY id DESC LIMIT $start, $end");
while ($friend = mysql_fetch_array($fre))
{
if($num==1){
echo "<div class='reki'>";
$num=0;
}else{
echo "<div class='rek'>";
$num=1;}
if($friend[id_user]==$my[id]){$frend=$friend[id_friends];}
else{$frend=$friend[id_user];}
$friends=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$frend'"));
echo " <a href='id$friends[id]'>".(file_exists("avatar/".$friends['id'].$friends['avatar']) ? "<img src='avatar/".$friends['id'].$friends['avatar']."' width='48' height='60' alt='ava' border='0'/>" : "")."</a>";
if($friends[pol]==0){echo "<img src=\"img/0.png\" alt=\"image\"/><a href='id$friends[id]'>$friends[nick]</a>";}
if($friends[pol]==1){echo "<img src=\"img/1.png\" alt=\"image\"/><a href='id$friends[id]'>$friends[nick]</a>";}if($id==$user[id]){
echo " - <a href=\"friends.php?id=$id&f=$friends[id]&act=del\">уд.</a>(из друзей)<br>";
}
echo "</div>";
}
if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?id=$id&page=$i'>$i</a></span>";
}}}
include_once("incs/down.php");
?>