Location: PHPKode > projects > OneForum > oneforum/topic.php
<?php include('data/config.php'); ?>
<?php include('layout/header.php'); ?>
<script type="text/javascript">
function insert(was) {
document.topic.reply.value += was + " ";
document.topic.reply.focus();
}
</script>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0"><a name="top" id="top"></a>
  <tr>
    <td><?php

	include_once('data/bbcode.php');
	include_once('data/badwords.php');

	$sql = "SELECT
				topics.topic_id,
				topics.topic_subject,
				topics.topic_cat,
				categories.cat_id,
				categories.cat_name
			FROM
				topics
			LEFT JOIN
				categories
			  ON
				topics.topic_cat = categories.cat_id
			WHERE
				topic_id = " . mysql_real_escape_string($_GET['id']);
			
	$result = mysql_query($sql);
	$id = mysql_real_escape_string($_GET['id']);

	if(!$result)
	{
	echo '<br /><p class="false">This topic could not be found - Try again.</p><br />';
	
	}else{
	
	if(mysql_num_rows($result) == 0)
	{
	echo '<br /><p class="false">This topic does not exist!</p><br />';
	
	}else{
	
	while($row = mysql_fetch_assoc($result))
	{
	
		$viewsql = "UPDATE
    					topics
					SET
						topic_views = topic_views + 1
					WHERE
    					topic_id = " . $id;
			
		$viewcount = mysql_query($viewsql);
	
	echo '<table width="100%" cellpadding="1" class="cleantable">
			<tr>
				<td width="70%"><br /><a href="' . $index . '">Forum</a> &raquo;&nbsp;<a href="category.php?id=' . $row['cat_id'] . '">' . htmlentities($row['cat_name'], ENT_QUOTES) . ' </a>&raquo;&nbsp;<span class="blue">' . ((strlen($row['topic_subject'])<6) ? $row['topic_subject'] : substr($row['topic_subject'],0,50).'') . '</span></td>
				<td width="30%" align="right"><br />[ <a href="create.php?id=' . $row['cat_id'] . '">New Topic</a> ]</td>
			</tr>
		  </table>';
		  
	echo '<table width="100%" cellpadding="5" class="maintable">';
			
	$pfad = $_SERVER['PHP_SELF'];
	$query = mysql_query("SELECT post_topic FROM posts WHERE post_topic = '" . $id . "'");
	$total = mysql_num_rows($query);
	$seiten = ceil($total / $datensaetze_pro_seite);

	if(empty($_GET['page'])){
		$page = 1;
	}elseif($_GET['page'] <= 0 || $_GET['page'] > $seiten){
		$page = 1;
	
	}else{
	
	$page = mysql_real_escape_string($_GET['page']);
		}
		$links = array();
		if(($page - $p) < 1){ $davor = $page - 1;  }else { $davor = $p; }            
		if(($page + $p) > $seiten){ $danach = $seiten - $page; }else{ $danach = $p; }    
		$off = ($page - $davor);
		if ($page- $davor > 1){
			$first = 1;
			$links[] = "<a href=\"topic.php?id=$row[topic_id]&page=$first\" title=\"First Page\">&laquo; First ...</a>\n";      
			}      
			if($page != 1){
			    $prev = $page-1;
			    $links[] = "<a href=\"topic.php?id=$row[topic_id]&page=$prev\" title=\"Previouse Page\"> &laquo;</a>\n";     
			}   
			for($i = $off; $i <= ($page + $danach); $i++){
			  if ($i != $page){
			        $links[] = "<a href=\"topic.php?id=$row[topic_id]&page=$i\">$i</a>\n";
			  }elseif($i == $seiten) {
			        $links[] = "<span class=\"current\">[ $i ]</span>\n";  
			  }elseif($i == $page){
			        $links[] = "<span class=\"current\">[ $i ]</span>\n";
			  }
			}                
			if($page != $seiten){
			    $next = $page+1;
			    $links[] = "<a href=\"topic.php?id=$row[topic_id]&page=$next\" title=\"Next Page\"> &raquo;</a>\n";
			}    
			if($seiten - $page - $p > 0 ){
			    $last = $seiten; 
			    $links[] = "<a href=\"topic.php?id=$row[topic_id]&page=$last\" title=\"Last Page\">... Last &raquo;</a>\n";
			}
			$start = ($page-1) * $datensaetze_pro_seite;
			$link_string = implode(" ", $links);

			$id = mysql_real_escape_string($_GET['id']);
			$posts_sql = "SELECT
							posts.post_topic,
							posts.post_content,
							posts.post_date,
							posts.post_by,
							users.user_id,
							users.user_name,
							users.user_date,
							users.user_level,
							user_signature
						  FROM
							posts
						  LEFT JOIN
							users
						  ON
							posts.post_by = users.user_id
						  WHERE
							posts.post_topic = '" . $id . "'
						  LIMIT
							$start,$datensaetze_pro_seite";
						
			$posts_result = mysql_query($posts_sql);
			
			if(!$posts_result) {
			
			echo '<tr><td><p class="false">&nbsp;&nbsp;&nbsp;This topic could not be displayed.</p>.</td></tr>';
			echo '</table>';
			
			}else{
			
				while($posts_row = mysql_fetch_assoc($posts_result))
				{
				echo '<tr>
						<td width="25%"><p><strong><u><a href="profile.php?user_id=' . $posts_row['user_id'] . '">' . htmlentities($posts_row['user_name'], ENT_QUOTES) . '</a></u></strong><br/><br /><small>'; if($posts_row['user_level']==0) {
																echo '<span class="user">User</span>';
															}elseif ($posts_row['user_level']==2) {
																echo '<span class="mod">Moderator</span>';
															}elseif ($posts_row['user_level']==1) {
																echo '<span class="admin">Administrator</span>'; }
				echo '</small><br /><span class="blue">Dabei Seit:</span> ' . date('d.m.Y', strtotime($posts_row['user_date'])) . '</p></td>
						<td width="75%">' . parseBBCode2HTML(delBad(nl2br(stripslashes(strip_tags($posts_row['post_content']))))) . '</td>
					  </tr>
					  <tr>
					  	<td width="25%">&nbsp;</td>
					  	<td width="75%">'; if($posts_row['user_signature']) {
											   echo '<div id="line">&nbsp;</div><br /><small>' . $posts_row['user_signature'] . '</small>';
										   }elseif ($posts_row['user_signature']== "") {
											   echo ''; }
				echo '</td>
					  </tr>
					  <tr>
					  	<td bgcolor="#efefef"><small>' . date('d.m.Y - H:i', strtotime($posts_row['post_date'])) . '</small></td>
						<td bgcolor="#efefef" align="right">
						<a href="#reply"><img src="layout/icons/answer.png" width="16" height="16" border="0" /></a>&nbsp;&nbsp;<a href="profile.php?user_id=' . $posts_row['user_id'] . '"><img src="layout/icons/profile.png" width="16" height="16" border="0" /></a>&nbsp;&nbsp;<a href="#top"><img src="layout/icons/top.png" width="16" height="16" border="0" /></a></td>
					  </tr>';
				
				}
				
				echo '</table>';
				
				echo '<tr><td colspan="2"><br /><div id="navigation">';
				echo '<span class="pages">Page '.$page.' of '.$seiten.'</span>';
				echo $link_string;
				echo '</div><br /><br /></td></tr>';				
			}
			
			if(!$_SESSION['signed_in']) {
			
			echo '<tr><td colspan="2"><a name="reply" id="reply"></a>&nbsp;You have to <a href="signin.php">sign in</a> to reply. - Not <a href="signup.php">registered</a>?<br /><br /></td></tr>';
			
			}else{
			
			include_once('data/flood.php');
			
			echo "<tr><td colspan=\"2\" class=\"maintable\"><a name=\"reply\" id=\"reply\"></a><h1>&nbsp;Reply</h1><br />
				  <form name=\"topic\" method=\"post\" action=\"reply.php?id=" . $row['topic_id'] . "\">
				  &nbsp;<a href=\"javascript:insert('<b></b>')\"><img src=\"layout/images/bold.png\" width=\"32\" height=\"34\" border=\"0\" title=\"Bold\"></a><a href=\"javascript:insert('<i></i>')\"><img src=\"layout/images/kursiv.png\" width=\"31\" height=\"34\" border=\"0\" title=\"Italic\"></a><a href=\"javascript:insert('<u></u>')\"><img src=\"layout/images/underline.png\" width=\"31\" height=\"34\" border=\"0\" title=\"Underline\"></a><a href=\"javascript:insert('[url][/url]')\"><img src=\"layout/images/link.png\" width=\"31\" height=\"34\" border=\"0\" title=\"Hyperlink (mit http://)\"></a><br />
				  &nbsp;<textarea name=\"reply\" class=\"fields\"></textarea><br />
				  <p>&nbsp;<a href=\"javascript:insert(':P','')\"><img border=\"0\" src=\"layout/smileys/000.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert(':)','')\"><img border=\"0\" src=\"layout/smileys/001.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert(';)','')\"><img border=\"0\" src=\"layout/smileys/002.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert(':(','')\"><img border=\"0\" src=\"layout/smileys/003.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert('*grr*','')\"><img border=\"0\" src=\"layout/smileys/004.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert('o_o','')\"><img border=\"0\" src=\"layout/smileys/005.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert('*_*','')\"><img border=\"0\" src=\"layout/smileys/006.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert('._.','')\"><img border=\"0\" src=\"layout/smileys/007.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert('-_-','')\"><img border=\"0\" src=\"layout/smileys/008.gif\" width=\"15\" height=\"14\" /></a>
<a href=\"javascript:insert(':D','')\"><img border=\"0\" src=\"layout/smileys/009.gif\" width=\"15\" height=\"14\" /></a></p>
					<p><small>Spam protection *</small><br />
					<strong>The sum of " . $random1 . " + " . $code . " =</strong> <input size=\"5\" name=\"zip\" id=\"Spamschutz\" type=\"text\" class=\"fields\" /><input type=\"hidden\" name=\"zip2\" value=" . $rand_result . " /></p>
					<p>&nbsp;<input type=\"submit\" class=\"button\" value=\"Antworten\" alt=\"Reply\"/></p>
					</form></td></tr>";
				}
			}
		}
	}
	
	echo '</table>';

?></td>
  </tr>
  <tr>
    <td><?php include('layout/infobox.php'); ?></td>
  </tr>
</table>
<?php include('layout/footer.php'); ?>
Return current item: OneForum