<?php
require_once('shapka.php');
require_once('../db.php');
require_once('inline.php');
$time=time();
print $begin;
$cid=intval(@$cid);
$infor=mysql_query("SELECT * from `forummain` WHERE `cid`='$cid'");
if(!mysql_num_rows($infor))
print 'Ошибка!Указан несуществующий раздел<br/>';
else
{
$info=mysql_fetch_array($infor);
print 'Раздел: '.$info['name'].'<br/>';
@$infop=@mysql_query("SELECT * from `user` WHERE `uid`='$_SESSION[uid]'");
@$userinfo=@mysql_fetch_array($infop);
if(@$userinfo['forumst']<3 or $time<$userinfo['forumban'])
print 'Вы не можете создавать темы<br/>';
else
print '<a href="newtema.php?str='.$str.'&cl='.$ses.'&cid='.$info['cid'].'">Новая тема</a><br/>';
print $razd;
$tema=mysql_query("SELECT * from `forumtema`,`user` WHERE `forumtema`.`cid`='$cid' and `user`.`uid`=`forumtema`.`uid` ORDER by `forumtema`.`stat` DESC, `forumtema`.`time` DESC");
$page=intval(@$page);
$start=$page*10;
@mysql_data_seek($tema,$start);
$end=$start+10;
$count=mysql_num_rows($tema);
$kolstr=ceil($count/10);
if($page>1){
print "<a href=\"forum.php?cl=$ses&cid=$cid&str=$str&page=".($page-1)."\">Назад</a><br/>";
print "<a href=\"forum.php?cl=$ses&cid=$cid&str=$str&page=0\">В начало</a><br/>$razd";
}
elseif($page>0)
print "<a href=\"forum.php?cl=$ses&cid=$cid&str=$str&page=".($page-1)."\">Назад</a><br/>$razd";
while($t=mysql_fetch_array($tema))
{$t['nazv']=htmlspecialchars($t['nazv']);
$date=date("H:i d.m.Y",$t['time']);
if($t['stat']>4)
print '<b>!</b>';
if(!$t['lock'])
print "<a href=\"tema.php?cl=$ses&sid=$t[sid]&str=$str\">$t[sajt],id=$t[uid] $date [$t[count]]</a><br/>$t[nazv]<br/>";
else
print "<a href=\"tema.php?sid=$t[sid]&cl=$ses&str=$str\">$t[sajt],id=$t[uid] $date [$t[count]]</a><b>x<br/></b>$t[nazv]<br/>";
$start++;
if($end<=$start)
break;
}
}
print $razd;
if($end<$count)
print "<a href=\"forum.php?cl=$ses&cid=$cid&str=$str&page=".($page+1)."\">Далее</a><br/>";
if($kolstr>$page+2)
print "<a href=\"forum.php?cl=$ses&cid=$cid&str=$str&page=".($kolstr-1)."\">В конец</a><br/>";
print '<a href="index.php?str='.$str.'&cl='.$ses.'">Pазделы</a><br/>';
print $razd;
print $gl;
print $endpage;
?>