Размер файла: 3.88Kb
<?php
// by mides, icq: 529-899-6, mail: [email protected]
$title = 'Форум';
require("../config.php");
require("../includes/start.php");
require("../includes/functions.php");
tp('Форум');
switch($_GET['act']){
###############################################################################
## Главная страница, список разделов ##
###############################################################################
default:
echo '<div class="s1">Разделы</div><div class="s2">';
$result = mysql_query("SELECT * FROM `forum_cats` WHERE `id_cat` = 0");
while($row = mysql_fetch_assoc($result)){
$topics = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topics` WHERE `id_cat` = ".$row['id'].""), 0);
$msg = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_msg` WHERE `id_cat` = ".$row['id'].""), 0);
echo '<a href="index.php?act=cat_view&id='.$row['id'].'">'.$row['name'].'</a> ('.$topics.'/'.$msg.')<br/>';
}
echo '</div>';
nav();
break;
###############################################################################
## Просмотр раздела ##
###############################################################################
case 'cat_view':
$id = intval($_REQUEST['id']);
$row = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_cats` WHERE `id` = '$id'"));
if(isset($row['id'])){
echo '<div class="s1">'.$row['name'].'</div><div class="s2">';
$count_subcats = mysql_result(mysql_query("SELECT * FROM `forum_cats` WHERE `id_cat` = '$id'"), 0);
if($count_subcats > 0){
$result_subcats = mysql_query("SELECT * FROM `forum_cats` WHERE `id_cat` = '$id'");
while($subcat = mysql_fetch_assoc($result_subcats)){
$topics = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topics` WHERE `id_cat` = ".$subcat['id'].""), 0);
$msg = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_msg` WHERE `id_cat` = ".$subcat['id'].""), 0);
echo '<a href="?act=cat_view&id='.$subcat['id'].'">'.$subcat['name'].'</a> ('.$topics.'/'.$msg.')<br/>';
}
echo '</div>';
nav2('./', 'форум');
}else{
$count_topics = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topics` WHERE `id_cat` = '$id'"), 0);
if($count_topics > 0){
$pages = ceil($count/$config['onpage']);
if(isset($_REQUEST['page'])){
$page = abs(intval($_REQUEST['page']));
}else{
$page = 1;
}
$from = ($page-1)*$config['onpage'];
$result_topics = mysql_query("SELECT * FROM `forum_topics` WHERE `id_cat` = '$id' ORDER BY `time` DESC LIMIT $from, ".$config['onpage']."");
while($topic = mysql_fetch_assoc($result_topics)){
$msg = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_msg` WHERE `id_topic` = '".$topic['id']."'"), 0);
$last_page = floor(mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_msg` WHERE `id_topic` = '".$topic['id']."'"), 0)/$config['onpage']);
echo '<a href="topic.php?id='.$topic['id'].'">'.$topic['title'].'</a>['.$msg.'] '.$topic['last_user'].'<a href="topic.php?id='.$topic['id'].'&page='.$last_page.'">»</a><br/>';
}
}else{
echo 'В этом разделе пока нет сообщений<br/>Щёлкните <b>Новая тема</b>, и ваше сообщение станет первым<br/>';
}
echo '<br/><a href="posting.php?act=topic_add&id='.$id.'" class="button">Новая тема</a></div>';
echo '<div class="s1">Навигация</div><div class="s2">';
navig($page, 'index.php?act=cat_view&id='.$id.'&', $pages);
echo '<a href="./">форум</a><br/><a href="../">на главную</a></div>';
}
}else{
error('Такого раздела не существует!');
nav2('./', 'форум');
}
break;
}
require("../includes/tail.php");
?>