111 lines
3.4 KiB
PHP
111 lines
3.4 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
// Check forum status
|
|
$forum_status = db_getVal("select status from forums where school_num = $school_num and record_num = $forum");
|
|
|
|
|
|
?>
|
|
<center>
|
|
<?php
|
|
if (db_num_rows($results)) {
|
|
?>
|
|
<table width='<?php echo($default_data_width) ?>' cellpadding='10' cellspacing='1' border='0' class='big-content-table'>
|
|
<tr class='heading'>
|
|
<td width='60%'>Topic</td>
|
|
<td align='center'>Replies</td>
|
|
<td align='center'>Views</td>
|
|
<td width='20%'>Last Post</td>
|
|
</tr>
|
|
<?php
|
|
$count = 0;
|
|
while ($row = db_fetch_array($results)) {
|
|
extract($row);
|
|
|
|
$bgclass = 'data-even';
|
|
if ($count % 2) $bgclass = 'data-odd';
|
|
$count++;
|
|
|
|
$edit = "";
|
|
if ($forum_status != 'Closed' && $posted_by == $_SESSION['UserInfo']['record_num'])
|
|
$edit = " [<a href='?action=forums&naction=edit-thread&forum=$forum&topic=$record_num&reply=$record_num'>Edit</a>]";
|
|
|
|
// Get userid of the person who created this thread
|
|
$query = "select userid from users " .
|
|
"where school_num = $base_school_num " .
|
|
"and record_num = $posted_by";
|
|
$posted_id = db_getVal($query) . " $edit";
|
|
|
|
|
|
// Determine how many posts there are for this topic
|
|
$query = "select count(*) from forum_threads " .
|
|
"where school_num = $school_num " .
|
|
"and top_thread_id = $record_num";
|
|
$posts = db_getVal($query);
|
|
|
|
|
|
// Get last post info
|
|
$last_posted_by = "";
|
|
$last_post = "No Posts";
|
|
|
|
// Get last post information
|
|
$query = "select posted_by,posted_time from forum_threads " .
|
|
"where school_num = $school_num " .
|
|
"and (top_thread_id = $record_num or record_num = $record_num) " .
|
|
"order by posted_time desc " .
|
|
"limit 0,1";
|
|
$result = db_query($query);
|
|
if (db_num_rows($result)) {
|
|
$row = db_fetch_array($result);
|
|
$last_post = date("D M jS @ g:ia",$row['posted_time']);
|
|
$user_num = $row['posted_by'];
|
|
$query = "select userid from users " .
|
|
"where school_num = $base_school_num " .
|
|
"and record_num = $user_num";
|
|
$last_posted_by = "posted by :: " . db_getVal($query);
|
|
}
|
|
|
|
if (strlen($message)) $message = nl2br($message) . "<br>\n<hr size='1'>\n";
|
|
|
|
?>
|
|
<tr class='<?php echo($bgclass) ?>'>
|
|
<td valign='top'>
|
|
<b><a href='?action=forums&forum=<?php echo($forum) ?>&topic=<?php echo($record_num) ?>'><?php echo($subject) ?></a></b><br>
|
|
<?php echo($message) ?>
|
|
<span class='small'>Created By :: <?php echo($posted_id) ?></span>
|
|
</td>
|
|
<td align='center' valign='top'><?php echo(number_format($posts,0)) ?></td>
|
|
<td align='center' valign='top'><?php echo(number_format($thread_views,0)) ?></td>
|
|
<td valign='top'>
|
|
<?php echo($last_post) ?><br>
|
|
<?php echo($last_posted_by) ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</table>
|
|
<?php
|
|
}
|
|
|
|
if ($count == 1) $current_forum_title .= "<br> - Topic :: <b>$subject</b>";
|
|
|
|
// Setup form values
|
|
if ($forum_status == 'Open' && !isset($topic)) {
|
|
$TitleText = "Create a New Forum Topic";
|
|
$ButtonText = "Create Topic";
|
|
$next_naction = "new-topic";
|
|
$topic = 0;
|
|
$subject = "";
|
|
$message = "";
|
|
include "forums.topic-form.php";
|
|
}
|
|
?>
|
|
</center>
|
|
<br>
|