Файл: vkollektive2014/soo/friends.php
Строк: 68
<?
include_once '../connect.php';
if(isset($_GET['s']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `id` = '".intval($_GET['s'])."' LIMIT 1"),0)==1)
{
$s=intval($_GET['s']);
$soo=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo` WHERE `id` = '$s' LIMIT 1"));
include_once 'inc/ban.php';
$user_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]' LIMIT 1"));
$set['title']=$soo['name'].' - Партнеры сообщества:'; // заголовок страницы
include_once '../head.php';
require('../core/bb_code.php');
require('../core/panel.php');
if(isset($u) && $user_s['level']>'0')
{
if(isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_friends` WHERE `id` = '".intval($_GET['del'])."' AND `id_soo`='$soo[id]' LIMIT 1"),0)==1)
{
mysql_query("DELETE FROM `soo_friends` WHERE `id`='".intval($_GET['del'])."' LIMIT 1");
//msg('Друг соо успешно удален');
}
elseif(isset($_POST['friend_add']) && $_POST['friend_add']!=$soo['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `id` = '".intval($_POST['friend_add'])."' LIMIT 1"),0)==1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_friends` WHERE `id_soo`='$soo[id]' AND `id_friend`='".intval($_POST['friend_add'])."' LIMIT 1"),0)==0)
{
$add_friend=intval($_POST['friend_add']);
mysql_query("INSERT INTO `soo_friends` (`id_soo`, `id_friend`, `time`) values ('$soo[id]', '$add_friend', '$time')");
//msg('Партнер сообщества успешно добавлен!');
}
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_friends` WHERE `id_soo`='$soo[id]'"),0);
$total = intval(($k_post - 1) / 10) + 1;
$page = intval(@$_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * 10 - 10;echo '<class="post">';
if ($k_post==0)
{
echo '<div class="div">Партнеров нет! :(</div>';
}
$q=mysql_query("SELECT * FROM `soo_friends` WHERE `id_soo`='$soo[id]' ORDER BY `time` ASC LIMIT $start, 10");
while ($friends = mysql_fetch_assoc($q))
{
$friend=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo` WHERE `id` = '$friends[id_friend]' LIMIT 1"));
if($num==1){
echo "<div class='div'>";
$num=0;
}else{
echo "<div class='div'>";
$num=1;}
echo '<img src="img/cat.png" alt="" />';
echo ' <a href="/soo/'.$friend['id'].'">'.$friend['name'].'</a> ('.vremya($friends['time']).')';
if(isset($u) && $user_s['level']>'0')echo' [<a href="?s='.$soo['id'].'&del='.$friends['id'].'">x</a>]<br />';
echo ''.smile(links(bb_code(censored($friend['desc'])))).'';
echo "</div>";
}
if($page>1)navigation($page, $total,'?s='.$soo['id'].'&'); // Вывод страниц
if(isset($u) && $user_s['level']>'0')
{
if(isset($_GET['add']))
{
echo'<div class="div"><form method="post" action="?s='.$soo['id'].'">';
echo'Введите ID сообщества:<br/>';
echo'<input type="text" name="friend_add" size="3">';
echo'<input type="submit" value="Добавить в список">';
echo'</form></div>';
}
else
{
echo'<div class="nav"><b>+</b> <a href="?s='.$soo['id'].'&add">Добавить партнера</a></div>';
}
}
echo'<div class="zona"><img src="/style/img/l.gif" alt="" class="icon"/><a href="index.php?s='.$soo['id'].'">В сообщество</a></div>';
}
else
{
header("Location:index.php");
}
include_once '../foot.php';
?>