Файл: forum/index.php
Строк: 340
<?
include_once '../sys/includes/start.php';
include_once '../sys/includes/compress.php';
include_once '../sys/includes/sess.php';
include_once '../sys/includes/home.php';
include_once '../sys/includes/settings.php';
include_once '../sys/includes/db_connect.php';
include_once '../sys/includes/ipua.php';
include_once '../sys/includes/fnc.php';
include_once '../sys/includes/user.php';
if (isset($_GET['id_forum']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_f` WHERE".((!isset($user) || $user['level']==0)?" `adm` = '0' AND":null)." `id` = '".intval($_GET['id_forum'])."'"),0)==1 && isset($_GET['id_razdel']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_r` WHERE `id` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."'"),0)==1 && isset($_GET['id_them']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `id` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."'"),0)==1 && isset($_GET['id_post']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id` = '".intval($_GET['id_post'])."' AND `id_them` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."'"),0)==1)
{
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_f` WHERE `id` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$razdel=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_r` WHERE `id` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$them=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_t` WHERE `id` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$post=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id` = '".intval($_GET['id_post'])."' AND `id_them` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$post2=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' ORDER BY `id` DESC LIMIT 1"));
if (isset($user))
{
$ank=get_user($post['id_user']);
if (isset($_GET['act']) && $_GET['act']=='edit' && isset($_POST['msg']) && isset($_POST['post']) && ((user_access('forum_post_ed')) || (isset($user) && $user['id']==$post['id_user'] && $post['time']>time()-600 && $post['id_user']==$post2['id_user'])))
{
$msg=$_POST['msg'];
if (isset($_POST['translit']) && $_POST['translit']==1)
{
$msg=translit($msg);
}
if (strlen2($msg)<2)
{
$err='Короткое сообщение!';
}
if (strlen2($msg)>1024)
{
$err='Длина сообщения превышает предел в 1024 символа!';
}
$mat=antimat($msg);
if ($mat)
{
$err='В тексте сообщения обнаружен мат: '.$mat;
}
if (!isset($err))
{
mysql_query("UPDATE `forum_p` SET `msg` = '".my_esc($msg)."' WHERE `id` = '".$post['id']."' LIMIT 1");
}
}
else if (isset($_GET['act']) && $_GET['act']=='edit' && (user_access('forum_post_ed') && ($ank['level']<$user['level'] || $ank['level']==$user['level'] && $ank['id']==$user['id']) || isset($user) && $post['id']==$post2['id'] && $post['id_user']==$user['id'] && $post['time']>time()-600))
{
$set['title']='Форум - редактирование поста';
include_once '../sys/includes/header.php';
title();
echo "<form method='post' name='message' action='/forum/".$forum['id']."/".$razdel['id']."/".$them['id']."/".$post['id']."/edit'>";
$msg2=output_text($post['msg'],false,true,false,false,false);
if (($user['dop']==1) && is_file(H.'s-klub/js/altername_post_form.php'))
{
include_once H.'s-klub/js/altername_post_form.php';
}else{
echo "<img src='/s-klub/img/post-add.png'> <b>Сообщение:</b><br />";
bb_panel();
echo "<textarea name='msg'>".$msg2."</textarea><br />";
}
if ($user['set_translit']==1)
{
echo "<label><input type='checkbox' name='translit' value='1' /> Транслит</label><br />";
}
echo "<input name='post' value='Изменить' type='submit' /><br />";
echo "</form>";
echo "<div class='foot'>";
echo "<img src='/s-klub/img/del.png'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/delete' title='Удалить пост'>Удалить пост</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=end' title='Вернуться в тему'>В тему</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/$razdel[id]/' title='В раздел'>".$razdel['name']."</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/' title='В подфорум'>$forum[name]</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/'>Форум</a><br />";
echo "</div>";
include_once '../sys/includes/footer.php';
exit;
}
else if (isset($_GET['act']) && $_GET['act']=='delete' && isset($user) && $them['close']==0 && ((user_access('forum_post_ed') && ($ank['level']<=$user['level'] || $ank['level']==$user['level'] && $ank['id']==$user['id'])) || $post['id']==$post2['id'] && $post['id_user']==$user['id'] && $post['time']>time()-600))
{
mysql_query("DELETE FROM `forum_p` WHERE `id` = '".intval($_GET['id_post'])."' AND `id_them` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1");
}
elseif (isset($_GET['act']) && $_GET['act']=='msg' && $them['close']==0 && isset($user))
{
$ank=get_user($post['id_user']);
$set['title']='Форум - '.$them['name'];
include_once '../sys/includes/header.php';
title();
auter();
echo "<form method='post' name='message' action='/forum/$forum[id]/$razdel[id]/$them[id]/new?otvet=$ank[id]'>";
echo "<div class='forum_tema'>";
echo "<img src='/s-klub/img/eye-go.png'> <a href='/info.php?id=$ank[id]'>Посмотреть анкету</a><br />";
echo "</div>";
$msg2=$ank['nick'].', ';
if (($user['dop']==1) && is_file(H.'s-klub/js/altername_post_form.php'))
{
include_once H.'s-klub/js/altername_post_form.php';
}else{
echo "<img src='/s-klub/img/post-add.png'> <b>Сообщение:</b><br />";
bb_panel();
echo "<textarea name='msg'>".$ank['nick'].", </textarea><br />";
}
if ($user['set_translit']==1)
{
echo "<label><input type='checkbox' name='translit' value='1' /> Транслит</label><br />";
}
echo "<input name='post' value='Отправить сообщение' type='submit' /><br />";
echo "</form>";
echo "<div class='foot'>";
echo "<img src='/s-klub/img/smiles.png'> <a href='/smiles.php'>Смайлы</a><br />";
echo "<img src='/s-klub/img/rules.png'> <a href='/rules.php'>Правила</a><br />";
echo "</div>";
echo "<div class='foot'>";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=end' title='Вернуться в тему'>В тему</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/$razdel[id]/' title='В раздел'>".$razdel['name']."</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/' title='В подфорум'>$forum[name]</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/'>Форум</a><br />";
echo "</div>n";
include_once '../sys/includes/footer.php';
exit;
}
else if (isset($_GET['act']) && $_GET['act']=='cit' && $them['close']==0 && isset($user))
{
$ank=get_user($post['id_user']);
$set['title']='Форум - '.$them['name'];
include_once '../sys/includes/header.php';
title();
auter();
echo "<div class='forum_tema'>";
echo "<img src='/s-klub/img/cit.png'> Будет процетировано сообщение:<br />";
echo "</div>";
echo "<div class='cit'>";
echo output_text($post['msg'])."<br />";
echo "</div>";
echo "<form method='post' name='message' action='/forum/$forum[id]/$razdel[id]/$them[id]/new?otvet=$ank[id]'>";
echo "<input name='cit' value='".$post['id']."' type='hidden' />";
$msg2=$ank['nick'].', ';
if (($user['dop']==1) && is_file(H.'s-klub/js/altername_post_form.php'))
{
include_once H.'s-klub/js/altername_post_form.php';
}else{
echo "<img src='/s-klub/img/post-add.png'> <b>Сообщение:</b><br />";
bb_panel();
echo "<textarea name='msg'>".$ank['nick'].", </textarea><br />";
}
if ($user['set_translit']==1)
{
echo "<label><input type='checkbox' name='translit' value='1' /> Транслит</label><br />";
}
echo "<input name='post' value='Отправить сообщение' type='submit' /><br />";
echo "</form>";
echo "<div class='foot'>";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=end' title='Вернуться в тему'>В тему</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/$razdel[id]/' title='В раздел'>$razdel[name]</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/' title='В подфорум'>".$forum['name']."</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/'>Форум</a><br />";
echo "</div>";
include_once '../sys/includes/footer.php';
exit;
}
}
}
if (isset($_GET['id_forum']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_f` WHERE".((!isset($user) || $user['level']==0)?" `adm` = '0' AND":null)." `id` = '".intval($_GET['id_forum'])."'"),0)==1 && isset($_GET['id_razdel']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_r` WHERE `id` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."'"),0)==1 && isset($_GET['id_them']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `id` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."'"),0)==1 )
{
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_f` WHERE `id` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$razdel=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_r` WHERE `id` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$them=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_t` WHERE `id` = '".intval($_GET['id_them'])."' AND `id_razdel` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$set['title']='Форум - '.$them['name'];
include_once '../sys/includes/header.php';
title();
$ank2=get_user($them['id_user']);
include 'inc/set_them_act.php';
include 'inc/them.php';
include 'inc/set_them_form.php';
echo "<div class='foot'>";
if (isset($user))
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_zakl` WHERE `id_them` = '$them[id]' AND `id_user` = '$user[id]'"),0)==0)
{
echo "<img src='/s-klub/img/zakl-add.png'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=$page&zakl=1' title='Добавить в закладки'>В закладки</a><br />";
}else{
mysql_query("UPDATE `forum_zakl` SET `time` = '".time()."' WHERE `id_them` = '$them[id]' AND `id_user` = '$user[id]'");
echo "<img src='/s-klub/img/zakl-del.png'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=$page&zakl=0' title='Удалить из закладок'>Удалить из закладок</a><br />";
}
}
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/$razdel[id]/' title='В раздел'>".$razdel['name']."</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/$forum[id]/' title='В подфорум'>".$forum['name']."</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/'>Форум</a><br />";
echo "</div>";
include_once '../sys/includes/footer.php';
exit;
}
if (isset($_GET['id_forum']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_f` WHERE".((!isset($user) || $user['level']==0)?" `adm` = '0' AND":null)." `id` = '".intval($_GET['id_forum'])."'"),0)==1 && isset($_GET['id_razdel']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_r` WHERE `id` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."'"),0)==1)
{
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_f` WHERE `id` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$razdel=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_r` WHERE `id` = '".intval($_GET['id_razdel'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' LIMIT 1"));
if (isset($user) && isset($_GET['act']) && $_GET['act']=='new' && (!isset($_SESSION['time_c_t_forum']) || $_SESSION['time_c_t_forum']<$time-600 || $user['level']>0))
{
include 'inc/new_t.php';
}else{
$set['title']='Форум - '.$razdel['name'];
include_once '../sys/includes/header.php';
title();
if (user_access('forum_razd_edit'))
{
include 'inc/set_razdel_act.php';
}
include 'inc/razdel.php';
if (user_access('forum_razd_edit'))
{
include 'inc/set_razdel_form.php';
}
echo "<div class='foot'>";
if (isset($user) && (!isset($_SESSION['time_c_t_forum']) || $_SESSION['time_c_t_forum']<$time-600 || $user['level']>0))
{
echo "<img src='/s-klub/img/tema-add.png'> <a href=/forum/$forum[id]/$razdel[id]/?act=new title='Создать новую тему'>Новая тема</a><br />";
}
echo "<img src='/s-klub/img/left.png'> <a href=/forum/$forum[id]/>$forum[name]</a><br />";
echo "<img src='/s-klub/img/left.png'> <a href=/forum/>Форум</a><br />";
echo "</div>";
}
include_once '../sys/includes/footer.php';
exit;
}
if (isset($_GET['id_forum']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_f` WHERE".((!isset($user) || $user['level']==0)?" `adm` = '0' AND":null)." `id` = '".intval($_GET['id_forum'])."'"),0)==1)
{
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_f` WHERE `id` = '".intval($_GET['id_forum'])."' LIMIT 1"));
$set['title']='Форум - '.$forum['name'];
include_once '../sys/includes/header.php';
title();
include 'inc/set_forum_act.php';
include 'inc/forum.php';
include 'inc/set_forum_form.php';
echo "<div class='foot'>";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/'>Форум</a><br />";
echo "</div>";
include_once '../sys/includes/footer.php';
exit;
}
$set['title']='Форум';
include_once '../sys/includes/header.php';
title();
if (user_access('forum_for_create') && isset($_GET['act']) && isset($_GET['ok']) && $_GET['act']=='new' && isset($_POST['name']) && isset($_POST['opis']) && isset($_POST['pos']))
{
$name=esc(stripcslashes(htmlspecialchars($_POST['name'])));
if (isset($_POST['translit1']) && $_POST['translit1']==1)
{
$name=translit($name);
}
if (strlen2($name)<3)
{
$err='Слишком короткое название!';
}
if (strlen2($name)>32)
{
$err='Слишком днинное название!';
}
$name=my_esc($name);
if (!preg_match("#^([A-zА-я0-9-_() ])+$#ui",$name))
{
$err='В названии форума присутствуют запрещенные символы!';
}
$opis=$_POST['opis'];
if (isset($_POST['translit2']) && $_POST['translit2']==1)
{
$opis=translit($opis);
}
if (strlen2($opis)>512)
{
$err='Слишком длинное описание!';
}
$opis=my_esc($opis);
$pos=intval($_POST['pos']);
if (!isset($err))
{
admin_log('Форум','Подфорумы',"Создание подфорума '$name'");
mysql_query("INSERT INTO `forum_f` (`opis`, `name`, `pos`) values('$opis', '$name', '$pos')");
msg('Подфорум успешно создан');
}
}
auter();
err();
echo "<div class='forum_tema'>";
echo "<img src='/s-klub/img/top.png'> <a href='/forum/files_list.php'>TOP 20 файлов</a><br />";
echo "<img src='/s-klub/img/rules.png'> <a href='/rules.php'>Правила</a><br />";
echo "<img src='/s-klub/img/who.png'> <a href='/forum/on-forum.php'>Кто в форуме?</a><br />";
echo "<img src='/s-klub/img/search.png'> <a href='/forum/search.php'>Поиск</a><br />";
echo "<img src='/s-klub/img/new.png'> Новые: <a href='/forum/new_t.php'>Темы</a> | <a href='/forum/new_p.php'>Посты</a><br />";
if (isset($user))
{
echo "<img src='/s-klub/img/my_f.png'> Мои: <a href='/forum/my_t.php'>Темы</a> | <a href='/forum/my_p.php'>Посты</a><br />";
}
echo "</div>";
$q=mysql_query("SELECT * FROM `forum_f`".((!isset($user) || $user['level']==0)?" WHERE `adm` = '0'":null)." ORDER BY `pos` ASC");
if (mysql_num_rows($q)==0)
{
echo "<table style='width:100%' cellspacing='1' cellpadding='1'><tr>";
echo "<td class='err'>";
echo "Нет подфорумов!";
echo "</td>";
echo "</tr></table>";
}
while ($forum=mysql_fetch_assoc($q))
{
echo "<table style='width:100%' cellspacing='1' cellpadding='1'><tr>";
echo "<td class='icon14'>";
echo "<img src='/s-klub/img/forum.png' alt='' />";
echo "</td>";
echo "<td class='p_t'>";
echo "<a href='/forum/".$forum['id']."/'>".$forum['name']." (".mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` = '".$forum['id']."'"),0).'/'.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `id_forum` = '".$forum['id']."'"),0).")</a>";
echo "</td>";
echo "</tr>";
if ($forum['opis']!=NULL)
{
echo "<tr>";
echo "<td class='p_m' colspan='2'>";
echo "<img src='/s-klub/img/opis.png'> ".output_text($forum['opis'])."<br />";
echo "</td>";
echo "</tr>";
}
echo "</table>";
}
if (user_access('forum_for_create') && (isset($_GET['act']) && $_GET['act']=='new' || mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_f`"),0)==0))
{
echo "<form method='post' action='/forum/index.php?act=new&ok'>";
echo "Название подфорума:<br />";
echo "<input name='name' type='text' maxlength='32' value='' /><br />";
if ($user['set_translit']==1)
{
echo "<label><input type='checkbox' name='translit1' value='1' /> Транслит</label><br />";
}
echo "Описание:<br />";
echo "<textarea name='opis'></textarea><br />";
if ($user['set_translit']==1)
{
echo "<label><input type='checkbox' name='translit2' value='1' /> Транслит</label><br />";
}
echo "Позиция:<br />";
$pos=mysql_result(mysql_query("SELECT MAX(`pos`) FROM `forum_f`"), 0)+1;
echo "<input name='pos' type='text' maxlength='3' value='".$pos."' /><br />";
echo "<input value='Создать' type='submit' /><br />";
echo "<img src='/s-klub/img/left.png'> <a href='/forum/'>Отмена</a><br />";
echo "</form>";
}
if (user_access('forum_for_create') && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_f`"),0)>0)
{
echo "<a href='/forum/?act=new'><div class="foot">";
echo "<img src='/s-klub/img/tema-add.png'> Новый подфорум<br />";
echo "</div></a>";
}
include_once '../sys/includes/footer.php';
?>