View file forum/forum.php

File size: 2.13Kb
<?php
	$str = $_GET["str"];

include ("../head.php");
include ("../tools.php");
 echo "<div class='contur_rek'>
<div class='header_rek'><div style='text-align:center'><big><b>Разделы</b></big></div></div></div>";
	$forum=hacker($_GET["forum"]);
	$forum=htmlspecialchars(stripslashes(trim($forum)));
    $user=hacker(htmlspecialchars(stripslashes(trim($user))));
    $tema=hacker($_GET["tema"]);
    $tema=htmlspecialchars(stripslashes(trim($tema)));


  $news = mysql_query("select * from `forum` where type='forum' and idforum='".$forum."';");
  $massivnews = mysql_fetch_array($news);
  $nme = mysql_num_rows($news);
    if ($nme!=1){
    $forum="0";
    $tema="0";    }
    else
    {

if (!empty($_SESSION['login']))
{echo "<div class='header'><a href='newtem.php?forum=".$forum."'>&#9679; Новая тема</a></div>
";}

$q = mysql_query("select * from `forum` where type='tema' and idforum='".$forum."' and zavis='0' order by time desc;");
      $page=hacker($_GET['page']);
      if ($page<=0)
      {$page=1;}
$count = mysql_num_rows($q);
while($arr = mysql_fetch_array($q))
 {
	if ($i<=$page*$kmess & $i>=($page-1)*$kmess)
	{
	$count1 = mysql_query("select * from `forum` where `type`='mess' and `idforum`='".$forum."' and `idtema`='".$arr['idtema']."';");
	$cnt = mysql_num_rows($count1);
	echo "<div class='contur'><div class='header'><a href='tema.php?forum=".$forum."&amp;tema=".$arr['idtema']."'>&#8594; ".$arr['text']." ($cnt)</a><br/></div>";
	$last=ceil($cnt/10);

	$count1=0;
	if ($last>=2)
	{
	echo"последняя страница:<a href='tema.php?forum=".$forum."&amp;tema=".$arr['idtema']."&amp;page=".$last."'>".$last."</a>";
	}
	$last=1;
	echo"</div>";
	}
	++$i;
}
echo "<div>";
if ($count>10 )
	{
		if ($page<ceil($count/10))
		{
	$next=$page+1;
	print "<a href='?forum=$forum&amp;tema=$tema&amp;page=".$next."'>Далее</a> ";
		}
	}
	$prev=$page-1;
	if ($prev!=0)
	{print "<a href='?forum=$forum&amp;tema=$tema&amp;page=".$prev."'>Назад</a>";}
echo "</div>";


	}
	echo "<div class='header'><a href='./' >&#9679; Разделы</a></div>";
require ("../foot.php");
	?>