<?PHP
include "config.php";
if ($ingelogd == "0"){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=login.php\">";
exit;
}
include('header.php');
?>

<html lang="nl">
<head>
<title>Ultimatecrime</title>
<meta name="description" content="Ultimatecrime - Forum - muisje!">
<meta name="keywords" content="world, gangster, forum, chatten, praten, gezellig, ontmoeten, muisje, crimineel, email, sturen, post, mail">
<meta name="Robots" CONTENT="follow">
<meta name="REVISIT-AFTER" CONTENT="1 days">
<link rel="stylesheet" type="text/css" href="style_general.css">
</head>
<body background="layout/images/layout_12.gif" bgproperties="fixed">
<br>
<br>
<br>

<?php

$dbresb		=	mysql_query("SELECT * FROM `topic` WHERE `id`='{$_GET['x']}'");
$topic		=	mysql_fetch_object($dbresb);
$message	=	ubb($topic->message);
$dbresc		=	mysql_query("SELECT * FROM `gebruiker` WHERE `login`='{$topic->login}'");
$login		=	mysql_fetch_object($dbresc);
$dbresd		=	mysql_query("SELECT * FROM `gebruiker` WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300 AND `login`='{$login->login}'");
$controlle	=	mysql_num_rows($dbresd);

	if($controlle == 1){
	$status	=	"<font color=\"#00FF00\">Online</font>";
	} else {
	$status	=	"Offline";
	}

	if($_GET['actie'] == "delete"){
	$dbres	=	mysql_query("SELECT * FROM `topic_replay` WHERE `id`='{$_GET['id']}'");
	$topic	=	mysql_fetch_object($dbres);
	mysql_query("UPDATE `topic` SET `replays`=`replays`-'1' WHERE `id`='{$topic->topic_id}'");
	mysql_query("DELETE FROM `topic_replay` WHERE `id`='{$_GET['id']}'");
	echo "<meta http-equiv=\"refresh\" content=\"0 URL=internet-forum.php\">";
	exit;
	}
?>

<table align="center" width="600">
	<tr>
		<td class="subTitle" width="600" colspan="2" align="center">
		<strong>&nbsp;<?php echo $topic->titel; ?> - <?php echo $login->login; ?></strong>
		</td>
	</tr>
	<tr>
		<td class="subTitle" width="600" colspan="2" style="padding:0; spacing:0;">
		<table width="594">
			<tr>
				<td align="right" width="20">
				<img src="layout/images/forum/icon_subtitle_man.jpg" width="18" height="16" border="0">
				</td>
				<td width="200" align="left">
				<a href="speler-profiel.php?x=<?php echo $login->login; ?>" target="content"><strong><?php echo $login->login; ?></strong></a>
				<font color="#333333">(<?php echo $login->posts; ?> posts)</font>
				</td>
				<td align="center" width="176">
				<font color="#333333"><?php echo $topic->time; ?></font>
				</td>
				<td align="right" width="200">&nbsp;</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="mainTxt" align="center" valign="top" width="120">
		<a href="speler-profiel.php?x=<?php echo $login->login; ?>" target="content"><img src="<?php echo $login->avater; ?>" width="100" height="100" border="0"></a>
		<br /><b><?php echo $status; ?></b>
		</td>
		<td class="mainTxt" align="left" valign="top" width="480">
		<?php echo $message; ?>
		</td>
	</tr>


<?php

$begin		=	($_GET['p'] >= 0) ? $_GET['p']*9 : 0;
$dbresa		=	mysql_query("SELECT * FROM `topic_replay` WHERE `topic_id`='{$_GET['x']}' ORDER BY `time` LIMIT $begin,9");

?>



<?php

	while($replay = mysql_fetch_object($dbresa)){
	$dbres1		=	mysql_query("SELECT `login`,`posts`,`avater`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE `login`='{$replay->login}'");
	$login		=	mysql_fetch_object($dbres1);
	$message	=	ubb($replay->message);

		if($login->online + 300 > time()){
		$status	=	"<font color=\"#00FF00\">Online</font>";
		} else {
		$status	=	"Offline";
		}

?>

	<tr>
		<td class="subTitle" width="600" colspan="2" style="padding:0; spacing:0;">
		<table width="594">
			<tr>
				<td align="right" width="20">
				<img src="layout/images/forum/icon_subtitle_man.jpg" width="18" height="16" border="0">
				</td>
				<td width="200" align="left">
				<a href="speler-profiel.php?x=<?php echo $login->login; ?>" target="content"><strong><?php echo $login->login; ?></strong></a>
				<font color="#333333">(<?php echo $login->posts; ?> posts)</font>
				</td>
				<td align="center" width="176">
				<font color="#333333"><?php echo $replay->time; ?></font>
				</td>
				<td align="right" width="200"><?php if($data->level == 3){ ?><a href="forum-topic.php?actie=delete&id=<?php echo $replay->id; ?>"><img src="layout/images/forum/quote.png" border=0 width="16" height="16"></a><?php } ?></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="mainTxt" align="center" valign="top" width="120">
		<a href="speler-profiel.php?x=<?php echo $login->login; ?>" target="content"><img src="<?php echo $login->avater; ?>" width="100" height="100" border="0"></a>
		<br /><b><?php echo $status; ?></b>
		</td>
		<td class="mainTxt" align="left" valign="top" width="480">
		<?php echo $message; ?>
		</td>
	</tr>

<?php

	}

?>

</table>
<table align="center" width="600">

<?php

$dbres		=	mysql_query("SELECT * FROM `topic_replay` WHERE `topic_id`='{$_GET['x']}'");

	if(mysql_num_rows($dbres) > 9){
	echo "<tr><td class=\"maintxt\" align=\"center\" colspan=\"4\">";

		if($begina/9 == 0){
		echo "<<</font>";
		} else {
		echo "<a href=\"forum-topic.php?id={$_GET['id']}&x={$_GET['x']}&p=". ($begina/9-1) ."\"><<</a>";
		}

		for($i=0; $i<mysql_num_rows($dbres)/9; $i++){
		echo " <a href=\"forum-topic.php?id={$_GET['id']}&x={$_GET['x']}&p=$i\">". ($i+1) ."</a> ";
		}

		if($begina+9 >= mysql_num_rows($dbres)) {
		echo ">>";
		} else {
		echo "<a href=\"forum-topic.php?id={$_GET['id']}&x={$_GET['x']}&p=". ($begina/9+1) ."\">>></a>";
		}

	echo "&nbsp; </td></tr><tr>";
	}

?>

</table>
<table align="center" width="600">
	<tr>
		<td class="subtitle" colspan="2">Opties op deze forum topic</td>
	</tr>
	<tr>
		<td class="maintxt" colspan="2" align="center"></td>
	</tr>

<?php

	if($data->level == 3 OR $topic->soort != 2){

?>

	<tr>
		<td class="mainTxt" width="300" align="center"><table><tr><td><img src="layout/images/forum/icon_newtopic.jpg"></td><td><a href="forum-newtopic.php?z=<?php echo $topic->id; ?>"><strong>Reageren</strong></a></td></tr></table></td><td class="mainTxt" width="300" align="center"><table><tr><td><img src="layout/images/forum/icon_back.jpg"></td><td><a href="forum-board.php?x=<?php echo $_GET['id']; ?>"><strong>Terug naar forum</strong></a></td></tr></table></td>
	</tr>
	<tr>
		<td class="subtitle" colspan="2">&nbsp;</td>
	</tr>
</table>

<?php

	} else {

?>

	<tr>
		<td class="mainTxt" width="600" align="center"><table><tr><td><img src="layout/images/forum/icon_back.jpg"></td><td><a href="forum-board.php?x=<?php echo $_GET['id']; ?>"><strong>Terug naar forum</strong></a></td></tr></table></td>
	</tr>
	<tr>
		<td class="subtitle" colspan="2">&nbsp;</td>
	</tr>
</table>

<?php

	}

?>

</body>
</html>

