Файл: pages/soo/group.php
Строк: 79
<?php
/*
author: SBeka
http://masteram.us/id580
*/
include ('../../system/mysql.php');
include ('../../system/sys_func.php');
$id = intval($_GET['id']);
if (!isset($user)) {
$title = 'Группы';
include ('../../system/head.php');
echo '<div class="err">Чтобы просматривать данную страницу вы должны <a href="/reg.php">зарегистрироваться</a> или <a href="/login.php">авторизоваться</a>!</div>';
foot();
exit;
}
$u = mysql_query("SELECT * FROM `group` WHERE `id`='$id'");
if (mysql_num_rows($u) != 1) {
$title = 'Ошибка';
include ('../../system/head.php');
echo '<div class="title">Ошибка</div>';
echo '<div class="err">Такой группы не существует!</div>
<a class="link" href="index.php">← Назад</a>';
foot();
exit;
}
$sqlGroup = mysql_fetch_assoc(mysql_query("SELECT * FROM `group` WHERE `id`='$id' LIMIT 1 "));
$sqlGroupUsers = mysql_result(mysql_query("SELECT COUNT(*) FROM `group_users` WHERE `group`='".$sqlGroup['id']."' AND `user`='".$user['id']."' "),0);
if (isset($_POST['outGroup'])) {
mysql_query("DELETE FROM `group_users` WHERE `group`='$sqlGroup[id]' AND `user`='$user[id]'");
$out = $sqlGroup['count_users']-1;
mysql_query("UPDATE `group` SET `count_users`='".$out."' WHERE `id`='$sqlGroup[id]' LIMIT 1");
header("Location: group.php?id=$sqlGroup[id]");
exit;
}elseif (isset($_POST['inGroup'])) {
mysql_query("INSERT INTO `group_users` SET `group`='$sqlGroup[id]', `user`='$user[id]', `date`='".time()."'");
$in = $sqlGroup['count_users']+1;
mysql_query("UPDATE `group` SET `count_users`='".$in."' WHERE `id`='$sqlGroup[id]' LIMIT 1");
header("Location: group.php?id=$sqlGroup[id]");
exit;
}
$title = $sqlGroup['name'];
include ('../../system/head.php');
echo "<div class='title'>$sqlGroup[name]</div>";
echo '<div class="post"><table cellpadding="5" cellspacing="5">
<tr>
<td> <img src="img/'.$sqlGroup['logo'].'" /> </td>
<td valign="top" width="100%"> <strong>'.$sqlGroup['name'].'</strong><hr/>';
if ($user['id'] == $sqlGroup['id_prez'] && $sqlGroupUsers == 1) {
if (!empty($sqlGroup['status'])) {
echo '<a href="status.php?id='.$sqlGroup['id'].'">'.$sqlGroup['status'].'</a>';
}else{echo '<a href="status.php?id='.$sqlGroup['id'].'">Не указано</a>';}
}else{
if (!empty($sqlGroup['status'])) {echo $sqlGroup['status'];}else{echo 'Не указано';} }
echo '</td>
</tr>
</table></div>';
echo '<form method="POST">';
if ($sqlGroupUsers == 1) echo '<center><input type="submit" name="outGroup" value="Выйти из группы" /></center>';
else echo '<center><input type="submit" name="inGroup" value="Вступить в группу" /></center>';
echo '</form>';
if ($sqlGroup['mod'] == 0 || $sqlGroupUsers == 1) {
//echo '<div class="b">Фотографий</div><div class="c"><br /></div>';
echo '<div class="b">Информация <span style="float:right">';
if ($sqlGroup['id_prez'] == $user['id'] && $sqlGroupUsers == 1)
echo '<a href="#">ред.</a>';
echo '</span></div>
<div class="c"><strong>Описания:</strong> '.$sqlGroup['opis'].'</div>
<div class="c"><strong>Новости:</strong> '.$sqlGroup['news'].'</div>
<div class="b">Другое</div>
<a class="link" href="users.php?id='.$sqlGroup['id'].'">Участники '.$sqlGroup['count_users'].'</a>
<a class="link" href="#">Фотографий</a>
<a class="link" href="#">О группе</a>';
if ($sqlGroup['id_prez'] == $user['id'] && $sqlGroupUsers == 1) {
echo '<a class="link" href="admin.php?id='.$sqlGroup['id'].'"><font color="red">Админ панел</font></a>';}
echo '<div class="b">Стена</div>';
if ($sqlGroupUsers == 1) {
echo '<div class="c"><form method="post" name="message" action="wall.php?id='.$id.'">';
include '../../system/bbcodes.php';
echo '<textarea name="msg" cols="25" rows="3"></textarea><br/>';
include '../../system/smiles.php';
echo '<input type="submit" name="sendWall" value="Написать на стене" />
</form></div>';}
$c_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `wall` WHERE `group_id`='$id' AND `razdel`='group_wall'"),0);
$k_page = k_page($c_p, $onpage);
$page = page($k_page);
$start = $onpage*$page-$onpage;
$sqlWall = mysql_query("SELECT * FROM `wall` WHERE `group_id`='$id' AND `razdel`='group_wall' ORDER BY `date` DESC LIMIT $start, $onpage ");
if ($c_p > 0) {
while ($wallArray = mysql_fetch_assoc($sqlWall)) {
$wallUser = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$wallArray['write_id']."' "));
echo '<div class="post"><span class="c_date"><small>'.ptime($wallArray['date']).'</small></span>
<table cellpadding="3" cellspacing="0"><tbody><tr><td>';
echo avatar($wallArray['write_id']);
echo '</td><td>';
echo '<a href="../user/user.php?name='.$wallUser['login'].'">'.userName($wallArray['write_id']).'</a><br/>';
echo position($wallArray['write_id']);
//echo '<small>'.$wallUser['status'].'</small>';
echo '</td></tr></tbody></table><hr/>'.output($wallArray['text']).'</div>';}
}else{echo '<div class="err" style="text-align:center;">Нет сообщений</div>';}
if ($k_page > 1)str('?id='.$id.'&', $k_page, $page);
} else {
echo '<div class="c"><strong>Описания:</strong> '.$sqlGroup['opis'].'</div>';
echo '<div class="b">Другое</div>
<a class="link" href="users.php?id='.$sqlGroup['id'].'">Участники '.$sqlGroup['count_users'].'</a>
<a class="link" href="#">О группе</a>';
}
foot();
?>