File size: 12.73Kb
<?php
include_once "../config.php";
include_once "../inc/inc.php";
include_once "../inc/func.php";
include_once "../inc/user.php";
include_once "../inc/gzip.php";
include_once "../inc/online.php";
include_once "../themes/$theme/index.php";
if (!isset($act)) {
// echo'<img src="/img/pic/24.gif">Форум<hr>';
if ((!isset($thema)) && (!isset($razd))) {
echo'<img src="/img/pic/24.gif"> [Форум]<hr>';
$query = "SELECT * FROM " . $pref . "forum ORDER BY nomer";
$result = mysql_query($query);
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<div class="b">';
echo'<a href="index.php?razd=' . $line['id'] . '">' . $line['name'] . '</a>';
if ($line['pravila'] != '') {
echo ' [<a href="index.php?act=pravila&r=' . $line['id'] . '">правила раздела</a>]<br>';
} else {
echo '<br>';
}
echo '<small>' . $line['opis'] . '</small></div>';
// $soob=smile($line[msg]);
echo '<a href="index.php?thema=' . $line['last_theme_id'] . '">' . $line['last_theme'] . '</a> - <a href="/setting/anketa.php?id=' . $line['last_autor_id'] . '">' . $line['last_autor'] . '</a><br>';
echo '<small>[' . $line['last_time'] . ']</small><br><hr>';
// echo '['.$line['ip'].' - '.$line['brow'].']<br>';
}
} else {
if (isset($razd)) {
$razd = (int)$razd;
if ($razd == 0) {
echo'Произошла ошибка. <a href="index.php">Форум</a>';
include_once "../themes/$theme/foot.php";
exit;
}
// echo'<img src="/img/pic/24.gif"> [<a href="index.php">Форум</a>/]<hr>';
// echo'Выводим список тем'.$razd;
$query = "SELECT id FROM " . $pref . "forum WHERE id=" . $razd;
$res = mysql_query($query);
$res = implode(mysql_fetch_array($res, MYSQL_ASSOC));
if ($res == '') {
echo 'Произошла ошибка. <a href="index.php">Форум</a>';
include_once "../themes/$theme/foot.php";
exit;
}
$query = "SELECT name FROM " . $pref . "forum WHERE id=" . $razd;
$nazva = mysql_fetch_array(mysql_query($query));
echo'<img src="/img/pic/24.gif"> [<a href="index.php">Форум</a>/' . $nazva[0] . ']<br>';
if ($kto == 'user') {
echo'<a href="index.php?act=addthema&razd=' . $razd . '">Создать тему</a>';
}
echo'<hr>';
$vsego = mysql_num_rows(mysql_query("SELECT * FROM " . $pref . "tema WHERE in_razd=" . $razd));
$pagevsego = $vsego / $kolforum_thema;
$pagevsego = (int)$pagevsego;
$bbb = $vsego - ($pagevsego * $kolforum_thema);
if ($bbb > 0) {
$pagevsego++;
}
$page = (int)$page;
if ($page >= $pagevsego) {
$page = $pagevsego;
}
if ((!isset($page)) || ($page <= 0) || ($page == '')) {
$page = 1;
$start = 0;
} else {
$start = ($page * $kolforum_thema) - $kolforum_thema;
}
$query = "SELECT * FROM " . $pref . "tema WHERE in_razd=" . $razd . " ORDER BY data_last_post DESC LIMIT $start, $kolforum_thema";
$result = mysql_query($query);
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<div class="b">Тема: <a href="index.php?thema=' . $line['id'] . '">' . $line['name_tema'] . '</a> [' . $line['all_post'] . ']</div>';
// $soob=smile($line[msg]);
echo 'Автор: <a href="/setting/anketa.php?id=' . $line['first_post_id'] . '">' . $line['first_post'] . '</a> [' . date("h:i / d-m-y", $line['data_first']) . ']<br>';
echo 'Последнее: <a href="/setting/anketa.php?id=' . $line['last_post_id'] . '">' . $line['last_post'] . '</a> [' . date("h:i / d-m-y", $line['data_last']) . ']<br>';
}
echo '<hr>Страницы:<br>';
if ($page == '1') {
echo'<-Назад';
} else {
$ggg = $page-1;
echo '<a href="index.php?page=' . $ggg . '&razd=' . $razd . '"><-Назад</a>';
}
echo ' [' . $page . ' из ' . $pagevsego . '] ';
if (($page == $pagevsego) || ($pagevsego == 0)) {
echo 'Вперёд-><br>';
} else {
$ggg = $page + 1;
echo '<a href="index.php?page=' . $ggg . '&razd=' . $razd . '">Вперёд-></a><br>';
}
echo '<form action="index.php" method="get">';
echo '<input name="razd" type="hidden" value="' . $razd . '">';
echo '<input name="page" type="text" value=""><input type="submit" value=">>">';
echo '</form>';
echo '<hr>Всего тем: ' . $vsego;
} else {
if (isset($thema)) {
$thema = (int)$thema;
if ($thema == 0) {
echo'Произошла ошибка. <a href="index.php">Форум</a>';
include_once "../themes/$theme/foot.php";
exit;
}
// echo'<img src="/img/pic/24.gif"> [<a href="index.php">Форум</a>/]<hr>';
// echo'Выводим посты';
$query = "SELECT id FROM " . $pref . "tema WHERE id=" . $thema;
$res = mysql_query($query);
$res = implode(mysql_fetch_array($res, MYSQL_ASSOC));
if ($res == '') {
echo 'Произошла ошибка. <a href="index.php">Форум</a>';
include_once "../themes/$theme/foot.php";
exit;
}
if ($info == 'postok') {
$page = 100000;
}
$query = "SELECT * FROM " . $pref . "tema WHERE id=" . $thema;
$liner = mysql_fetch_array(mysql_query($query));
$in_razd = $liner['in_razd'];
$query = "SELECT name FROM " . $pref . "forum WHERE id=" . $in_razd;
$nazva = mysql_fetch_array(mysql_query($query));
echo'<img src="/img/pic/24.gif"> [<a href="index.php">Форум</a>/<a href="index.php?razd=' . $in_razd . '">' . $nazva[0] . '</a>/' . $liner['name_tema'] . ']';
if ($info == 'postok') {
echo '<center><font color="red">Сообщение добавлено</font></center>';
}
if ($info == 'themaok') {
echo '<center><font color="red">Тема добавлена</font></center>';
}
echo'<hr>';
$query1 = "SELECT * FROM " . $pref . "tema WHERE id=" . $thema;
$result1 = mysql_fetch_array(mysql_query($query1));
$ids = (int)$result1['tema_nomer'];
$vsego = mysql_num_rows(mysql_query("SELECT * FROM " . $pref . "tema_random_" . $ids));
$pagevsego = $vsego / $kolforum_post;
$pagevsego = (int)$pagevsego;
$bbb = $vsego - ($pagevsego * $kolforum_post);
if ($bbb > 0) {
$pagevsego++;
}
$page = (int)$page;
if ($page >= $pagevsego) {
$page = $pagevsego;
}
if ((!isset($page)) || ($page <= 0) || ($page == '')) {
$page = 1;
$start = 0;
} else {
$start = ($page * $kolforum_post) - $kolforum_post;
}
$query = "SELECT * FROM " . $pref . "tema_random_" . $ids . " LIMIT $start, $kolforum_post";
$result = mysql_query($query);
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<div class="b"><a href="/setting/anketa.php?id=' . $line['id_user'] . '">' . $line['login'] . '</a> [' . $line['datatext'] . ']</div>';
$soob = smile($line[msg]);
echo $soob . '<br>';
echo '[' . $line['ip'] . ' - ' . $line['brow'] . ']<br>';
}
echo '<hr>';
if ($kto == 'guest') {
echo 'Для добавления сообщений вы должны авторизироваться или зарегистрироваться<br>';
}
if ($kto == 'user') {
echo '<form action="addpost.php?thema=' . $thema . '" method="post">';
echo'Сообщение<br>';
echo'<textarea cols="30" rows="5" name="msg" type="text" value=""></textarea><br><br>';
echo'<input type="submit" value="Добавить">';
echo '</form>';
}
echo '<hr>Страницы:<br>';
if ($page == '1') {
echo'<-Назад';
} else {
$ggg = $page-1;
echo '<a href="index.php?page=' . $ggg . '&thema=' . $thema . '"><-Назад</a>';
}
echo ' [' . $page . ' из ' . $pagevsego . '] ';
if (($page == $pagevsego) || ($pagevsego == 0)) {
echo 'Вперёд-><br>';
} else {
$ggg = $page + 1;
echo '<a href="index.php?page=' . $ggg . '&thema=' . $thema . '">Вперёд-></a><br>';
}
echo '<form action="index.php" method="get">';
echo '<input name="thema" type="hidden" value="' . $thema . '">';
echo '<input name="page" type="text" value=""><input type="submit" value=">>">';
echo '</form>';
echo '<hr>Всего сообщений: ' . $vsego;
}
}
}
}
if ($act == 'addthema') {
$razd = (int)$razd;
if ($razd == 0) {
echo'Произошла ошибка. <a href="index.php">Форум</a>';
include_once "../themes/$theme/foot.php";
exit;
}
$query = "SELECT id FROM " . $pref . "forum WHERE id=" . $razd;
$res = mysql_query($query);
$res = implode(mysql_fetch_array($res, MYSQL_ASSOC));
if ($res == '') {
echo 'Произошла ошибка. <a href="index.php">Форум</a>';
include_once "../themes/$theme/foot.php";
exit;
}
if ($kto == 'guest') {
echo'Вы не можете добавлять темы';
include_once "../themes/$theme/foot.php";
exit;
}
$query = "SELECT name FROM " . $pref . "forum WHERE id=" . $razd;
$nazva = mysql_fetch_array(mysql_query($query));
echo'Добавить тему в раздел ' . $nazva[0];
echo '<form name="" action="addthema.php?razd=' . $razd . '" method="post">';
echo'Название темы:<br>';
echo'<input name="name_thema" type="text" value=""><br>';
echo'Сообщение:<br>';
echo'<textarea cols="30" rows="5" name="msg" type="text" value=""></textarea><br><br>';
echo'<input type="submit" value="Добавить">';
echo'</form>';
echo'<hr><a href="index.php?razd=' . $razd . '">Назад</a><br>';
}
if ($act == 'pravila') {
$r = (int)$r;
if ((isset($r)) && ($r != '') && ($r != 0)) {
$query = "SELECT pravila FROM " . $pref . "forum WHERE id=" . $r;
$res = mysql_query($query);
$res = implode(mysql_fetch_array($res, MYSQL_ASSOC));
if ($res == '') {
echo 'Произошла ошибка<br><a href="index.php">Форум</a><br>';
include_once "../themes/$theme/foot.php";
exit;
} else {
$query2 = "SELECT name FROM " . $pref . "forum WHERE id=" . $r;
$res2 = mysql_query($query2);
$res2 = implode(mysql_fetch_array($res2, MYSQL_ASSOC));
echo 'Правила форума для раздела <font color="red">' . $res2 . '</font><br>';
echo $res . '<br><a href="index.php">Форум</a><br>';
}
} else {
echo 'Произошла ошибка<br><a href="index.php">Форум</a><br>';
include_once "../themes/$theme/foot.php";
exit;
}
}
include_once "../themes/$theme/foot.php";
?>