View file showtopik.php

File size: 3.39Kb
<?php
// MyForum - Сервис форумов 
// Copyright © A'lex и KO. All Rights Reserved
// По всем вопросам обращайтесь на email [email protected] или в асю 376920428

include 'config.php';
include 'functions.php';

if ($moder && $show) {
	$r = mysql_query("SELECT * FROM {$table}{$f}_messages WHERE ForumID=$p AND TopikID=$t");
} else {
	$r = mysql_query("SELECT * FROM {$table}{$f}_messages WHERE ForumID=$p AND TopikID=$t AND Visible=0");
}
$nummes = mysql_numrows($r);
$body="";
$npost=0;
if ($sid == FALSE) {
	$tp = $_SERVER['HTTP_ACCEPT'];
	$user = $_SERVER["HTTP_USER_AGENT"];
	if (strstr($tp,'text/html') || strstr($user, 'Mozilla')) {
		$size = 4800;
	} else {
		$size = 1800;
	}
} else {
	$size = substr($sid, 15, 1);
	if ($size == 1) {$size=1800;}
	if ($size == 2) {$size=4800;}
	if ($size == 3) {$size=9800;}
}
if ($mes == FALSE) {$mes = 0;}
if (($mes > $nummes)) {$mes = $nummes-1;}
if ($mes!=0) {
	for($i=0; $i<$mes-1; $i++) {
		$a=mysql_fetch_array($r);
		$npost++;
	}
}
$nsize=0;
for($i=$mes-1; $i<$nummes; $i++) {
	$add="";
	$a=mysql_fetch_array($r);
	$ID = $a['ID'];
	$Cop = $a['Cop'];
	$Body = $a['Body'];	
	$Date = $a['Date'];
	$Visible = $a['Visible'];
	if ($Visible==1) {$label=' del';} else {$label="";}
	$k = mysql_query("SELECT * FROM {$table}{$f}_users WHERE Nick='$Cop'");
	if ((mysql_numrows($k)!=0) || $moder) {
		if (($Visible=='0') || ($moder && $show && ($Visible!='0'))) {
			$add="$Date   <b><a href=\"usermenu.php?f=$f&p=$p&t=$t&mes=$ID$isid\">$Cop</a></b>$label<br/>" .
			"$Body<br/><br/>\n";
		}
	} else {
		if (($Visible=='0') || ($moder && $show && ($Visible!='0'))) {
			$add="$Date   <b>$Cop</b>$label<br/>" .
			"$Body<br/><br/>\n";
		}
	}
	$nsize+=strlen($add);
	$npost++;
	if (($nsize > $size) && (strlen($body)!=0)) {
		$newpost=$npost;
		break;
	} else {
		$body.=$add;
	}
}
if ($newpost) {$next = "<a href=\"showtopik.php?f=$f&p=$p&t=$t&mes=$newpost$isid\">Далее</a><br/>";}
$r = mysql_query("SELECT * FROM {$table}{$f}_forums WHERE ID=$p");
$a=mysql_fetch_array($r);
$ForumTitle=$a['Title'];
$r = mysql_query("SELECT * FROM {$table}{$f}_topiks WHERE ID=$t");
$a=mysql_fetch_array($r);
$TopikID=$a['ID'];
$TopikTitle=$a['Title'];
$Cop=$a['Cop'];
$Enabled=$a['Enabled'];
$Visible=$a['Visible'];

if (($Visible!=0) && (!$moder)) {displaytext('Ошибка', $Banner, "Не найдено!", "Назад в $ForumTitle");exit;}
$back = "<a href=\"showforum.php?f=$f&p=$p$isid\">Назад в $ForumTitle</a>";
if ($Enabled==0) {
	$menu = "<a href=\"newtopik.php?f=$f&p=$p&t=$TopikID$isid\">Ответить в тему</a><br/>";
	if ($moder || (($Cop==$userinfo['Nick']) && ($sid!=FALSE))) {
		$menu.="<a href=\"moder.php?f=$f&mode=close&p=$p&t=$t$isid\">Закрыть тему</a><br/>";
	}
} else {
	$menu = "<b>Тема закрыта</b><br/>";
	if ($moder || (($Cop==$userinfo['Nick']) && ($sid!=FALSE))) {
		$menu.="<a href=\"moder.php?f=$f&mode=open&p=$p&t=$t$isid\">Открыть тему</a><br/>";
	}
}
if ($moder && ($Visible==0)) {
	$menu.="<a href=\"moder.php?f=$f&mode=del&p=$p&t=$t$isid\">Удалить тему</a><br/>";
}

if ($moder && ($Visible!=0)) {
	$menu.="<a href=\"moder.php?f=$f&mode=up&p=$p&t=$t$isid\">Восстановить тему</a><br/>";
}
displaytext($TopikTitle, $Banner . $back, $body, $next . $menu . $back, $w);
mysql_close($lnk);
?>