Файл: world-faces.ru/world-faces.ru/forum/index.php
Строк: 421
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/dbPDO.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
only_reg();
/* function ai -> abs(intval( for number filtre) */
function ai($number){
$number = abs((int)$number);
return $number;
}
if (!isset($user) || $user['level']==0)$no_adm=" `adm` = '0' AND";else $no_adm=NULL;
$new = DB::$dbs->querySingle("select count(id) from `forum_t` LEFT JOIN `forum_rdm` ON `forum_t`.`id` = `forum_rdm`.`t_id` AND `forum_rdm`.`user_id` =? WHERE (`forum_rdm`.`t_id` Is Null OR `forum_t`.`time` > `forum_rdm`.`time`)",array($user['id']));
if (isset($_GET['id_forum']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_f` WHERE$no_adm `id` =?",array(ai($_GET['id_forum'])))==1
&& isset($_GET['id_razdel']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_r` WHERE `id` =? AND `id_forum` =?",array(ai($_GET['id_razdel']),ai($_GET['id_forum'])))==1
&& isset($_GET['id_them']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_t` WHERE `id` =? AND `id_razdel` =? AND `id_forum` =?",array(ai($_GET['id_them']),ai($_GET['id_razdel']),ai($_GET['id_forum'])))==1
&& isset($_GET['id_post']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_p` WHERE `id` =? AND `id_them` =? AND `id_razdel` =? AND `id_forum` =?",array(ai($_GET['id_post']),ai($_GET['id_them']),ai($_GET['id_razdel']),ai($_GET['id_forum'])))==1
)
{
$forum = DB::$dbs->queryFetch("SELECT * FROM `forum_f` WHERE `id` =? LIMIT 1",array(ai($_GET['id_forum'])));
$razdel = DB::$dbs->queryFetch("SELECT * FROM `forum_r` WHERE `id` =? AND `id_forum` =? LIMIT 1",array(ai($_GET['id_razdel']),ai($_GET['id_forum'])));
$them = DB::$dbs->queryFetch("SELECT * FROM `forum_t` WHERE `id` =? AND `id_razdel` =? AND `id_forum` =? LIMIT 1",array(ai($_GET['id_them']),ai($_GET['id_razdel']),ai($_GET['id_forum'])));
$post = DB::$dbs->queryFetch("SELECT * FROM `forum_p` WHERE `id` =? AND `id_them` =? AND `id_razdel` =? AND `id_forum` =? LIMIT 1",array(ai($_GET['id_post']),ai($_GET['id_them']),ai($_GET['id_razdel']),ai($_GET['id_forum'])));
$post2 = DB::$dbs->queryFetch("SELECT * FROM `forum_p` WHERE `id_them` =? AND `id_razdel` =? AND `id_forum` =? ORDER BY `id` DESC LIMIT 1",array(ai($_GET['id_them']),ai($_GET['id_razdel']),ai($_GET['id_forum'])));
if (isset($user)){
$ank=DB::$dbs->queryFetch("SELECT * FROM `user` WHERE `id` =? LIMIT 1",array($post['id_user']));
if (isset($_GET['act']) && $_GET['act']=='edit' && isset($_POST['msg']) && isset($_POST['post']) && (isset($user) && ($user['level']>$ank['level'] || $user['level']==4 || ($ank['id']==$user['id'] || $user['level']>0)) || $post['id']==$post2['id'] && $post['id_user']==$user['id'] && $post['time']>time()-600)){
$msg=chck($_POST['msg']);
if (isset($_POST['translit']) && $_POST['translit']==1)$msg=translit($msg);
if (strlen2($msg)<2)$err='Короткое сообщение';
if (strlen2($msg)>1024)$err='Длина сообщения превышает предел в 1024 символа';
if (!isset($err)) DB::$dbs->query("UPDATE `forum_p` SET `msg` =? WHERE `id` =? LIMIT 1",array($msg,ai($post['id'])));
}
elseif (isset($_GET['act']) && $_GET['act']=='edit' && (isset($user) && ($user['level']>$ank['level'] || $user['level']==4 || ($ank['id']==$user['id'] && $user['level']>0)) || $post['id']==$post2['id'] && $post['id_user']==$user['id'] && $post['time']>time()-600)){
$set['title']='Форум - редактирование поста'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
echo "<form method='post' action='/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/edit'>n";
echo "Сообщение:<br />n<textarea name="msg">".esc(trim(stripcslashes(htmlspecialchars($post['msg']))))."</textarea><br />n";
if ($user['set_translit']==1)echo "<label><input type="checkbox" name="translit" value="1" /> Транслит</label><br />n";
echo "<input name='post' value='Изменить' type='submit' /><br />n";
echo "</form>n";
echo "»<a href="/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/delete" title='Удалить пост'>Удалить пост</a><br />n";
echo "<div class="menu">n";
echo "<a href="/forum/$forum[id]/$razdel[id]/$them[id]/?page=end" title='Вернуться в тему'>В тему</a><br />n";
echo "<a href="/forum/$forum[id]/$razdel[id]/" title='В раздел'>$razdel[name]</a><br />n";
echo "<a href="/forum/$forum[id]/" title='В подфорум'>$forum[name]</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
}
elseif (isset($_GET['act']) && $_GET['act']=='delete' && isset($user) && $them['close']==0 && ($user['level']>0 || $post['id']==$post2['id'] && $post['id_user']==$user['id'] && $post['time']>time()-600)){
DB::$dbs->query("DELETE FROM `forum_p` WHERE
`id` = ? AND
`id_them` = ? AND
`id_razdel` = ? AND
`id_forum` = ? LIMIT 1",array(ai($_GET['id_post']),ai($_GET['id_them']),ai($_GET['id_razdel']),ai($_GET['id_forum'])));
}
elseif (isset($_GET['act']) && $_GET['act']=='msg' && $them['close']==0 && isset($access['for_p_cr'])){
$ank=DB::$dbs->queryFetch("SELECT * FROM `user` WHERE `id` =? LIMIT 1",array(ai($post['id_user'])));
$set['title']='Форум - '.$them['name']; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut();
echo "<form method='post' name='message' action='/forum/$forum[id]/$razdel[id]/$them[id]/new'>n";
echo "<a href='/info.php?id=$ank[id]'>Посмотреть анкету</a><br />n";
$msg2=$ank['nick'].', ';
if ($set['web'] && is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php'))
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';
else
echo "Сообщение:<a href="/smiles.php">Смайлы</a><br />n<textarea name="msg">$ank[nick], </textarea><br />n";
if ($user['set_translit']==1)echo "<label><input type="checkbox" name="translit" value="1" /> Транслит</label><br />n";
echo "<input name='post' value='Отправить сообщение' type='submit' /><br />n";
echo "</form>n";
echo "<div class="menu">n";
echo "</div>n";
echo "<div class="menu">n";
echo "<a href="/forum/$forum[id]/$razdel[id]/$them[id]/?page=end" title='Вернуться в тему'>В тему</a><br />n";
echo "<a href="/forum/$forum[id]/$razdel[id]/" title='В раздел'>$razdel[name]</a><br />n";
echo "<a href="/forum/$forum[id]/" title='В подфорум'>$forum[name]</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
}
elseif (isset($_GET['act']) && $_GET['act']=='cit' && $them['close']==0 && isset($access['for_p_cr'])){
$ank=DB::$dbs->queryFetch("SELECT * FROM `user` WHERE `id` =? LIMIT 1",array(ai($post['id_user'])));
$set['title']='Форум - '.$them['name']; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut();
echo "Будет процетировано сообщение:<br />n";
echo "<div class='cit'>n";
echo esc(trim(br(bbcode(links(stripcslashes(htmlspecialchars($post['msg'])))))))."<br />n";
echo "</div>n";
echo "<form method='post' name='message' action='/forum/$forum[id]/$razdel[id]/$them[id]/new'>n";
echo "<input name='cit' value='$post[id]' type='hidden' />";
$msg2=$ank['nick'].', ';
if ($set['web'] && is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php'))
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';
else
echo "Сообщение:<br />n<textarea name="msg">$ank[nick], </textarea><br />n";
if ($user['set_translit']==1)echo "<label><input type="checkbox" name="translit" value="1" /> Транслит</label><br />n";
echo "<input name='post' value='Отправить сообщение' type='submit' /><br />n";
echo "</form>n";
echo "<div class="menu">n";
echo "<a href="/forum/$forum[id]/$razdel[id]/$them[id]/?page=end" title='Вернуться в тему'>В тему</a><br />n";
echo "<a href="/forum/$forum[id]/$razdel[id]/" title='В раздел'>$razdel[name]</a><br />n";
echo "<a href="/forum/$forum[id]/" title='В подфорум'>$forum[name]</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
}
}
}
if (isset($_GET['id_forum']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_f` WHERE$no_adm `id` =?",array(ai($_GET['id_forum'])))==1
&& isset($_GET['id_razdel']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_r` WHERE
`id` =? AND
`id_forum` =?",array(ai($_GET['id_razdel']),ai($_GET['id_forum'])))==1
&& isset($_GET['id_them']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_t` WHERE
`id` = ? AND
`id_razdel` = ? AND
`id_forum` = ?",array(ai($_GET['id_them']),ai($_GET['id_razdel']),ai($_GET['id_forum'])))==1 )
{
$forum =DB::$dbs->queryFetch("SELECT * FROM `forum_f` WHERE `id` =? LIMIT 1",array(ai($_GET['id_forum'])));
$razdel=DB::$dbs->queryFetch("SELECT * FROM `forum_r` WHERE
`id` = ? AND
`id_forum` = ? LIMIT 1",array(ai($_GET['id_razdel']),ai($_GET['id_forum'])));
$them=DB::$dbs->queryFetch("SELECT * FROM `forum_t` WHERE
`id` = ? AND
`id_razdel` = ? AND
`id_forum` = ? LIMIT 1",array(ai($_GET['id_them']),ai($_GET['id_razdel']),ai($_GET['id_forum'])));
$set['title']='Форум - '.$them['name']; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
$ank2=DB::$dbs->queryFetch("SELECT * FROM `user` WHERE `id` =? LIMIT 1",array(ai($them['id_user'])));
if (isset($user) && ($ank2['level']<$user['level'] || $user['level']==4 || $ank2['id']==$user['id']))include 'inc/set_them_act.php';
include 'inc/them.php';
if (isset($user) && ($ank2['level']<$user['level'] || $user['level']==4 || $ank2['id']==$user['id']))include 'inc/set_them_form.php';
echo "<div class="gend">n";
if (isset($user))
{
if (DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_zakl` WHERE `id_them` =? AND `id_user` =?",array(ai($them['id']),ai($user['id'])))==0)
echo "»<a href="/forum/$forum[id]/$razdel[id]/$them[id]/?page=$page&zakl=1" title='Добавить в закладки'>В закладки</a><br />n";
else
{
DB::$dbs->query("UPDATE `forum_zakl` SET `time` =? WHERE `id_them` =? AND `id_user` =?",array(time(),ai($them['id']),ai($user['id'])));
echo "<a href="/forum/$forum[id]/$razdel[id]/$them[id]/?page=$page&zakl=0" title='Удалить из закладок'>Удалить из закладок</a><br />n";
}
}
echo "<a href="/forum/$forum[id]/$razdel[id]/" title='В раздел'>$razdel[name]</a><br />n";
echo "<a href="/forum/$forum[id]/" title='В подфорум'>$forum[name]</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
}
if (isset($_GET['id_forum']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_f` WHERE$no_adm `id` =?",array(ai($_GET['id_forum'])))==1
&& isset($_GET['id_razdel']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_r` WHERE `id` =? AND `id_forum` =?",array(ai($_GET['id_razdel']),ai($_GET['id_forum'])))==1)
{
$forum = DB::$dbs->queryFetch("SELECT * FROM `forum_f` WHERE `id` =? LIMIT 1",array(ai($_GET['id_forum'])));
$razdel= DB::$dbs->queryFetch("SELECT * FROM `forum_r` WHERE `id` =? AND `id_forum` =? LIMIT 1",array(ai($_GET['id_razdel']),ai($_GET['id_forum'])));
if (isset($user) && isset($access['for_t_cr']) && 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/inc/thead.php';
title();
if (isset($user) && $user['level']>2)include 'inc/set_razdel_act.php';
include 'inc/razdel.php';
if (isset($user) && $user['level']>2)include 'inc/set_razdel_form.php';
echo "<div class="menu">n";
if (isset($access['for_t_cr']) && (!isset($_SESSION['time_c_t_forum']) || $_SESSION['time_c_t_forum']<$time-600 || $user['level']>0))
echo "<a href="/forum/$forum[id]/$razdel[id]/?act=new" title='Создать новую тему'>Новая тема</a><br />n";
echo "<a href="/forum/$forum[id]/">$forum[name]</a><br />n";
echo "</div>n";
}
include_once '../sys/inc/tfoot.php';
}
if (isset($_GET['id_forum']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_f` WHERE$no_adm `id` =?",array(ai($_GET['id_forum'])))==1)
{
$forum=DB::$dbs->queryFetch("SELECT * FROM `forum_f` WHERE `id` =? LIMIT 1",array(ai($_GET['id_forum'])));
$set['title']='Форум - '.$forum['name']; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
if (isset($user) && $user['level']>2)include 'inc/set_forum_act.php';
include 'inc/forum.php';
if (isset($user) && $user['level']>2)include 'inc/set_forum_form.php';
include_once '../sys/inc/tfoot.php';
}
$set['title']='Форум'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
if (isset($user) && $user['level']==4 && isset($access['for_f_cr']) && isset($_GET['act']) && isset($_GET['ok']) && $_GET['act']=='new' && isset($_POST['name']) && isset($_POST['opis']) && isset($_POST['pos']))
{
$name=chck($_POST['name']);
if (isset($_POST['translit1']) && $_POST['translit1']==1)$name=translit($name);
//if (ereg("{|}|^|%|\$|#|@|!|~|'|"|`|<|>",$name))$err='В названии форума присутствуют запрещенные символы';
if (strlen2($name)<3)$err='Слишком короткое название';
if (strlen2($name)>32)$err='Слишком днинное название';
$opis=chck($_POST['opis']);
if (isset($_POST['translit2']) && $_POST['translit2']==1)$opis=translit($opis);
//if (strlen2($opis)<10)$err='Короткое описание';
if (strlen2($opis)>512)$err='Слишком длинное описание';
$pos=ai($_POST['pos']);
if (!isset($err)){
DB::$dbs->query("INSERT INTO `forum_f` (`opis`, `name`, `pos`) values(?,?,?)",array($opis,$name,$pos));
msg('Подфорум успешно создан');
}
}
err();
aut(); // форма авторизации
/*if (isset($user) & $user['rating']<=10)
{
if ($user['pol']==0){echo "Извини <b>красавица,</b> n";} else {echo "<b>Извини братан,</b> n";}
echo "но чтобы писать в форуме нужно иметь хотябы <b>10</b> рейтинга<br/>У вас <b>$user[rating]</b> рейтингаn<br />Сейчас вы можете общаться в <a href='/love/'><font color='#FF0000'>Знакомствах</font></a> или в <a href='/chat/'><font color='#FF0000'>Чате</font></a>n";
}
else
{*/
if (isset($user))
{
echo "<style type=text/css>
#thems {color:#BBB;
padding-left:3px;
margin-left:4px;
border-left: 2px solid #BBB;
font-size: 12px;}
#thems a:hover{ color: orange;}
</style>n";
$nn = $new > 0 ? 'Непрочитанное ('.$new.')' : 'Непрочитанное';
echo "<div class="page_foot">n";
echo "<img src='/forum/New.gif' alt=''/>n";
echo "Новые: <a href='/forum/new_p.php'>посты</a>/n";
echo "<a href='/forum/new_t.php'>темы</a><br />n";
echo "<img src='/forum/New.gif' alt=''/>n";
echo "Мои: <a href='/forum/my_p.php'>посты</a>/n";
echo "<a href='/forum/my_t.php'>темы</a><br />n";
echo "<img src='/forum/New.gif' alt=''/>n";
echo "<a href='/forum/new.php'>$nn</a>n";
echo "</div>n";
if (!isset($user) || $user['level']==0)$no_adm=" WHERE `adm` = '0'";else $no_adm=NULL;
if (!isset($user) || $user['level']==0)$no_adm=" WHERE `adm` = '0'";else $no_adm=NULL;
$q=DB::$dbs->query("SELECT * FROM `forum_f`$no_adm ORDER BY `pos` ASC");
if (empty($q)) {
echo "Нет подфорумовn";
}
while ($forum = $q -> fetch())
{
if($num==1){
echo "<div class='adm2'>";
$num=0;
}else{
echo "<div class='adm'>";
$num=1;}
echo "<img src='/style/themes/$set[set_them]/forum/14/forum.png' alt='' /> ";
echo "<a href='/forum/$forum[id]/'>$forum[name]</a> <span class='ank_n'>(".DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_r` WHERE `id_forum` =?",array($forum['id'])).")</span><br />n";
if ($forum['opis']!=NULL && $user['set_forum']==1)echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($forum['opis']))))))))."n";
echo "</div>";
if($user['set_forum']==0){
$qs=DB::$dbs->query("SELECT * FROM `forum_r` WHERE `id_forum` =? ORDER BY `time` ASC",array($forum['id']));
if (empty($qs)) {
echo " Нет разделовn";
}
while ($razd = $qs->fetch())
{
## выводим подфорумы данного форума
echo '<img src="/img/tabor/t4.png" alt="." />';
echo " <a href='/forum/$forum[id]/$razd[id]'>$razd[name] (".DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_t` WHERE `id_forum` =? AND `id_razdel` =?",array($forum['id'],$razd['id'])).'/';
echo DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` =? AND `id_razdel` =?",array($forum['id'],$razd['id'])).")</a><br/>n";
$_SESSION['razdel_id'] = $razd['id'];
}
$them=DB::$dbs->queryFetch("SELECT * FROM `forum_t` WHERE `id_forum` =? ORDER BY `time` DESC LIMIT 1",array($forum['id']));
//$raz = mysql_query("SELECT `id` FROM `forum_r` WHERE `id_forum`='$forum[id]' AND `id_them`='$them[id]' LIMIT `");
//$razdd = mysql_fetch_assoc($raz);
## вывод одной из последних тем ##
if ($them!=NULL){
$post=DB::$dbs->queryFetch("SELECT * FROM `forum_p` WHERE `id_forum` =? ORDER BY `time` DESC LIMIT 1",array($forum['id']));
$ank2=DB::$dbs->queryFetch("SELECT * FROM `user` WHERE `id` =? LIMIT 1",array($post['id_user']));
echo "<div id='thems'>
Тема: <a href='/forum/$forum[id]/$_SESSION[razdel_id]/$them[id]/?page=end' title='Тема "$them[name]"'>$them[name]</a><br/>
Пост: <a href='/info.php?id=$ank2[id]' title='Анкета "$ank2[nick]"'><span style="color:$ank2[ncolor]">$ank2[nick]</span></a> (".vr($post['time']).")</div>n";
}
else
{
echo "Тем пока нет :(n";
}
}
}
echo "<div class='menu'>n";
echo "• <a href='/forum/search.php'>Поиск</a> / <a href='/info/rules_forum.php'>Правила Форума</a>n";
echo "</div>n";
if (isset($user) && $user['level']==4 && isset($access['for_f_cr']) && (isset($_GET['act']) && $_GET['act']=='new' || DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_f`")==0))
{
echo "<form method="post" action="/forum/index.php?act=new&ok">n";
echo "Название подфорума:<br />n";
echo "<input name="name" type="text" maxlength='32' value='' /><br />n";
if ($user['set_translit']==1)echo "<label><input type="checkbox" name="translit1" value="1" /> Транслит</label><br />n";
echo "Описание:<br />n";
echo "<textarea name="opis"></textarea><br />n";
if ($user['set_translit']==1)echo "<label><input type="checkbox" name="translit2" value="1" /> Транслит</label><br />n";
echo "Позиция:<br />n";
$pos=DB::$dbs->querySingle("SELECT MAX(`pos`) FROM `forum_f`")+1;
echo "<input name="pos" type="text" maxlength='3' value='$pos' /><br />n";
echo "<input value="Создать" type="submit" /><br />n";
echo "«<a href="/forum/">Отмена</a><br />n";
echo "</form>n";
}
if (isset($user) && $user['level']==4 && isset($access['for_f_cr']) && DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_f`")>0){
echo "<div class='gend'>n";
echo "<a href="/forum/?act=new"><center>Новый подфорум</a><br /></center>n";
echo "</div>n";
}
}//}
include_once '../sys/inc/tfoot.php';
?>