<?php

require '../system/start.php';
require '../system/functions.php';
switch($act)
{
default:
$str['mesto'] = 'Форум';
$str['block'] = $set['site'].' / Форум';
include '../style/'.$style.'/head.php';
$forum = mysql_result(mysql_query("select count(*) from `users` where `where` = 'Форум' and time > ".(time()-300).""),0);

echo '<div class="where">';
if ($user) 
	echo 'Мои: Темы|<a href="look.php?act=message">Сообщения</a><br/>';
              echo '<a href="index.php?act=search">Поиск</a> / <a href="pravila.php">Правила!</a> / <a href="new.php">Новые</a> <span style="color:#ff0000">+'.mysql_result(mysql_query("select count(*) from `forum_posts` where `time` > ".(time()-86400).""),0).'</span></div>';

$query = mysql_query("select * from `forum_sel`");
if(mysql_num_rows($query) == 0)
{
    echo '<div class="forum1">Форумы еще не созданы!</div>';
}
else
{
    while ($row = mysql_fetch_assoc($query))
    {
        $i++;
        if($i%2)
        {
            echo '<div class="forum1">';
        }
        else
        {
            echo '<div class="forum2">';
        }
        echo '<img class="ico" src="../style/'.$style.'/ico/frazd.png" alt="" /> ';
        if(isset($_GET['id']) && int($_GET['id']) != $row['id'])
        {
            echo '<a href="index.php?id='.$row['id'].'">'.$row['title'].'</a>';
        }
        elseif(isset($_GET['id']) && int($_GET['id']) == $row['id'])
        {
            echo $row['title'];
        }
        elseif(!isset($_GET['id']))
        {
            echo '<a href="index.php?id='.$row['id'].'">'.$row['title'].'</a>';
        }
            if(isset($_GET['id']) && int($_GET['id']) == $row['id'])
            {
                $q = mysql_query("select * from `forum_forums` where `id_sel` = ".int($_GET['id'])."");
                while ($rows = mysql_fetch_assoc($q))
                {
                    $topics = mysql_result(mysql_query("select count(*) from `forum_topics` where `id_forum` = ".$rows['id'].""),0);
                    $posts = mysql_result(mysql_query("select count(*) from `forum_posts` where `id_forum` = ".$rows['id'].""),0);
                    echo '<div class="ftext"><a href="forum.php?id='.$rows['id'].'"><img class="ico" src="../style/'.$style.'/ico/newpost.png" alt="" /> '.$rows['title'].'</a> ('.$topics.'/'.$posts.')</div>';
                }
            }
        echo '</div>';
    }
}
break;
case 'search':
$str['mesto'] = 'Поиск';
$str['block'] = $set['site'].' / <a href="index.php">Форум</a> / Поиск';
include '../style/'.$style.'/head.php';
echo '<div class="mess"><form action="search.php" method="get"><div>Что искать:<br/><input name="query" type="text" value=""><br/>
Искать в:<br/>
<select size="1" name="in">
<option value="1">Темах</option>
<option value="2">Сообщениях</option>
</select><br/>
<input type="submit" value="Искать"></div></form></div>
<div class="on2"><img class="ico" src="../style/default/ico/newpost.png" alt="" /> <a href="index.php">Форум</a></div>';
break;
}
if ($user)
{
echo '<div class="where">
В форуме '.$forum.' человек
</div>'; 
}
echo '<div class="on2">
Модераторы: ';

$r = mysql_query("SELECT * FROM `users` WHERE `level` = '6'");
$num = mysql_num_rows($r);
$i = 1;
while ($e = mysql_fetch_assoc($r)) {
	if ($i < $num)
		echo $e['login'] . ',';
	if ($i == $num)
		echo $e['login'];
	$i++;
}
if ($num == 0)
	echo 'Модераторов нет';
echo '</div>';

include '../style/'.$style.'/foot.php';
?>