Файл: my/friends.php
Строк: 259
<?
define('GCMS',true);
define('ROOT','../');
require_once (ROOT.'system/power.php');
$func->aut();
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=''.$func->famname($ya['id'],0).' '.$func->ifsex($ya['id'],'принял','приняла').' вашу заявку в друзья';
$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'],''.$func->ifsex($ya['id'],'Подружился','Подружилась').' с [gomy=id'.$u['id'].']'.$u['login'].'[/gomy]',1,'frends');
$func->lenta($ass['user'],''.$func->ifsex($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=''.$func->famname($ya['id'],0).' предлогает вам дружбу,посмотреть список заявок можно в [url=http://'.shit($_SERVER['SERVER_NAME']).'/my/friends.php?id='.$id.']списке друзей[/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 `idwh` = '".$id."' and `where`='frends' or `user`='".$ya['id']."' and `idwh` = '".$id."' and `where`='frends' LIMIT 1");
if ($sql -> num_rows > 0) {
$us = $sql -> fetch_assoc();
$db -> query("DELETE FROM `nuts` WHERE `idwh`='".$id."' and `user`='".$ya['id']."' or `idwh`='".$ya['id']."' and `user`='".$id."'");
header('location: /id'.$id.'');
} 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 -> famname($users['user']).' '.$func -> online($users['user']).'<br/>
Предлагает вам дружбу</td>
</tr></table></div>';
echo '<div class="dialog">
<a class="dialog_m" href="?do=pri&id='.$users['id'].'">Принять</a>
<a class="dialog_m" href="?do=otjav&id='.$users['id'].'">Отклонить</a>
</div>';
}
$act = 'friends.php?do=jav';
echo $func -> pagenav($act,$page,$total);
}else echo'<div class="fon">Заявок в друзья к вам нет</div>';
echo '<div class="levo"><a href="?id='.$ya['id'].'" 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="?id='.$ya['id'].'" class="levo_tuch">'.$diz -> img('back.png').' Назад</a></div>';
break;
case 'fr_only':
$diz -> head('Друзья в сети');
$diz -> title('Друзья в сети');
$us = $db -> dbcount('COUNT(`id`)','users',"`id`='".$id."'");
if($us>0){
$fr_online = $db -> query("SELECT COUNT(`id`) as `count` FROM `nuts` where `user` IN (SELECT `id` FROM `online`) and `time`<>'0' and `idwh`='".$ya['id']."' and `where`='frends'")->fetch_assoc();
$count=$fr_online['count'];
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 COUNT(`id`) as `count`,`user` FROM `nuts` where `user` IN (SELECT `id` FROM `online`) and `time`<>'0' and `idwh`='".$ya['id']."' and `where`='frends' ORDER BY `id` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
echo '<div class="mail"/><a href="/id'.$users['user'].'"/>
<table border="0" width="100%"><tr valign="top">
<td height="0" width="26">'.$func->avatar($users['user']).'</td>
<td>'. $func -> famname($users['user'],0).'<br/>
'. $func -> online($users['user']).'
</td></tr></table></a></div>';
}
$act = 'friends.php?';
echo $func -> pagenav($act,$page,$total);
}else echo '<div class="fon"/>У '.$func->famname($id).' нет друзей в сети.</div>';
}else header('Location: /id'.$id);
echo '<div class="levo"><a href="?id='.$id.'" class="levo_tuch">'.$diz -> img('back.png').' Назад</a></div>';
break;
default:
$diz -> head('Список друзей');
$us = $db -> dbcount('COUNT(`id`)','users',"`id`='".$id."'");
if($us>0){
$count = $db -> dbcount('COUNT(`id`)','nuts',"`where`='frends' and `idwh`='".$id."' and `time`<>'0'");
$diz -> title('Список друзей (Всего: <b>'.$count.'</b>)');
echo '<div class="but_razdel">
<a class="button_razdel" style="width:50%;" href="/id'.$id.'">'.$func->famname($id,0).'</a>';
if($ya['id']==$id){
$myjav = $db -> dbcount('COUNT(`id`)','nuts',"`where`='frends' and `user`='".$id."' and `time`='0'");
$jav = $db -> dbcount('COUNT(`id`)','nuts',"`where`='frends' and `idwh`='".$id."' and `time`='0'"); /// where
if($myjav>0)echo'<a class="button_razdel" style="width:50%;" href="?do=myjav">Мои заявки в друзья <span class="chet"/>'.$myjav.'</span></a>';
if($jav>0)echo'<a class="button_razdel" style="width:50%;" href="?do=jav">Заявки в друзья <span class="chet"/>'.$jav.'</span></a>';
}
$fr_online = $db -> query("SELECT COUNT(`id`) as `count` FROM `nuts` where `user` IN (SELECT `id` FROM `online`) and `time`<>'0' and `idwh`='".$ya['id']."' and `where`='frends'")->fetch_assoc();
echo'<a class="button_razdel" style="width:50%;" href="?do=fr_only&id='.$id.'">Друзья в сети <span class="chet"/>'.$fr_online['count'].'</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`='".$id."' and `where`='frends' ORDER BY `id` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
echo '<div class="mail"/><a href="/id'.$users['user'].'"/>
<table border="0" width="100%"><tr valign="top">
<td height="0" width="26">'.$func->avatar($users['user']).'</td>
<td>'. $func -> famname($users['user'],0).'<br/>
'. $func -> online($users['user']).'<br/>
<a href="?do=delfr&id='.$users['user'].'">Удалить</a></td>
</tr></table></a></div>';
}
$act = 'friends.php?';
echo $func -> pagenav($act,$page,$total);
}else echo '<div class="fon"/>У '.$func->famname($id).' нет друзей</div>';
}else header('Location: /id'.$id);
}
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);
?>