<?
include '../config.php';
include '../func.php';
head();
ban();

/////////////////////////////





$razdel = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_razdel` WHERE `id` = '".num($_GET['razdel'])."'"));
$podforum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_podrazdel` WHERE `id` = '".num($_GET['pod_forum'])."'"));

if ( $id_session )
mysql_query("UPDATE `profile` SET `online` = 'podforum".$podforum['id']."' WHERE `id` = '".$id_session."'");

if ( $_GET['mod'] == 'delete_good' ) echo link1 . 'Тема успешно удалена' . div;
if ( $_GET['mod'] == 'delete_error' ) echo link1 . 'Возникла ошибка' . div;

echo head . "<a href=\"index.php?act=pod_forum&id=".$razdel['id']."\">".$razdel['name']."</a> | <b>".$podforum['name']."</b>" . div;  

if ( empty ( $podforum['id'] ) ) {
    
    echo katalog . 'Данного подфорума не существует' . div;
    pod_navig();
    foot();
    exit();
    
}

$all = mysql_result(mysql_query("SELECT count(*) FROM `forum_themes` WHERE `pod_forum` = '".num($_GET['pod_forum'])."'"), 0);

if ( $all == 0) {
    echo katalog . 'Темы еще не созданы' . div;
    //echo kub . '<img src="style/img/kub.gif" alt="" />' . div;
    echo katalog . '<a href="add_theme.php?razdel='.$razdel['id'].'&pod_forum='.$podforum['id'].'">Создать тему</a>' . div;
    pod_navig();
    foot();
    exit();
    
}

//echo katalog;
if($all){

$a = 10;


$onpage = $a;
$allpage = ceil($all/$onpage);
$this_page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ;
if($this_page < 1 || $this_page > $allpage)$this_page = 1;
$start = $this_page*$onpage - $onpage;

$result = mysql_query("SELECT * FROM forum_themes WHERE `razdel_id` = '".num($_GET['razdel'])."' AND `pod_forum` = '".num($_GET['pod_forum'])."' ORDER BY `fiz` DESC, `time` DESC  limit ".$start.",".$onpage."");
while($themes = mysql_fetch_assoc($result)){
echo '<div class="'.($i++ % 2 ? 'link2' : 'link2').'">';
$all_posts = mysql_result(mysql_query("SELECT count(*) FROM `forum_msg` WHERE `theme` = '$themes[id]'"), 0);

if ( $themes['fiz'] == 0 ) $fix = ''; else $fix = '# ';
echo $fix . "<img src=\"../images/document.png\" alt=\".\"/> <a href=\"theme.php?razdel=".num($_GET['razdel'])."&pod_forum=".num($_GET['pod_forum'])."&theme=".$themes['id']."\">".$themes['name']."</a> [".$all_posts."]</div>"; 


}
echo '<div class="link1"><b>Страницы:</b> ';
navigation($allpage,"themes.php?razdel=".num($_GET['razdel'])."&pod_forum=".num($_GET['pod_forum'])."&p={p}",1,1);
echo div;
}

//echo div . kub . '<img src="../style/img/kub.gif" alt="" />' . div;
echo link2 . '<a href="add_theme.php?razdel='.$razdel['id'].'&pod_forum='.$podforum['id'].'">Создать тему</a>' . div;



pod_navig();
foot();
?>