<?php require('layout/header.php'); ?>
<div id="content_wrapper">
<div class="content"><?php
if((isset($_GET['id'])) && (is_numeric($_GET['id']))) {
$id = mysql_real_escape_string($_GET['id']);
$id = intval($_GET['id']);
}else{
echo '<p align="center" class="false">' . $lang['invalid_id'] . '!</p>';
exit();
}
$sql = "SELECT
cat_id,
cat_name,
cat_description
FROM
categories
WHERE
cat_id = " . $id;
$result = mysql_query($sql) OR die(mysql_error());
if(!$result) {
echo '<p class="false" align="center">' . $lang['no_category'] . '.</p>' . mysql_error();
}else{
if(intval(mysql_num_rows($result)) == 0) {
echo '<p class="false">' . $lang['no_existing_category'] . '.</p>';
}else{
while($row = mysql_fetch_assoc($result)) {
echo '<table width="100%" cellpadding="5" class="cleantable">
<tr>
<td width="50%"><a href="' . $index . '">Forum</a> » <span class="blue">' . htmlentities($row['cat_name'], ENT_QUOTES) . '</span></td>
<td width="50%" align="right">[ <a href="create.php?id=' . (int)$row['cat_id'] . '">' . $lang['new_topic'] . '</a> ]</td>
</tr>';
}
$pfad = $_SERVER['PHP_SELF'];
$query = mysql_query("SELECT topic_cat FROM topics WHERE topic_cat = '" . $id . "'") OR die(mysql_error());
$total = intval(mysql_num_rows($query));
$seiten = ceil($total / $datensaetze_pro_kategorie);
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="category.php?id=' . $id . '&page=' . $first . '" title="' . $lang['goto_first_page'] . '" class="topicby">« ' . $lang['first'] . ' ...</a>';
}
if($page != 1) {
$prev = $page-1;
$links[] = '<a href="category.php?id=' . $id . '&page=' . $prev . '" title="' . $lang['page_back'] . '" class="topicby"> «</a>';
}
for($i = $off; $i <= ($page + $danach); $i++) {
if($i != $page) {
$links[] = '<a href="category.php?id=' . $id . '&page=' . $i . '" class="topicby">' . $i . '</a>';
}elseif($i == $seiten) {
$links[] = '<span class="current_main">' . $i . '</span>';
}elseif($i == $page) {
$links[] = '<span class="current_main">' . $i . '</span>';
}
}
if($page != $seiten) {
$next = $page+1;
$links[] = '<a href="category.php?id=' . $id . '&page=' . $next . '" title="' . $lang['next_page'] . '" class="topicby"> »</a>';
}
if($seiten - $page - $p > 0 ) {
$last = $seiten;
$links[] = '<a href="category.php?id=' . $id . '&page=' . $last . '" title="' . $lang['last_page'] . '" class="topicby">... ' . $lang['last'] . ' »</a>';
}
$start = ($page-1) * $datensaetze_pro_kategorie;
$link_string = implode(" ", $links);
$query = "SELECT
topic_id,
topic_subject,
topic_date,
topic_cat,
topic_views
FROM
topics
WHERE
topic_cat = '" . $id . "'
ORDER BY
topic_id DESC
LIMIT
$start,$datensaetze_pro_kategorie";
$result = mysql_query($query) OR die(mysql_error());
if(!$result) {
echo '<tr><td><p>' . $lang['no_topic'] . '.</p></td></tr>';
}else{
if(intval(mysql_num_rows($result)) == 0) {
echo '<tr><td><br><h1>' . $lang['no_existing_topics'] . '.</h1></td></tr>';
}else{
echo '<table width="100%" cellpadding="5" class="maintable">
<tr>
<td align="left"><span class="blue">' . $lang['topic'] . '</span></td>
<td align="left"><span class="blue">' . $lang['date'] . ' | ' . $lang['views'] . '</span></td>
<td align="center"><span class="blue">' . $lang['posts'] . '</span></td>
</tr>';
while($row = mysql_fetch_assoc($result)) {
echo '<tr>';
if(strtotime($row['topic_date']) >= time()-7200) {
echo '<td class="leftpart"><img src="images/topic_new.png"> <a href="topic.php?id=' . (int)$row['topic_id'] . '">' . htmlentities($row['topic_subject'], ENT_QUOTES) . '</a><br></td>';
}else{
echo '<td class="leftpart"><img src="images/topic.png"> <a href="topic.php?id=' . (int)$row['topic_id'] . '">' . htmlentities($row['topic_subject'], ENT_QUOTES) . '</a></td>';
}
echo '<td class="rightpart"><img src="images/forward.png" alt="Go">';
if($language == "de") {
echo date('d.m.Y', strtotime($row['topic_date']));
}elseif($language == "en") {
echo date('Y-m-d', strtotime($row['topic_date'])); }
echo ' | <img src="images/views.png"> <span class="text_tags">' . htmlentities($row['topic_views']) . '</span></td>
<td class="statpart" align="center">';
$allrep = mysql_query("SELECT post_id FROM posts WHERE post_topic = " . (int)$row['topic_id'] . "");
$replies = mysql_num_rows($allrep);
echo '<div class="cat_bubble">
<span class="point4"></span>
<span class="bubble4">' . $replies . '</span>
</div></td></tr>';
}
echo '<table width="100%" cellpadding="0" class="pagefo">
<tr>
<td colspan="2"><br><br><span class="pages_main">' . $lang['page'] . ' <u>' . $page . '</u> ' . $lang['by'] . ' ' . $seiten . '</span>' . $link_string . '</td>
</tr></table>';
}}}}
echo '</table>';
?>
<div class="spacer_div"> </div>
<div class="clear"></div>
<div class="cloud_tags"><strong><?php
$abfrage = mysql_query("SELECT topic_id FROM topics WHERE topic_cat = '" . $id . "'") OR die(mysql_error());
$sum_topics = mysql_num_rows($abfrage);
echo (int)$sum_topics;
echo '</strong> ' . $lang['topics'] . ''; ?></div>
<div class="cloud_tags"><strong><?php
$abfrage = mysql_query("SELECT
posts.post_id,
posts.post_topic,
topics.topic_id,
topics.topic_cat
FROM
posts
LEFT JOIN
topics
ON
posts.post_topic = topics.topic_id
WHERE
topic_cat = '" . $id . "'");
$sum_posts = mysql_num_rows($abfrage);
echo (int)$sum_posts;
echo '</strong> ' . $lang['posts'] . ''; ?></div>
<div class="spacer_div"> </div>
</div>
</div>
<div id="infobox_wrapper">
<div class="infobox">
<?php include('layout/infobox.php'); ?>
</div>
</div>
<?php require('layout/footer.php'); ?>