|
<?php
/*
#Бесплатный WAP движок StrongCMS
#Официальный сайт поддержки: http://strongcms.ru
*/
######### Вывод темы #########
$forum_t = $db->super_query("SELECT * FROM `forum_tema` WHERE `id` = '".$id."'");
$forum_r = $db->super_query("SELECT * FROM `forum_razdel` WHERE `id` = '".$forum_t['razdel']."'");
$forum_k = $db->super_query("SELECT * FROM `forum_kat` WHERE `id` = '".$forum_t['kat']."'");
#заголовок>шапка
$title = $forum_t['name'];
require ('../system/head.php');
$forum_zaklad = $db->super_query("SELECT * FROM `forum_zaklad` WHERE `tema` = '".$id."' and `us` = '".$user['id']."' ");
if (!$forum_t)
err($title, 'Такой темы не существует!');
echo '<div class="title"><a href="'.HOME.'/forum/">Форум</a> | <a href="'.HOME.'/forum/razdel'.$forum_r['id'].'">'.$forum_r['name'].'</a> | <a href="'.HOME.'/forum/kat'.$forum_k['id'].'">'.$forum_k['name'].'</a> | '.$forum_t['name'].'</div>';
if (isset($_REQUEST['submit']))
{
$text = strong($_POST['msg']);
if (empty($text))
err('Введите текст сообщения!');
if (mb_strlen($text, 'UTF-8') < 3)
err('Минимум для ввода 3 символа!');
$post_spam = $db->fetch_array($db->query('select * from `forum_post` where `us` = "'.$user['id'].'" and `tema` = "'.$id.'" and `text` = "'.$text.'"'));
if ($post_spam)
err('Вы такой пост уже писали в этой теме!');
$time = $db->query("SELECT * FROM `forum_post` WHERE `us` = '".$user['id']."' ORDER BY `time` DESC");
while ($t = $db->fetch_assoc($time))
{
$forum_antispam = $db->super_query("SELECT * FROM `antispam` WHERE `forum_post` ");
$timeout = $t['time'];
if ((TIME - $timeout) < $forum_antispam['forum_post'])
err('Пишите не чаще чем раз в '.$forum_antispam['forum_post'].' секунд!');
}
$db->query("UPDATE `forum_tema` SET `up` = '".TIME."' WHERE `id` = '".$id."'");
$db->query("INSERT INTO `forum_post` SET `kat` = '".$forum_k['id']."',`text` = '".$text."',`us` = '".$user['id']."',`time` = '".TIME."',`tema` = '".$id."',`razdel` = '".$forum_r['id']."'");
##добавляем юзеру стронгов и рейтинг
$db->query("UPDATE `users` SET `money` = '".($user['money'] + $settings['forum_tem_m'])."', `rating` = '".($user['rating'] + 0.01)."' WHERE `id` = '".$user['id']."' LIMIT 1");
##оповещание
if ($user['id'] != $forum_t['us'] and $forum_t['notice'] == 1)
{
$db->query("INSERT INTO `lenta` SET `readlen` = '0', `time` = '".TIME."', `komy` = '".$forum_t['us']."', `kto` = '".$user['id']."', `text` = 'написал в вашей [url=".HOME."/forum/tema".$id."?selection=top]теме[/url]'");
}
header('Location: /forum/tema'.$id.'?selection=top');
exit;
}
if ($user['id'])
{
$viz = $db->super_query("SELECT COUNT(id) as count FROM `forum_visited` WHERE `tema` = '".$id."' AND `user_id` = '".$user['id']."'");
if (!$viz['count'])
{
$db->query("INSERT INTO `forum_visited` SET
`tema` = '".$id."',
`user_id` = '".$user['id']."',
`time` = '".TIME."'");
} else
{
$db->query("UPDATE `forum_visited` SET
`time`='".time()."' WHERE `user_id` = '".$user['id']."' AND `tema` = '".$id."' LIMIT 1");
}
}
$count = $db->super_query("SELECT COUNT(*) as count FROM `forum_post` WHERE `tema` = '".$id."' and `kat` = '".$forum_t['kat']."' and `razdel` = '".$forum_t['razdel']."'");
$start = nav($count['count']);
$k_post = $start['s'] + 1;
$post = $db->query("SELECT * FROM `forum_post` WHERE `tema`='".$id."' ORDER BY `id` LIMIT ".$start['s'].",".$max);
if ($user['id'])
{
echo '<div class="news">';
if ($user['id'] == $forum_t['us'] or $user['level'] >= 1)
echo '<a href="/forum/red_tem'.$id.'">Изменить</a> |';
if ($forum_zaklad == 0)
echo ' <a href="/forum/zaklad'.$id.'">В закладки</a>';
else
echo ' <a href="/forum/zaklad'.$id.'">Удалить из закладок</a>';
if ($forum_t['status'] == 0 or $forum_t['status'] == 2)
{
if ($user['level'] >= 1)
echo ' | <a href="/forum/tema_close'.$id.'">Закрыть</a>';
} elseif ($forum_t['status'] == 1)
{
if ($user['level'] >= 1)
echo ' | <a href="/forum/tema_close'.$id.'">Открыть</a>';
}
if ($user['level'] >= 1)
echo ' | <a href="/forum/index.php?act=move&id='.$id.'">Переместить</a>';
if ($forum_t['status'] != 2)
{
if ($user['level'] >= 2)
echo ' | <a href="/forum/tema_top'.$id.'">Закрепить</a>';
} else
{
if ($user['level'] >= 2)
echo ' | <a href="/forum/tema_top'.$id.'">Открепить</a>';
}
if ($user['level'] >= 2)
echo ' | <a href="/forum/tema_del'.$id.'">Удалить</a>';
echo '</div>';
}
if ($forum_t['status'] == 1)
{
echo '<div class="podmenu">Тема закрыта для обсуждения!</div>';
}
while ($a = $db->fetch_assoc($post))
{
echo '<div class="podmenu"><span class="counts3"><b>'.$k_post++.'</b></span> '.nick($a['us']).' ['.vremja($a['time']).'] ';
if ($user['id'])
{
/*** Действия ***/
if ($user['level'] >= 2)
echo '<span class="counts3"><b><a href="/forum/post_del'.$a['id'].'">уд</a></b></span>';
if ($user['id'] == $a['us'] or $user['level'] >= 1)
echo '<span class="counts3"><b><a href="/forum/post_red'.$a['id'].'">ред</a></b></span>';
if ($user['id'] != $a['us'])
echo '<span class="counts3"><b><a href="/forum/post_otvet'.$a['id'].'">отв</a></b></span>';
if ($user['id'] != $a['us'])
echo '<span class="counts3"><b><a href="/forum/post_citata'.$a['id'].'">цит</a></b></span>';
/*** Действия ***/
}
echo '
';
if (!$a['citata'] == NULL)
echo 'Цитата:
<div class="cit">'.nick($a['citata_us']).': '.nl2br(smile(bb($a['citata']))).'</div>';
echo ''.nl2br(smile(bb($a['text']))).'</div>';
$count = $db->super_query("SELECT COUNT(id) as count FROM `forum_file` WHERE `post_id` = '".$a['id']."'");
if ($count['count'])
{
$load_s = $db->query("SELECT * FROM `forum_file` WHERE `post_id`='".$a['id']."'");
echo '<div class="podmenu"><b>Прикрепленные файлы:</b>
';
while ($a = $db->fetch_array($load_s))
{
echo '<a href="../files/forum/'.$a['name_file'].'">'.$a['name_file'].'</a> ['.fsize('../files/forum/'.$a['name_file']).']
';
}
echo '</div>';
}
}
if ($user['id'])
{
if ($forum_t['status'] != 1)
{
echo '<div class="podmenu"><form action="" name="message" method="POST"> ';
##Панель BB кодов
bbpanel();
echo '<textarea name="msg" placeholder="Введите сообщение..."></textarea>
<input type="submit" name="submit" value="Написать" />
</form></div>';
}
}
$gde = $forum_t['name'].' , /forum/tema'.$id.'';
$kto = $db->super_query('SELECT COUNT(id) as count FROM `users` WHERE `gde` LIKE "%'.$gde.'%" AND `viz` > "'.(TIME - 60).'"');
$visited = $db->super_query("SELECT COUNT(*) as count FROM `forum_visited` WHERE `tema` = '".$id."'");
echo '<div class="news">
<a href="'.HOME.'/forum/rules.php"><b>Правила</b></a> | <a href="'.HOME.'/smile/">Смайлы</a> |
<a href="'.HOME.'/forum/bb.php">BB</a> |
<a href="'.HOME.'/forum/tema'.$id.'/who">В теме</a> ('.$kto['count'].') | <a href="'.HOME.'/forum/visited'.$id.'">Посетили</a> ('.$visited['count'].')
</div>';
if ($start['k_page'] > 1)
echo str(HOME.'/forum/tema'.$id.'?', $start['k_page'], $start['page']); // Вывод страниц
?>