2003-07-18 21:38:51 +00:00
< ? php
require_once ( '../include.php' );
require_once ( 'forum.inc' );
2003-07-30 00:50:54 +00:00
// Number of forum topics per page.
2003-07-18 21:38:51 +00:00
$n = 50 ;
/* sanitize variable */
$_GET [ 'id' ] = stripslashes ( strip_tags ( $_GET [ 'id' ]));
2003-07-30 00:50:54 +00:00
// Is this sanitization stuff really necessary?
$_GET [ 'sort' ] = stripslashes ( strip_tags ( $_GET [ 'sort' ]));
2003-07-18 21:38:51 +00:00
if ( ! array_key_exists ( 'start' , $_GET ) || $_GET [ 'start' ] < 0 )
$_GET [ 'start' ] = 0 ;
2003-08-01 20:30:25 +00:00
$forum = getForum ( $_GET [ 'id' ]);
if ( $forum -> is_helpdesk ) {
doHeader ( 'Help Desk' );
$sort_style = 'activity-most' ;
} else {
doHeader ( 'Forum' );
( $_GET [ 'sort' ] != NULL ) ? $sort_style = $_GET [ 'sort' ] : $sort_style = 'modified-new' ;
2003-07-30 00:50:54 +00:00
}
2003-07-18 21:38:51 +00:00
?>
2003-07-30 00:50:54 +00:00
< form action = " forum.php " method = " get " >
< input type = " hidden " name = " id " value =< ? php echo $forum -> id ?> >
< table width = 100 % cellspacing = 0 cellpadding = 0 >
< tr valign = " bottom " >
< td align = " left " style = " border:0px " >
2003-07-18 21:38:51 +00:00
< p >
< span class = " title " >< ? php echo $forum -> title ?> </span>
< br >< a href = " index.php " >< ? php echo $cfg [ 'sitename' ] ?> Forum</a>
</ p >
2003-08-01 20:30:25 +00:00
< p >< a href = " post.php?id=<?php echo $_GET['id'] ?> " >< ? php if ( $forum -> is_helpdesk ) echo " Post a New Question " ; else echo " Post a New Thread / Question " ; ?> </a></p>
2003-07-30 00:50:54 +00:00
</ td >
2003-08-01 20:30:25 +00:00
< ? php if ( ! $forum -> is_helpdesk ) { ?>
2003-07-30 00:50:54 +00:00
< td align = " right " style = " border:0px " >
< select name = " sort " >
< option < ? php if ( $sort_style == 'modified-new' ) echo 'selected' ?> value="modified-new">Most recent post first</option>
< option < ? php if ( $sort_style == 'modified-old' ) echo 'selected' ?> value="modified-old">Least recent post first</option>
2003-07-30 20:06:54 +00:00
< option < ? php if ( $sort_style == 'activity-most' ) echo 'selected' ?> value="activity-most">Most recent activity first</option>
2003-07-30 00:50:54 +00:00
< option < ? php if ( $sort_style == 'views-most' ) echo 'selected' ?> value="views-most">Most views first</option>
< option < ? php if ( $sort_style == 'replies-most' ) echo 'selected' ?> value="replies-most">Most replies first</option>
</ select >
< input type = " submit " value = " Sort " >
</ td >
2003-08-01 20:30:25 +00:00
< ? php } ?>
2003-07-30 00:50:54 +00:00
</ tr ></ table >
</ form >
2003-07-18 21:38:51 +00:00
< ? php
if ( $forum -> threads > $n ) :
$totalPages = floor ( $forum -> threads / $n );
$curPage = floor ( $_GET [ 'start' ] / $n );
$pages = array ( 0 , 1 , 2 );
for ( $i = - 1 ; $i <= 1 ; $i ++ )
if ( $curPage + $i > 0 && $curPage + $i < $totalPages - 1 )
array_push ( $pages , $curPage + $i );
for ( $i = - 3 ; $i <= - 1 ; $i ++ )
if ( $totalPages + $i > 0 )
array_push ( $pages , $totalPages + $i );
$pages = array_unique ( $pages );
natsort ( $pages );
$pages = array_values ( $pages );
$gotoStr = '<p style="text-align:right">Goto page ' ;
if ( $curPage == 0 )
$gotoStr .= '<span style="font-size:larger; font-weight:bold">1</span>' ;
else
$gotoStr .= '<a href="forum.php?id=' . $_GET [ 'id' ] . '&start=' . (( $curPage - 1 ) * $n ) . '">Previous</a> <a href="forum.php?id=' . $_GET [ 'id' ] . '&start=0">1</a>' ;
for ( $i = 1 ; $i < count ( $pages ) - 1 ; $i ++ ) {
if ( $curPage == $pages [ $i ]) {
$gotoStr .= ( $i > 0 && $pages [ $i - 1 ] == $pages [ $i ] - 1 ) ? ', ' : ' ... ' ;
$gotoStr .= '<span style="font-size:larger; font-weight:bold">' . ( $pages [ $i ] + 1 ) . '</span>' ;
} else {
$gotoStr .= ( $i > 0 && $pages [ $i - 1 ] == $pages [ $i ] - 1 ) ? ', ' : ' ... ' ;
$gotoStr .= '<a href="forum.php?id=' . $_GET [ 'id' ] . '&start=' . ( $pages [ $i ] * $n ) . '">' . ( $pages [ $i ] + 1 ) . '</a>' ;
}
}
if ( $curPage == $totalPages - 1 )
$gotoStr .= ', <span style="font-size:larger; font-weight:bold">' . $totalPages . '</span>' ;
else
$gotoStr .= ', <a href="forum.php?id=' . $_GET [ 'id' ] . '&start=' . (( $totalPages - 1 ) * $n ) . '">' . $totalPages . '</a> <a href="forum.php?id=' . $_GET [ 'id' ] . '&start=' . (( $curPage + 1 ) * $n ) . '">Next</a>' ;
$gotoStr .= '</p>' ;
echo $gotoStr ;
endif ;
?>
< p >
< table class = " content " border = " 0 " cellpadding = " 5 " cellspacing = " 0 " width = " 100% " >
< tr >
2003-08-01 20:30:25 +00:00
< ? php if ( $forum -> is_helpdesk ) { ?>
< th > Question </ th >
< th style = " width: 50px " > Answers </ th >
< ? php } else { ?>
< th > Titles </ th >
< th style = " width: 50px " > Replies </ th >
< th style = " width: 150px " > Author </ th >
< th style = " width: 50px " > Views </ th >
< th style = " width: 170px " > Last Post </ th >
< ? php } ?>
2003-07-18 21:38:51 +00:00
</ tr >
< ? php
2003-07-30 00:50:54 +00:00
$threads = $forum -> getThreads ( $_GET [ 'start' ], $n , $sort_style );
2003-07-18 21:38:51 +00:00
while ( $thread = getNextThread ( $threads )) :
$user = getUser ( $thread -> owner );
?>
< tr style = " font-size:8pt; text-align:center " >
< td class = " col1 " style = " font-size:10pt; text-align:left " >< a href = " thread.php?id=<?php echo $thread->id ?> " >< b >< ? php echo stripslashes ( $thread -> title ) ?> </b></a></td>
2003-08-01 20:30:25 +00:00
< ? php
if ( $forum -> is_helpdesk ) {
echo " <td class= \" col2 \" > " , $thread -> replies , " </td> " ;
} else {
echo "
< td class = \ " col2 \" > " , $thread -> replies , " </td>
< td class = \ " col3 \" ><a href= \" ../show_user.php?userid= " , $thread -> owner , " \" > " , $user -> name , " </a></td>
< td class = \ " col2 \" > " , $thread -> views , " </td>
< td class = \ " col3 \" style= \" text-align:right \" > " , date ( 'D M j, Y g:i a' , $thread -> timestamp ), " </td> " ;
}
?>
2003-07-18 21:38:51 +00:00
</ tr >
< ? php
endwhile ;
?>
</ table >
</ p >
< ? php
if ( $forum -> threads > $n )
echo $gotoStr ;
?>
< ? php
doFooter ();
?>