Файл: vkollektive2014/soo/index.php
Строк: 263
<?
include_once '../connect.php';
$location = '(В сообществах)';
include_once '../core/panel.php';
include_once '../core/bb_code.php'; if(!$u['id']){header ("Location: /login.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';
if(isset($_GET['rules']))
{
$title=$soo['name'].' - Правила сообщества'; // заголовок страницы
include_once '../head.php';
include_once '../core/panel.php'; include_once '../core/bb_code.php';
echo'<div class="div"><b>Правила сообщества:</b><br/></div><div class="div">';
echo ''.smile(links(bb_code($soo['rules']))).'';
echo'</div>';
echo'<div class="div"><img src="/style/img/l.gif" alt="" class="icon"/><a href="?s='.$soo['id'].'">В сообщество</a></div>';
}
else
{
$title=''.$title.' | '.$soo['name'].''; // заголовок страницы
include_once '../head.php';
if(isset($u) && $u['id']==$soo['new_adm'] && isset($_GET['new_sozd']) && $_GET['new_sozd']=='not'){
mysql_query("UPDATE `soo` SET `new_adm`='' WHERE `id`='$soo[id]' LIMIT 1");
ok('Вы отказались от сообщества!');}
include_once 'inc/user_act.php';
if(!isset($u) || isset($u) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_user` = '$u[id]' AND `id_soo`='$soo[id]' AND `activate`='0' AND `invit`='0' LIMIT 1"),0)==0 && $u['id']!=$soo['admid'])
{
if($soo['konf_soo']==0 || $soo['konf_soo']==1)echo'<div class="nav"><img src="img/open.png" alt=""/> Открыто для чтения</div>'; if($soo['konf_soo']==0)echo'<div class="nav"><img src="img/open.png" alt=""/> Открыто для чтения</div>'; else echo'<div class="nav"><img src="img/close.png" alt=""/> Закрыто для чтения</div>';
}
echo'<div class="zona">';
echo'<table class="qq">';
echo '<tr>';
echo'<td class="icon48" rowspan="2">';
if (is_file($_SERVER['DOCUMENT_ROOT']."/soo/logo/$soo[id].jpg"))
echo '<img src="/soo/logo/'.$soo['id'].'.jpg" alt="'.$soo['name'].'" />';
elseif (is_file($_SERVER['DOCUMENT_ROOT']."/soo/logo/$soo[id].png"))
echo '<img src="/soo/logo/'.$soo['id'].'.png" alt="'.$soo['name'].'" />';
else
echo '<img src="/soo/img/0.png" alt="No Logo" />';
echo'</td>';
echo '<td class="gg">';
echo'</td>';
echo'</tr>';
echo '</table>';
echo'</div>';
if($soo['conf_news']==1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_news` WHERE `id_soo` = '$soo[id]' LIMIT 1"),0)!=0)
{
if($soo['konf_soo']==0 || isset($u) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$u[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1 || isset($u) && $u['id']==$soo['admid'])
{
$news=mysql_fetch_array(mysql_query("SELECT * FROM `soo_news` WHERE `id_soo` = '$soo[id]' ORDER BY `time` DESC LIMIT 1"));
echo'<div class="nav"><img src="/style/themes/'.$set['set_them'].'/icons/news.png" alt="" /> <b>'.$news['name'].'</b> ('.vremya($news['time']).')<br/>';
echo ''.smile(links(bb_code($news['mess']))).'</div>';
}
}
echo'<div class="main_menu">';
$count_forum_t = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_forum_thems` WHERE `id_soo` = '$soo[id]'"),0);
$count_forum_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_forum_mess` WHERE `id_soo` = '$soo[id]'"),0);
$count_news = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_news` WHERE `id_soo` = '$soo[id]'"),0);
$count_chat = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_chat` WHERE `id_soo` = '$soo[id]'"),0);
$count_votes_open = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id_soo` = '$soo[id]' AND `time_close`>'$time'"),0);
$count_votes_all = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id_soo` = '$soo[id]'"),0);
$count_users = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `activate`='0' AND `invit`='0'"),0);
$count_banned = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `activate`='0' AND `invit`='0' AND `ban`>'$time'"),0);
$count_friends = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_friends` WHERE `id_soo` = '$soo[id]'"),0);
echo'<div class="div">Имя сообщества: '.$soo['name'].' <span style="color:green"></span><br/></div>';
echo '<div class="div">Описание: '.smile(links(bb_code($soo['desc']))).'</div>';
if($soo['rules']!=NULL)echo'<div class="div"><img src="img/rules.png" alt=""/> <a href="index.php?s='.$soo['id'].'&rules">Правила сообщества</a><br/></div>';
echo'<div class="zona"><img src="img/rss.png" alt=""/> <a href="news.php?s='.$soo['id'].'">Новости</a> ('.$count_news.')<br/></br>';
echo'<img src="img/forum.png" alt=""/> <a href="forum.php?s='.$soo['id'].'">Форум</a> ('.$count_forum_t.'/'.$count_forum_p.')<br/></br>';
echo'<img src="img/chat.png" alt=""/> <a href="chat.php?s='.$soo['id'].'">Беседка</a> ('.$count_chat.')<br/></br>';
echo'<img src="img/users.png" alt=""/> <a href="users.php?s='.$soo['id'].'">Участники</a> ('.$count_users.')<br/></br>';
#echo'<img src="img/banned.png" alt=""/> <a href="banned.php?s='.$soo['id'].'">Забаненные</a> ('.$count_banned.')<br/></br>';
echo'<img src="img/cat.png" alt=""/> <a href="friends.php?s='.$soo['id'].'">Партнеры</a> ('.$count_friends.')<br/></div><div class="div">';
if(isset($u))
{
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]' LIMIT 1"));
if(isset($u) && $u['id']==$soo['admid'] || $u_s['level']>'1')
{
echo'<img src="img/admin.png" alt=""/> <a href="admin.php?s='.$soo['id'].'">Управление сообществом</a><br/>';
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$u[id]' LIMIT 1"),0)==0 && $u['id']!=$soo['admid'])
{
if($soo['konf_soo']==0 || $soo['konf_soo']==1 || $soo['konf_soo']==3)
{
echo'<img src="img/open.png" alt=""/> <a href="index.php?s='.$soo['id'].'&enter">Вступить в сообщество</a><br/>';
}
}
elseif(mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$u[id]' AND `invit`='1' LIMIT 1"),0)==1)
{
echo'<img src="img/open.png" alt=""/> <a href="index.php?s='.$soo['id'].'&yes">Принять приглавшение</a><br/>';
echo'<img src="img/close.png" alt=""/> <a href="index.php?s='.$soo['id'].'&no">Отклонить приглашение</a><br/>';
}
elseif(mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$u[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1)
{
#echo'<img src="img/invite.png" alt=""/> <a href="users.php?s='.$soo['id'].'&invite">Пригласить в соо</a><br/>';
if($u['id']!=$soo['admid'])echo'<img src="img/close.png" alt=""/> <a href="index.php?s='.$soo['id'].'&exit">Покинуть сообщество</a><br/>';
}
}
#
echo'</div></div>';
echo '<div class="main"><b>Ссылка на сообщество:</b> <a href="/soo/'.$soo['id'].'">http://'.$_SERVER['HTTP_HOST'].'/soo/'.$soo['id'].'</a><br/></div>';
echo'<div class="zona"><img src="img/back.png" alt=""/> <a href="/soo/">Вернутся к разделам</a></div>';
}
}
elseif(isset($_GET['r']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_cat` WHERE `id` = '".intval($_GET['r'])."' LIMIT 1"),0)==1)
{
$r=intval($_GET['r']);
$razdel=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_cat` WHERE `id` = '$r' LIMIT 1"));
$title=$title.'Сообщества - '.$razdel['name']; // заголовок страницы
include_once '../head.php';
if(isset($_GET['sort']))
{
if($_GET['sort']=='users'){$sort='users'; $por='DESC';}
elseif($_GET['sort']=='open'){$sort='konf_soo'; $por='ASC';}
else{$sort='time'; $por='DESC';}
}
else
{
$sort='time'; $por='DESC';
}
if(isset($u) && $u['admin']>0 && isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `id` = '".intval($_GET['del'])."' LIMIT 1"),0)==1)
{
$delid=intval($_GET['del']);
$del=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo` WHERE `id` = '".$delid."' LIMIT 1"));
$deladm=$del['admid'];
if($u['admin']>0 || $u['id']==$deladm['id'])
{
if(isset($_GET['ok']))
{
mysql_query("DELETE FROM `soo_users` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_chat` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_news` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_bl` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_friends` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_friends` WHERE `id_friend`='$delid'");
mysql_query("DELETE FROM `soo_votes` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_votes_otvet` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_forums` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_forum_thems` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_forum_mess` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo` WHERE `id`='$delid'");
mysql_query("DELETE FROM `soo_obmen_dir` WHERE `id_soo`='$delid'");
$q=mysql_query("SELECT * FROM `soo_obmen_files` WHERE `id_soo`='@$soo[id]'");
while ($delete = mysql_fetch_assoc($q))
{
unlink(H.'sys/soo/obmen/files/'.$delete['id'].'.dat');
}
mysql_query("DELETE FROM `soo_obmen_files` WHERE `id_soo`='$delid'");
mysql_query("DELETE FROM `soo_obmen_komm` WHERE `id_soo`='$delid'");
ok('Сообщество успешно удалено');
}
else
{
echo'<div class="err">Вы уверены,что хотите удалить данное сообщество?<br/>';
echo'<a href="?r='.$r.'&del='.$delid.'&ok">Да</a> | <a href="?r='.$r.'">Нет</a></div>';
}
}
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `id_cat`='$r'"),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'<div class="cred">';
echo'Сортировать: [<a href="?r='.$r.'&sort=users&page='.$page.'">Популярные</a>] [<a href="?r='.$r.'&sort=time&page='.$page.'">Новые</a>] [<a href="?r='.$r.'&sort=open&page='.$page.'">Открытые</a>]</div>';
echo'<div class="div"><img src="img/open.png" alt="open"/> - Открытые для чтения<br/>';
echo'<img src="img/close.png" alt="close"/> - Закрытые для чтения</div>';
echo '<class="zona">';
if ($k_post==0)
{
echo 'Нет сообществ в данной категории';
}
else
{
$q=mysql_query("SELECT * FROM `soo` WHERE `id_cat`='$r'");
while ($comm = mysql_fetch_assoc($q))
{
if(@$num==1){
echo "<div class='div'>";
$num=0;
}else{
echo "<div class='div'>";
$num=1;}
if($comm['konf_soo']==0 || $comm['konf_soo']==1)echo'<img src="img/open.png" alt="open"/>'; else echo'<img src="img/close.png" alt="close"/>';
echo ' <a href="/soo/'.$comm['id'].'">'.$comm['name'].'</a>';
$time=time()-7200;
if($comm['ban']!=NULL && $comm['ban']>$time)echo'[BAN]';
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo`='$comm[id]' AND `activate`='0' AND `invit`='0'"),0);
#if(isset($_GET['sort']) && $_GET['sort']=='users')echo'<br/> Участников в сообществе: '.$count.''; else
#echo "<br/>";
echo '<br/>Описание: '.smile(links(bb_code($comm['desc']))).'';
if($u['admin']>0 && $u['id']!=$comm['admid'])
{
#echo'</br>[<a href="ban.php?s='.$comm['id'].'">Нарушения</a>]';
}
if(isset($u) && $u['admin']>0 || $u['id']==$comm['admid'])
{
echo'<br/>[<a href="?r='.$r.'&del='.$comm['id'].'">Удалить соо</a>]';
}
echo "</div>";
}
if($page>1)navigation($page, $total,'?r='.$r.'&sort='.$sort.'&'.$por.'&'); // Вывод страниц
echo'<div class="zona">';
echo'<img src="img/back.png" alt=""/> <a href="/soo/">Сообщества</a></div>';
}
}
else
{
if(isset($_GET['new']) && isset($u))
{
$title=$title.' Сообщества/'.@$razdel['name'].'/Новое сообщество'; // заголовок страницы
include_once '../head.php';
$limit = 3;
$time_create = 60*60*24*30;
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `admid` = '$u[id]' LIMIT 1"),0)>=$limit && $u['admin']<1)
{
echo'Максимальное количество сообществ на одного человека <b>'.$limit.'</b>, у Вас уже столько имеется<br/>';
}
elseif(mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `admid` = '$u[id]' LIMIT 1"),0)!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `admid` = '$u[id]' LIMIT 1"),0)<$limit && $u['admin']<1)
{
$last_soo = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo` WHERE `admid` = '$u[id]' ORDER BY `time` DESC LIMIT 1"));
$time_new = $last_soo['time']+$time_create;
if($time<$time_new)
{
echo'<div class="err">Нельзя так часто создавать сообщества.Следующая возможность у Вас будет '.vremya($time_new).'</div>';
}
else
{
include_once 'inc/new_act.php';
include_once 'inc/new_form.php';
}
}
elseif(mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `admid` = '$u[id]' LIMIT 1"),0)==0 || $u['admin']>=1)
{
include_once 'inc/new_act.php';
include_once 'inc/new_form.php';
}
echo'<img src="img/back.png" alt=""/> <a href="/soo/">Сообщества</a><br/>';
}
else{
$title=$title.' Сообщества'; // заголовок страницы
include_once '../head.php';
if(isset($u) && $u['admin']>0)
{
include_once 'inc/admin_soo_act.php';
}
if(isset($u))echo'<div class="div"><img src="img/add.png" alt=""/> <a href="?new">Создать сообщество</a><br/>';
echo "</div>";
$q=mysql_query("SELECT * FROM `soo_cat`");
if (mysql_num_rows($q)==0){
echo 'Нет категорий';
}
while ($cat = mysql_fetch_assoc($q))
{
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `id_cat`='$cat[id]'"),0);
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="?r='.$cat['id'].'">'.$cat['name'].'</a> ('.$count.')';echo '<br/>';
if ($cat['desc']!=NULL)
{
echo ''.smile(links(bb_code($cat['desc']))).'<br />';
}
if(isset($u) && $u['admin']>0)
{
echo' [<a href="?edit='.$cat['id'].'">ред</a>][<a href="?del='.$cat['id'].'">[<font color="red">x</font></a>]<br/>';
}
echo '</div>';
}
if(isset($u) && $u['admin']>0)
{
echo "<div class='zona'>";
include_once 'inc/admin_soo_form.php';
echo "</div>";
}
}
}
include_once '../foot.php';
?>