Файл: my/friends.php
Строк: 251
<?
define('GCMS',true);
define('ROOT','../');
require_once (ROOT.'system/power.php');
$fuser->aut();
switch ($do) {
////заявка в друзья
case 'pri':
if($mode=='jav')$url_back='?do=jav'; else $url_back=ROOT.'id'.$id;
//проверяем,есть ли пользователь
$sql_user = $db -> query("SELECT `id` FROM `users` WHERE `id` = '".$id."' LIMIT 1");
if ($sql_user -> num_rows > 0) {
//проверяем,не в игноре ли мы или он
if ($fuser->ignor($id,$ya['id'])==false and $fuser->ignor($ya['id'],$id)==false) {
$sql = $db -> query("SELECT * FROM `nuts` WHERE `time`='0' and `where`='frends' and `idwh`='$ya[id]' and `user`='$id' or `time`='0' and `where`='frends' and `user`='$ya[id]' and `idwh`='$id' LIMIT 1");
if ($sql -> num_rows > 0) {
$ass = $sql -> fetch_assoc();
if($ass['idwh']==$ya['id']){
$db -> query("INSERT INTO `nuts` set `user` = '$ya[id]',`idwh` = '$id',`where` = 'frends',`time` = '".time()."'");
$db -> query("UPDATE `nuts` SET `time` = '".time()."' WHERE `id` = '".$ass['id']."'");
}else{
$db -> query("INSERT INTO `nuts` set `idwh` = '$ya[id]',`user` = '$id',`where` = 'frends',`time` = '".time()."'");
$db -> query("UPDATE `nuts` SET `time` = '".time()."' WHERE `id` = '".$ass['id']."'");
}
//
$fuser->lenta($ya['id'],''.$fuser->ifsex($ya['id'],'Подружился','Подружилась').' с '.$fuser->avatar($id,24,24).' '.$fuser->famname($id).'',1,'friends');
$fuser->lenta($id,''.$fuser->ifsex($id,'Подружился','Подружилась').' с '.$fuser->avatar($ya['id'],24,24).' '.$fuser->famname($ya['id']).'',1,'friends');
//
header('location: '.$url_back);
} else {
$text=$fuser->famname($ya['id'],0).' предлогает вам дружбу,посмотреть список заявок можно в [url=http://'.shit($_SERVER['SERVER_NAME']).'/my/friends.php?id='.$id.']списке друзей[/url]';
$fuser->sysmail($text,$id);
$db -> query("INSERT INTO `nuts` set `user` = '$ya[id]',`idwh` = '$id',`where` = 'frends',`time` = '0'");
header('location: '.ROOT.'id'.$id.'');
}
} else header('location: '.ROOT.'id'.$id);
} else {
$db -> query("DELETE FROM `nuts` WHERE `idwh`='$id' and `user`='$ya[id]' or `user`='$id' and `idwh`='$ya[id]'");
header('location: '.ROOT.'id'.$id);
}
break;
////Удаление из друзей
case 'delfr':
if($mode=='friends')$url_back='?do=jav'; elseif($mode=='myjav') $url_back='?do=myjav'; else $url_back=ROOT.'id'.$id;
$sql = $db -> query("SELECT `id` FROM `nuts` WHERE `idwh`='".$ya['id']."' and `user` = '".$id."' and `where`='frends' or `user`='".$ya['id']."' and `idwh` = '".$id."' and `where`='frends' LIMIT 1");
if ($sql -> num_rows > 0) {
$db -> query("DELETE FROM `nuts` WHERE `idwh`='".$id."' and `user`='".$ya['id']."' or `idwh`='".$ya['id']."' and `user`='".$id."'");
header('location: '.$url_back);
} else header('location: '.$url_back);
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">'.$fuser->avatar($users['user']).'</td>
<td>'.$fuser -> famname($users['user']).' '.$fuser -> online($users['user']).'<br/>
Предлагает вам дружбу</td>
</tr></table></div>';
echo '<div class="dialog">
<a class="dialog_m" href="?do=pri&id='.$users['user'].'&mode=jav">'.language('Принять').'</a>
<a class="dialog_m" href="?do=delfr&id='.$users['user'].'&mode=friends">'.language('Отклонить').'</a>
</div>';
}
$act = '?do=jav';
echo $func -> pagenav($act,$page,$total);
}else echo'<div class="fon">'.language('Список пуст').'</div>';
echo '<div class="levo"><a href="?id='.$ya['id'].'" class="levo_tuch">'.$diz -> icon('back.png').' '.language('Назад').'</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">
<table border="0" width="100%"><tr valign="top">
<td height="0" width="26">'.$fuser->avatar($users['idwh']).'</td>
<td>Заявка для<br/>'.$fuser -> famname($users['idwh']).' '.$fuser -> online($users['idwh']).'</td>
</tr></table></div>';
echo '<div class="dialog">
<a class="dialog_m" href="?do=delfr&id='.$users['idwh'].'&mode=myjav">'.language('Отменить').'</a>
</div>';
}
$act = '?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 -> icon('back.png').' '.language('Назад').'</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 '<a href="'.ROOT.'id'.$users['user'].'" class="mail">
<table border="0" width="100%"><tr valign="top">
<td height="0" width="26">'.$fuser->avatar($users['user']).'</td>
<td>'. $fuser -> famname($users['user'],0).'<br/>
'. $fuser -> online($users['user']).'
</td></tr></table></a>';
}
$act = '?do=fr_only';
echo $func -> pagenav($act,$page,$total);
}else echo '<div class="fon">'.language('Список пуст').'</div>';
}else header('Location: /id'.$id);
echo '<div class="levo"><a href="?id='.$id.'" class="levo_tuch">'.$diz -> icon('back.png').' '.language('Назад').'</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('Список друзей');
echo '<div class="but_razdel">';
if($id!=$ya['id'])echo '<a class="button_razdel" style="width:25%;" href="/id'.$id.'">'.$fuser->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'");
if($myjav>0)echo'<a class="button_razdel" style="width:25%;" href="?do=myjav">Мои заявки в друзья <span class="chet"/>'.$myjav.'</span></a>';
if($jav>0)echo'<a class="button_razdel" style="width:25%;" 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:25%;" 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">'.$fuser->avatar($users['user']).'</td>
<td>'. $fuser -> famname($users['user'],0).'<br/>
'. $fuser -> online($users['user']).'<br/>';
if($id==$ya['id'])echo '<a href="?do=delfr&id='.$users['user'].'">Удалить</a></td>';
echo '</tr></table></a></div>';
}
echo $func -> pagenav('?',$page,$total);
}else echo '<div class="fon">'.language('Список пуст').'</div>';
}else header('Location: '.ROOT.'id'.$id);
}
echo '<div class="levo"><a href="./" class="levo_tuch">'.$diz -> icon('back.png').' '.language('Мой кабинет').'</a></div>';
echo '<div class="levo"><a href="/index.php" class="levo_tuch">'.$diz -> icon('home.png').' '.language('На главную').'</a></div>';
#####Копирайт#######
$diz -> out($msg);
?>