|
<?php
//-----Создаем титл страницы-----//
$title = 'Друзья';
//-----Подключаем функции-----//
require_once ('../system/function.php');
//-----Подключаем вверх-----//
require_once ('../system/header.php');
//-----Если гость,то...----//
if(!$user['id']) {
header('Location: /index.php');
exit();
}
$id = abs(intval($_GET['id']));
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."'"));
$f = mysql_fetch_assoc(mysql_query("SELECT * FROM `friend` WHERE `id` = '".$user[id]."' AND `i` = '0'"));
switch($_GET['act'])
{
default:
echo '<div class="title"><center>Заявки в друзья</center></div>';
if($f < 1)
{echo '<div class="podmenu">Заявок не поступало</a></div>';}
$friend = mysql_query("SELECT * FROM `friend` WHERE `id` = '".$user[id]."' AND `i` = '0' ORDER BY `time`");
while($f = mysql_fetch_assoc($friend))
{
echo '<div class="anketa">'.nick($f['friend']).' [<a href="'.$HOME.'/user/friend_new.php?act=add&id='.$f['friend'].'">Принять</a>] [<a href="'.$HOME.'/user/friend_new.php?act=otkl&id='.$f['friend'].'">Отклонить</a>]</div> ';
}
echo '<a href="/user_'.$user[id].'"><div class="anketa"> Назад</div></a>';
break;
case 'add':
$id = abs(intval($_GET['id']));
$anks = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$stenka['us']."'"));
$f = mysql_fetch_assoc(mysql_query("SELECT * FROM `friend` WHERE `id` = '".$user[id]."' AND `i` = '0'"));
if($f[N] == 0) {
echo '<div class="title">Заявки | Ошибка</div><div class="podmenu"><center><b>Такой заявки не существует!</b></center></div>';
require_once ('../system/footer.php');
exit();
}
if($user['id'] != $ank['id'])
{
mysql_query("INSERT INTO `lenta` SET `readlen` = '0', `time` = '".time()."', `komy` = '".$ank['id']."', `kto` = '".$user['id']."', `text` = 'принял Вашу заявку на предложение дружбы'");
}
mysql_query("INSERT INTO `friend` SET `friend` = '".$user[id]."', `id` = '".$id."', `time` = '".time()."', `i` = '1' ");
mysql_query("UPDATE `friend` SET `time` = '".time()."', `i` = '1' WHERE `id` = '".$ank[id]."'");
mysql_query("UPDATE `friend` SET `time` = '".time()."', `i` = '1' WHERE `friend` = '".$id."'");
header('Location: '.$HOME.'/user/friend_new.php');
exit();
break;
case 'otkl':
$id = abs(intval($_GET['id']));
$anks = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$stenka['us']."'"));
$f = mysql_fetch_assoc(mysql_query("SELECT * FROM `friend` WHERE `id` = '".$user[id]."' AND `i` = '0'"));
if($f[N] == 0) {
echo '<div class="title">Заявки | Ошибка</div><div class="podmenu"><center><b>Такой заявки не существует!</b></center></div>';
require_once ('../system/footer.php');
exit();
}
if($user['id'] != $ank['id'])
{
mysql_query("INSERT INTO `lenta` SET `readlen` = '0', `time` = '".time()."', `komy` = '".$ank['id']."', `kto` = '".$user['id']."', `text` = 'отклонил Вашу заявку на предложение дружбы'");
}
mysql_query("DELETE FROM `friend` WHERE `friend` = '".$ank[id]."'");
header('Location: '.$HOME.'/user/friend_new.php');
exit();
break;
}
//-----Подключаем низ-----//
require_once ('../system/footer.php');
?>