Файл: my/friends.php
Строк: 179
<?php
define('GCMS',true);
define('ROOT','../');
require_once (ROOT.'system/power.php');
switch ($do) {
////заявка в друзья
case 'pri':
$sql2 = $db -> query("SELECT * FROM `nuts` WHERE `idwh`='$id' and `user`='$ya[id]' and `where`='ignor' LIMIT 1");
if ($sql2 -> num_rows == 0) {
$sql2 = $db -> query("SELECT * FROM `nuts` WHERE `user`='$id' and `idwh`='$ya[id]' and `where`='ignor' LIMIT 1");
if ($sql2 -> num_rows == 0) {
$sql = $db -> query("SELECT * FROM `nuts` WHERE `time`='0' and `where`='frends' and `idwh`='$ya[id]' LIMIT 1");
if ($sql -> num_rows > 0) {
$ass = $sql -> fetch_assoc();
$sql2 = $db -> query("SELECT * FROM `users` WHERE `id` = '".$ass['user']."' LIMIT 1");
if ($sql2 -> num_rows > 0) {
$u = $sql2 -> fetch_assoc();
$db -> query("INSERT INTO `nuts` set `user` = '$ya[id]',`idwh` = '$ass[user]',`where` = 'frends',`time` = '".time()."'");
$text=''.$ya['login'].' принял вашу заявку в друзья';
$func->sysmail($text,$ass['user']);
$db -> query("UPDATE `nuts` SET `time` = '".time()."' WHERE `user` = '$ya[id]' and `idwh` = '$ass[user]' or `user` = '$ass[user]' and `idwh` = '$ya[id]'");
$func->lenta($ya['id'],'Подружился(ась) с [gomy=id'.$u['id'].']'.$u['login'].'[/gomy]',1,'frends');
$func->lenta($ass['user'],'Подружился(ась) с [gomy=id'.$ya['id'].']'.$ya['login'].'[/gomy]',1,'frends');
header('location: /id'.$u['id'].'');
} else {
$db -> query("DELETE FROM `nuts` WHERE `id`='$id'");
header('location: ?');
}
} else {
$text=''.$ya['login'].' предлогает вам дружбу,посмотреть список заявок можно в [url=http://'.$_SERVER['SERVER_NAME'].'/my/friends.php]списке друзей[/url]';
$func->sysmail($text,$id);
$db -> query("INSERT INTO `nuts` set `user` = '$ya[id]',`idwh` = '$id',`where` = 'frends',`time` = '0'");
header('location: /id'.$id.'');
}
} else header('location: /id'.$id.'');
} else header('location: /id'.$id.'');
break;
////Удаление из друзей
case 'delfr':
$sql = $db -> query("SELECT * FROM `nuts` WHERE `idwh`='$ya[id]' and `id` = '".$id."' and `where`='frends' or `user`='$ya[id]' and `id` = '".$id."' and `where`='frends' LIMIT 1");
if ($sql -> num_rows > 0) {
$us = $sql -> fetch_assoc();
if($us['user']==$ya['id'])$id_u=$us['idwh']; else $id_u=$us['user'];
$db -> query("DELETE FROM `nuts` WHERE `idwh`='$us[user]' or `user`='$ya[id]'");
$db -> query("DELETE FROM `nuts` WHERE `id`='$id'");
header('location: /id'.$id_u.'');
} else header('location: ?');
break;
////Заявки в друзья
case 'jav':
$diz -> head('Заявки в друзья');
$count = $db -> dbcount('COUNT(`id`)','nuts',"`where`='frends' and `idwh`='$ya[id]' and `time`='0'");
$diz -> title('Список заявок (Всего: <b>'.$count.'</b>)');
if($count>0){
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$sql = $db -> query("SELECT * FROM `nuts` where `time`='0' and `idwh`='$ya[id]' and `where`='frends' ORDER BY `user` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
echo '<div class="fon"/>
<table border="0" width="100%"><tr valign="top">
<td height="0" width="26">'.$func->avatar($users['user']).'</td>
<td>'.$func -> nick($users['user']).' '.$func -> online($users['user']).'<br/>
Предлагает вам дружбу<br/>
<a href="?do=pri&id='.$users['id'].'">Принять</a> | <a href="?do=otjav&id='.$users['id'].'">Отклонить</a></td>
</tr></table></div>';
}
$act = 'friends.php?do=jav';
echo $func -> pagenav($act,$page,$total);
}else echo'<div class="fon">Заявок в друзья к вам нет</div>';
echo '<div class="levo"><a href="?" class="levo_tuch">'.$diz -> img('back.png').' Назад</a></div>';
break;
////Мои заявки в друзья
case 'myjav':
$diz -> head('Мои заявки в друзья');
$count = $db -> dbcount('COUNT(`id`)','nuts',"`where`='frends' and `user`='$ya[id]' and `time`='0'");
$diz -> title('Список заявок (Всего: <b>'.$count.'</b>)');
if($count>0){
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$sql = $db -> query("SELECT * FROM `nuts` where `time`='0' and `user`='$ya[id]' and `where`='frends' ORDER BY `idwh` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
echo '<div class="fon">Заявка для '. $func -> user($users['idwh']).'</div>';
}
$act = 'friends.php?do=myjav';
echo $func -> pagenav($act,$page,$total);
}else{echo '<div class="fon">Ваших заявок в друзья не найдено</div>';}
echo '<div class="levo"><a href="?" class="levo_tuch">'.$diz -> img('back.png').' Назад</a></div>';
break;
default:
$diz -> head('Список друзей');
$count = $db -> dbcount('COUNT(`id`)','nuts',"`where`='frends' and `idwh`='$ya[id]' and `time`<>'0'");
$diz -> title('Список друзей (Всего: <b>'.$count.'</b>)');
$myjav = $db -> dbcount('COUNT(`id`)','nuts',"`where`='frends' and `user`='$ya[id]' and `time`='0'");
echo '<div class="levo"/><a href="?do=myjav" class="levo_tuch">Мои заявки в друзья <span class="count"/>'.$myjav.'</span></a></div>';
$jav = $db -> dbcount('COUNT(`id`)','nuts',"`where`='frends' and `idwh`='$ya[id]' and `time`='0'");
echo '<div class="levo"/><a href="?do=jav" class="levo_tuch">Заявки в друзья <span class="count"/>'.$jav.'</span></a></div>';
if($count>0){
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$sql = $db -> query("SELECT * FROM `nuts` where `time`<>'0' and `idwh`='$ya[id]' and `where`='frends' ORDER BY `id` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
echo '<div class="menu"/><a href="/id'.$users['user'].'" class="menutuch"/>
<table border="0" width="100%"><tr valign="top">
<td height="0" width="26">'.$func->avatar($users['user']).'</td>
<td>'. $func -> nick($users['user'],0).'<br/>
'. $func -> online($users['user']).'<br/>
<a href="?do=delfr&id='.$users['id'].'">Удалить</a></td>
</tr></table></a></div>';
}
$act = 'friends.php?';
$msg .= $func -> pagenav($act,$page,$total);
}else echo '<div class="fon"/>У вас нет друзей</div>';
}
echo '<div class="levo"><a href="./" class="levo_tuch">'.$diz -> img('back.png').' Личный кабинет</a></div>';
echo '<div class="levo"><a href="/index.php" class="levo_tuch">'.$diz -> img('home.png').' На главную</a></div>';
#####Копирайт#######
$diz -> out($msg);
?>