2004-02-02 23:34:39 +00:00
< ? php
2005-01-12 13:39:05 +00:00
$cvs_version_tracker [] = " \$ Id $ " ; //Generated automatically - do not edit
2004-02-02 23:34:39 +00:00
require_once ( '../inc/db.inc' );
2005-05-04 08:46:46 +00:00
require_once ( '../inc/db_forum.inc' );
2004-05-24 03:40:38 +00:00
require_once ( '../inc/time.inc' );
2005-01-18 13:00:38 +00:00
require_once ( '../inc/forum_moderators.inc' );
2005-05-13 19:11:04 +00:00
require_once ( '../inc/text_transform.inc' );
2006-07-10 17:18:42 +00:00
require_once ( '../inc/util.inc' );
2007-05-26 17:00:01 +00:00
require_once ( '../inc/forum_pm.inc' );
2004-02-02 23:34:39 +00:00
2004-09-04 23:37:49 +00:00
define ( 'AVATAR_WIDTH' , 100 );
define ( 'AVATAR_HEIGHT' , 100 );
2005-01-18 13:00:38 +00:00
$special_user_bitfield [ 0 ] = " Forum moderator " ;
$special_user_bitfield [ 1 ] = " Project administrator " ;
$special_user_bitfield [ 2 ] = " Project developer " ;
$special_user_bitfield [ 3 ] = " Project tester " ;
$special_user_bitfield [ 4 ] = " Volunteer developer " ;
$special_user_bitfield [ 5 ] = " Volunteer tester " ;
$special_user_bitfield [ 6 ] = " Project scientist " ;
2004-09-04 23:37:49 +00:00
define ( 'ST_NEW_TIME' , 1209600 ); //3600*24*14 - 14 days
define ( 'ST_NEW' , 'New member' );
2005-01-18 13:00:38 +00:00
define ( 'MAXIMUM_EDIT_TIME' , 3600 ); //Maximally allow edits of forums posts up till one hour after posting.
2004-09-04 23:37:49 +00:00
define ( 'FORUM_OPEN_LINK_IN_NEW_WINDOW' , 1 );
2006-06-16 23:53:56 +00:00
define ( 'MAX_FORUM_LOGGING_TIME' , 2419200 ); //3600*24*28 - 28 days
2004-02-02 23:34:39 +00:00
define ( 'NO_CONTROLS' , 0 );
define ( 'FORUM_CONTROLS' , 1 );
define ( 'HELPDESK_CONTROLS' , 2 );
define ( " EXCERPT_LENGTH " , " 120 " );
2005-04-20 20:56:58 +00:00
define ( 'NEW_IMAGE' , 'img/unread_post.png' );
define ( 'NEW_IMAGE_STICKY' , 'img/unread_sticky.png' );
2006-11-10 17:09:09 +00:00
define ( 'NEW_IMAGE_LOCKED' , 'img/unread_locked.png' );
define ( 'NEW_IMAGE_STICKY_LOCKED' , 'img/unread_sticky_locked.png' );
define ( 'IMAGE_STICKY' , 'img/sticky_post.png' );
define ( 'IMAGE_LOCKED' , 'img/locked_post.png' );
define ( 'IMAGE_STICKY_LOCKED' , 'img/sticky_locked_post.png' );
2004-10-10 03:04:29 +00:00
define ( 'NEW_IMAGE_HEIGHT' , '15' );
2005-04-20 20:56:58 +00:00
define ( 'EMPHASIZE_IMAGE' , 'img/emphasized_post.png' );
2004-10-25 22:04:15 +00:00
define ( 'EMPHASIZE_IMAGE_HEIGHT' , '15' );
2005-04-20 20:56:58 +00:00
define ( 'FILTER_IMAGE' , 'img/filtered_post.png' );
2004-12-18 18:13:46 +00:00
define ( 'FILTER_IMAGE_HEIGHT' , '15' );
2005-04-30 09:04:00 +00:00
define ( 'RATE_POSITIVE_IMAGE' , 'img/rate_positive.png' );
define ( 'RATE_POSITIVE_IMAGE_HEIGHT' , '9' );
define ( 'RATE_NEGATIVE_IMAGE' , 'img/rate_negative.png' );
define ( 'RATE_NEGATIVE_IMAGE_HEIGHT' , '9' );
2005-10-01 11:11:53 +00:00
define ( 'REPORT_POST_IMAGE' , 'img/report_post.png' );
define ( 'REPORT_POST_IMAGE_HEIGHT' , '9' );
2004-02-02 23:34:39 +00:00
define ( 'SOLUTION' , 'This answered my question' );
define ( 'SUFFERER' , 'I also have this question' );
define ( 'OFF_TOPIC' , 'Off-topic' );
2004-10-25 22:04:15 +00:00
define ( 'DEFAULT_LOW_RATING_THRESHOLD' , - 25 );
define ( 'DEFAULT_HIGH_RATING_THRESHOLD' , 5 );
2004-09-04 23:37:49 +00:00
$thread_sort_styles [ 'timestamp' ] = " Newest first " ;
$thread_sort_styles [ 'timestamp_asc' ] = " Oldest first " ;
$thread_sort_styles [ 'score' ] = " Highest rated first " ;
2004-02-02 23:34:39 +00:00
$faq_sort_styles [ 'create_time' ] = " Most recent question first " ;
$faq_sort_styles [ 'timestamp' ] = " Most recent answer first " ;
2004-03-26 18:37:46 +00:00
$faq_sort_styles [ 'activity' ] = " Most frequently asked first " ;
2004-02-02 23:34:39 +00:00
$answer_sort_styles [ 'score' ] = " Highest score first " ;
$answer_sort_styles [ 'timestamp' ] = " Most recent first " ;
2004-09-04 23:37:49 +00:00
$answer_sort_styles [ 'timestamp_asc' ] = " Oldest first " ;
2004-02-02 23:34:39 +00:00
$thread_filter_styles [ '2' ] = " \" Very helpful \" " ;
$thread_filter_styles [ '1' ] = " At least \" helpful \" " ;
$thread_filter_styles [ '0' ] = " At least \" neutral \" " ;
$thread_filter_styles [ '-1' ] = " At least \" unhelpful \" " ;
$thread_filter_styles [ '-2' ] = " All posts " ;
$post_ratings [ '2' ] = " Very helpful (+2) " ;
$post_ratings [ '1' ] = " Helpful (+1) " ;
$post_ratings [ '0' ] = " Neutral " ;
2004-12-28 05:25:44 +00:00
$post_ratings [ '-1' ] = " Not helpful (-1) " ;
2004-02-02 23:34:39 +00:00
$post_ratings [ '-2' ] = " Off topic (-2) " ;
2006-07-10 17:18:42 +00:00
$config = get_config ();
2007-04-29 13:02:35 +00:00
$no_forum_rating = parse_bool ( $config , " no_forum_rating " );
2006-07-10 17:18:42 +00:00
2006-06-16 23:53:56 +00:00
/**
* Process a user - supplied title to remove HTML stuff
**/
2005-01-09 21:52:22 +00:00
function cleanup_title ( $title ) {
2006-12-23 14:59:47 +00:00
$x = trim ( htmlspecialchars ( $title ));
2005-01-14 19:45:43 +00:00
$x = stripslashes ( $x ); // clean up funky old titles in DB
2005-01-09 21:52:22 +00:00
if ( strlen ( $x ) == 0 ) return " (no title) " ;
else return $x ;
}
2006-06-16 23:53:56 +00:00
/**
* Check if user has special user bit enabled
**/
2005-01-18 13:00:38 +00:00
function isSpecialUser ( $user , $specialbit ){
return ( substr ( $user -> special_user , $specialbit , 1 ) == 1 );
}
2006-06-16 23:53:56 +00:00
/**
* Check to see if a specific user has rated a specific post before
**/
2004-10-25 22:04:15 +00:00
function getHasRated ( $user , $postid ){
2005-04-20 20:56:58 +00:00
return ( strstr ( $user -> rated_posts , " | " . $postid ));
2004-10-25 22:04:15 +00:00
}
2006-06-16 23:53:56 +00:00
/**
* Get the user ' s preferred sorting style .
**/
2004-09-04 23:37:49 +00:00
function getSortStyle ( $user , $place ){
2004-09-05 19:26:27 +00:00
if ( $user -> id != " " ){
2004-10-10 03:04:29 +00:00
list ( $forum , $thread , $faq , $answer ) = explode ( " | " , $user -> sorting );
2004-09-05 19:26:27 +00:00
} else {
list ( $forum , $thread , $faq , $answer ) = explode ( " | " , $_COOKIE [ 'sorting' ]);
}
2006-06-16 23:53:56 +00:00
return $$place ; // Huh?
2004-09-04 23:37:49 +00:00
}
2007-11-11 19:22:35 +00:00
function should_show_post ( $logged_in_user , $postcount , $postnumber , $post , $sort_style , $last_visit ){
$no_wraparound = get_str ( " nowrap " , true );
2004-03-26 22:56:45 +00:00
2007-11-11 19:22:35 +00:00
// If the user isn't logged in we always display everything (useful for Google bots etc)
if ( ! $logged_in_user ) return true ;
// If the user hasn't enabled the feature to display only a certain amount of posts, simply display all of them.
if ( ! $logged_in_user -> getMinimumWrapPostcount ()) return true ;
// If the user has asked to display all the posts just display them
if ( $no_wraparound ) return true ;
// If it is enabled and we havent yet hit the limit, simply display all
if ( $postcount < $logged_in_user -> getMinimumWrapPostcount ()) return true ;
// Let's display the post if it is the first post
if ( $postnumber == 1 || $postnumber == ( $postcount + 1 )) return true ;
// Also, if this post is unread, show it
if ( $post -> getTimestamp () > $last_visit ) return true ;
// The user can choose to display the last X posts in a thread only, "last" here depends on sorting criteria:
if ( $sort_style == CREATE_TIME_OLD ){
if ( $postnumber > $postcount + 1 - $logged_in_user -> getDisplayWrapPostcount ()) return true ;
} else if ( CREATE_TIME_NEW ){
if ( $postnumber <= $logged_in_user -> getDisplayWrapPostcount ()) return true ;
} else {
// For other sorting criteria we do not know how to define "last" so simply display it all
return true ;
}
// In all other cases we should not show this particular post
return false ;
}
2006-06-16 23:53:56 +00:00
/*** display functions ***/
2004-02-02 23:34:39 +00:00
2006-06-16 23:53:56 +00:00
/**
* Show the posts in a thread for a user .
* It ' s a big one .
**/
2007-10-30 23:34:26 +00:00
function show_posts (
$thread , $sort_style , $filter , $logged_in_user , $show_controls = true
) {
2004-02-02 23:34:39 +00:00
$n = 1 ;
2007-10-12 17:58:50 +00:00
$first_unread_post = null ;
2007-10-30 23:34:26 +00:00
$last_visit = 0 ;
2007-10-12 17:58:50 +00:00
2006-06-16 23:53:56 +00:00
if ( $show_controls ) {
2004-02-02 23:34:39 +00:00
$controls = FORUM_CONTROLS ;
} else {
$controls = NO_CONTROLS ;
}
2005-09-20 17:54:52 +00:00
// If logged in user is moderator,
// let him see all posts - including hidden ones
2006-06-16 23:53:56 +00:00
if ( $logged_in_user && $logged_in_user -> isSpecialUser ( S_MODERATOR )){
2005-09-20 17:54:52 +00:00
$show_hidden_posts = true ;
2005-01-18 13:00:38 +00:00
} else {
2005-09-20 17:54:52 +00:00
$show_hidden_posts = false ;
2005-01-18 13:00:38 +00:00
}
2006-06-16 23:53:56 +00:00
$posts = $thread -> getPosts ( $sort_style , $show_hidden_posts );
$postcount = ( sizeof ( $posts ) - 1 );
2007-10-30 23:34:26 +00:00
if ( $logged_in_user ) {
$last_visit = $thread -> getLastReadTimestamp ( $logged_in_user );
}
2004-02-02 23:34:39 +00:00
2005-11-28 00:24:32 +00:00
$postnumber = 0 ; $previous_post = 0 ;
2006-06-16 23:53:56 +00:00
foreach ( $posts as $key => $post ){
2007-11-11 19:22:35 +00:00
$postnumber ++ ;
if ( should_show_post ( $logged_in_user , $postcount , $postnumber , $post , $sort_style , $last_visit )){
2007-10-30 23:34:26 +00:00
if ( $postnumber != $previous_post + 1 ){
//A number of posts were hidden, display a way to unhide them:
echo " <tr class= \" postseperator \" ><td></td><td colspan= \" 2 \" >
Only the first post and the last " .( $logged_in_user->getDisplayWrapPostcount ()). " posts
( of the " .( $postcount +1). " posts in this thread ) are displayed . < br />
< a href = \ " ?id= " . $thread -> getID () . " &nowrap=true \" >Click here to also display the remaining posts</a>.</td></tr> " ;
2006-06-16 23:53:56 +00:00
}
2007-10-30 23:34:26 +00:00
$previous_post = $postnumber ;
show_post ( $post , $thread , $logged_in_user , $n , $controls , $filter );
// To allow users to start reading a thread even though our DB layer is super slow
$n = ( $n + 1 ) % 2 ;
if (( $post -> getTimestamp () > $last_visit ) &&
(( ! $first_unread_post ) || ( $post -> getTimestamp () < $first_unread_post -> getTimestamp ()))
){
$first_unread_post = $post ;
}
}
2004-02-02 23:34:39 +00:00
}
2005-01-09 21:52:22 +00:00
2006-06-16 23:53:56 +00:00
if ( $logged_in_user && $logged_in_user -> hasJumpToUnread ()){
if ( $first_unread_post ){
echo " <script>function jumpToUnread() { location.href='# " . $first_unread_post -> getID () . " ';}</script> " ;
2004-10-10 03:04:29 +00:00
} else {
echo " <script>function jumpToUnread() { };</script> " ;
}
}
2006-06-16 23:53:56 +00:00
if ( $logged_in_user ) $thread -> setLastReadTimestamp ( $logged_in_user );
2004-02-02 23:34:39 +00:00
}
2006-06-16 23:53:56 +00:00
/**
* Display an individual post , as though in a thread .
**/
function show_post ( $post , $thread , $logged_in_user , $n , $controls = FORUM_CONTROLS , $filter = true ) {
$user = $post -> getOwner ();
2006-07-10 17:18:42 +00:00
global $no_forum_rating ;
2007-05-11 02:43:57 +00:00
global $config ;
2006-06-16 23:53:56 +00:00
2007-10-30 23:34:26 +00:00
$tokens = " " ;
$rated_below_threshold = false ;
$rated_above_threshold = false ;
2007-02-08 19:54:05 +00:00
2007-10-30 23:34:26 +00:00
//If the user that made this post is on the list of people to ignore,
// change thresholds to be much more strict
//
2006-06-16 23:53:56 +00:00
if ( $logged_in_user ){
2007-10-30 23:34:26 +00:00
$tokens = url_tokens ( $logged_in_user -> getAuthenticator ());
2006-06-16 23:53:56 +00:00
if ( in_array ( $user -> getID (), $logged_in_user -> getIgnoreList ())){
$user_is_on_ignorelist = true ;
$rated_below_threshold = ( $logged_in_user -> getHighRatingThreshold () > $post -> getRating ());
$rated_above_threshold = ( $logged_in_user -> getHighRatingThreshold () + abs ( $logged_in_user -> getLowRatingThreshold ()) < ( $post -> getRating ()));
} else { //Use normal threshold values
$rated_below_threshold = ( $logged_in_user -> getLowRatingThreshold () > ( $post -> getRating ()));
$rated_above_threshold = ( $logged_in_user -> getHighRatingThreshold () < ( $post -> getRating ()));
}
2005-01-06 11:47:44 +00:00
}
2007-10-30 23:34:26 +00:00
2006-08-01 22:28:03 +00:00
// The creator can edit the post, but only in a specified amount of time
// (exception: a moderator can edit his/her posts at any time)
2006-08-01 21:45:05 +00:00
//
2006-08-01 22:28:03 +00:00
$can_edit = false ;
if ( $logged_in_user ) {
if ( $user -> getID () == $logged_in_user -> getID ()) {
if ( $logged_in_user -> isSpecialUser ( S_MODERATOR )) {
$can_edit = true ;
2006-12-29 20:57:29 +00:00
} else if ( can_reply ( $thread , $logged_in_user )) {
2006-08-01 22:28:03 +00:00
$time_limit = $post -> getTimestamp () + MAXIMUM_EDIT_TIME ;
$can_edit = time () < $time_limit ;
2006-12-29 20:57:29 +00:00
} else {
$can_edit = false ;
2006-08-01 22:28:03 +00:00
}
}
}
2006-08-01 21:45:05 +00:00
2004-02-02 23:34:39 +00:00
echo "
2007-07-14 18:33:48 +00:00
< tr class = \ " row " . $n . " \" valign= \" top \" >
< td rowspan = \ " 3 \" ><a name= \" " . $post -> getID () . " \" ></a><div class= \" authorcol \" >
2004-02-02 23:34:39 +00:00
" ;
2006-06-16 23:53:56 +00:00
// Print the user links
echo re_user_links ( $user , URL_BASE );
2005-02-08 21:20:00 +00:00
echo " <br> " ;
2006-06-16 23:53:56 +00:00
// Print the special user lines, if any
2005-01-18 13:00:38 +00:00
global $special_user_bitfield ;
2005-05-11 08:59:42 +00:00
$fstatus = " " ;
2006-06-16 23:53:56 +00:00
$keys = array_keys ( $special_user_bitfield );
for ( $i = 0 ; $i < sizeof ( $special_user_bitfield ); $i ++ ) {
if ( $user -> isSpecialUser ( $keys [ $i ])) {
$fstatus .= $special_user_bitfield [ $keys [ $i ]] . " <br> " ;
2005-09-20 17:54:52 +00:00
}
2004-09-04 23:37:49 +00:00
}
2007-10-12 17:58:50 +00:00
if ( $user -> getCreateTime () > time () - ST_NEW_TIME ) $fstatus .= ST_NEW . " <br> " ;
2005-02-08 21:20:00 +00:00
if ( $fstatus ) echo " <font size= \" -2 \" > $fstatus </font> " ;
2004-12-21 23:06:31 +00:00
2006-06-16 23:53:56 +00:00
echo " <span class= \" authorinfo \" > " ;
2004-10-25 22:04:15 +00:00
if ( ! $filter || ! $rated_below_threshold ){
2006-06-16 23:53:56 +00:00
if ( $user -> hasAvatar () && ( ! $logged_in_user || ( $logged_in_user -> hasHideAvatars () == false ))) {
echo " <img width= \" " . AVATAR_WIDTH . " \" height= \" " . AVATAR_HEIGHT . " \" src= \" " . $user -> getAvatar () . " \" alt= \" Avatar \" ><br> " ;
2005-01-09 21:52:22 +00:00
}
2007-03-27 14:43:00 +00:00
}
2007-11-01 17:54:44 +00:00
$url = " forum_pm.php?action=new&userid= " . $user -> getID ();
$name = $user -> dbObj -> name ;
show_button ( $url , " Send message " , " Send $name a private message " );
echo " Joined: " , gmdate ( 'M j y' , $user -> getCreateTime ()), " <br> " ;
2007-05-15 10:06:38 +00:00
2007-03-27 14:43:00 +00:00
if ( function_exists ( 'project_forum_user_info' )){
project_forum_user_info ( $user );
} else { // default
// circumvent various forms of identity spoofing
// by displaying the user id of the poster.
// its cheap, easy, and doesn't require any additional database calls.
echo " Posts: " . $user -> getPostCount () . " <br> " ;
echo " ID: " . $user -> getID () . " <br> " ;
echo " Credit: " . number_format ( $user -> getTotalCredit ()) . " <br> " ;
echo " RAC: " . number_format ( $user -> getExpavgCredit ()) . " <br> " ;
2004-10-25 22:04:15 +00:00
}
2006-06-16 23:53:56 +00:00
echo " </span></div></td> " ;
2005-01-14 19:45:43 +00:00
2006-06-16 23:53:56 +00:00
if ( $controls == FORUM_CONTROLS ) {
echo " <td colspan= \" 2 \" class= \" postheader \" > " ;
2007-11-02 15:57:19 +00:00
echo " <form action= \" forum_rate.php?post= " , $post -> getID (), " \" method= \" post \" > " ;
2005-11-24 16:26:05 +00:00
} else {
2006-06-16 23:53:56 +00:00
echo " <td class= \" postheader \" > " ;
2005-11-24 16:26:05 +00:00
}
2004-09-04 23:37:49 +00:00
2006-06-16 23:53:56 +00:00
if ( $logged_in_user && $post -> getTimestamp () > $thread -> getLastReadTimestamp ( $logged_in_user )){
2007-11-01 20:41:24 +00:00
show_image ( NEW_IMAGE , " You haven't read this message yet " , NEW_IMAGE_HEIGHT );
2004-09-04 23:37:49 +00:00
}
2004-10-25 22:04:15 +00:00
if ( $rated_above_threshold ){
2007-11-01 20:41:24 +00:00
show_image ( EMPHASIZE_IMAGE , " This message has a high average rating " , EMPHASIZE_IMAGE_HEIGHT );
2004-10-25 22:04:15 +00:00
}
2005-01-09 21:52:22 +00:00
2006-06-16 23:53:56 +00:00
echo " <a href= \" forum_thread.php?id= " . $thread -> getID () . " &nowrap=true# $post->id\ " > Message " . $post->getID (). " </ a > - " ;
if ( $post -> isHidden ()) echo " <font color=red>[deleted] </font> " ;
2005-01-09 21:52:22 +00:00
echo "
2006-06-16 23:53:56 +00:00
Posted " , pretty_time_str( $post->getTimestamp ());
2004-02-02 23:34:39 +00:00
;
2007-11-02 18:48:48 +00:00
if ( $post -> getParentPostID ()) {
echo " - in response to <a href= \" forum_thread.php?id= " . $thread -> getID () . " &nowrap=true# " . $post -> getParentPostID () . " \" >Message ID " . $post -> getParentPostID () . " </a>. " ;
}
echo " " ;
if ( $can_edit && $controls != NO_CONTROLS ) {
show_button ( " forum_edit.php?id= " . $post -> getID () . " $tokens " , " Edit " , " Edit this message " );
}
if ( $logged_in_user && $logged_in_user -> isSpecialUser ( S_MODERATOR )) {
show_post_moderation_links ( $config , $logged_in_user , $post , $tokens );
}
if ( $post -> getModificationTimestamp ()) {
echo " <br>Last modified: " , pretty_time_Str ( $post -> getModificationTimestamp ());
}
2004-10-25 22:04:15 +00:00
if ( $rated_below_threshold && $filter ){
2007-11-02 18:48:48 +00:00
if ( $user_is_on_ignorelist ) {
$andtext = " and the user is on your ignore list " ;
}
2006-06-16 23:53:56 +00:00
echo " <br>This post has been filtered (rating: " . ( $post -> getRating ()) . " ) $andtext , press <a href= \" ?id= " . $thread -> getID () . " &filter=false# " . $post -> getID () . " \" >here</a> to view this thread without filtering " ;
2004-02-02 23:34:39 +00:00
}
2006-06-16 23:53:56 +00:00
echo " </td></tr></form> " ;
2005-11-24 16:26:05 +00:00
echo " <tr class= \" row $n\ " >< td class = \ " postbody \" colspan= \" 2 \" > " ;
2006-06-16 23:53:56 +00:00
//If either filtering is turned off or this post is not below the threshold
2005-01-09 21:52:22 +00:00
if ( ! $filter || ! $rated_below_threshold ){
2006-06-16 23:53:56 +00:00
$posttext = $post -> getContent ();
2005-09-20 17:54:52 +00:00
// If the creator of this post has a signature and
// wants it to be shown for this post AND the logged in
// user has signatures enabled: show it
//
2006-06-16 23:53:56 +00:00
if ( $post -> hasSignature () && ( ! $logged_in_user || ! $logged_in_user -> hasHideSignatures ())){
$posttext .= " \n ____________ \n " . $user -> getSignature ();
2005-09-20 17:54:52 +00:00
}
2006-06-16 23:53:56 +00:00
if ( $logged_in_user ){
$options = $logged_in_user -> getTextTransformSettings ();
} else {
$options = new output_options ;
}
2005-09-20 17:54:52 +00:00
$posttext = output_transform ( $posttext , $options );
2005-05-13 19:11:04 +00:00
2005-05-17 08:53:29 +00:00
echo " <p> " , $posttext , " </p> " ;
2006-06-16 23:53:56 +00:00
echo " </td></tr><tr><td class= \" postfooter \" >ID: <i> " , $post -> id ;
2006-07-10 17:18:42 +00:00
if ( $no_forum_rating != NULL ) {
2007-11-01 20:41:24 +00:00
echo " | <a href= \" forum_report_post.php?post= " . $post -> getID () . " \" > " ;
show_image ( REPORT_POST_IMAGE , " Report this post as offensive " , REPORT_POST_IMAGE_HEIGHT );
echo " </td> " ;
2006-07-10 17:18:42 +00:00
} else {
2007-10-30 23:34:26 +00:00
$rating = $post -> getRating ();
2007-11-01 20:41:24 +00:00
echo " | Rating: " , $rating , " </i> | rate:
< a href = \ " forum_rate.php?post= " . $post -> getID () . " &choice=p $tokens\ " >
" ;
show_image ( RATE_POSITIVE_IMAGE , " Click if you like this message " , RATE_POSITIVE_IMAGE_HEIGHT );
echo " </a> / <a href= \" forum_rate.php?post= " . $post -> getID () . " &choice=n $tokens\ " > " ;
show_image ( RATE_NEGATIVE_IMAGE , " Click if you don't like this message " , RATE_NEGATIVE_IMAGE_HEIGHT );
echo " </a> <a href= \" forum_report_post.php?post= " . $post -> getID () . " \" > " ;
show_image ( REPORT_POST_IMAGE , " Report this post as offensive " , REPORT_POST_IMAGE_HEIGHT );
echo " </a></td> " ;
2006-07-10 17:18:42 +00:00
}
2006-12-29 20:57:29 +00:00
if (( $controls == FORUM_CONTROLS ) && ( can_reply ( $thread , $logged_in_user ))) {
2007-11-01 20:41:24 +00:00
echo " <td align=right class= \" postfooter \" > " ;
$url = " forum_reply.php?thread= " . $thread -> getID () . " &post= " . $post -> getID () . " #input " ;
show_button ( $url , " Reply " , " Post a reply to this message " );
echo " </td> " ;
2005-11-24 16:26:05 +00:00
} else {
2006-06-16 23:53:56 +00:00
echo " <td class= \" postfooter \" ></td> " ;
}
2005-11-24 16:26:05 +00:00
echo " </tr> " ;
2007-06-22 13:19:56 +00:00
} else {
echo " </td></tr><tr><td class= \" postfooter \" colspan= \" 2 \" > " ;
2004-02-02 23:34:39 +00:00
}
2005-11-24 16:26:05 +00:00
echo " <tr class= \" postseperator \" ><td colspan=3></td></tr> " ;
2004-02-02 23:34:39 +00:00
}
2006-06-16 23:53:56 +00:00
/*** utility functions ***/
2004-02-02 23:34:39 +00:00
2006-06-16 23:53:56 +00:00
/**
* Start the forum table , output the proper headings and such .
**/
2007-10-22 19:36:01 +00:00
function start_forum_table ( $headings , $extra = " width= \" 100% \" " ) {
2007-10-12 17:58:50 +00:00
$span = null ;
2007-10-22 19:36:01 +00:00
start_table ( $extra . " cellspacing= \" 0 \" " );
2005-01-18 19:56:18 +00:00
echo " <tr> " ;
2004-02-02 23:34:39 +00:00
2005-01-18 19:56:18 +00:00
for ( $i = 0 ; $i < count ( $headings ); $i ++ ) {
2005-09-20 17:54:52 +00:00
if ( is_array ( $headings [ $i ])){
$title = $headings [ $i ][ 0 ];
2006-06-16 23:53:56 +00:00
$class = $headings [ $i ][ 1 ] ? $headings [ $i ][ 1 ] : " heading " ;
2007-10-12 17:58:50 +00:00
if ( isset ( $headings [ $i ][ 2 ])) {
$span = " colspan= \" " . $headings [ $i ][ 2 ] . " \" " ;
}
2005-09-20 17:54:52 +00:00
} else {
$title = $headings [ $i ];
$class = " heading " ;
2006-06-16 23:53:56 +00:00
$span = " " ;
2005-09-20 17:54:52 +00:00
}
2006-06-16 23:53:56 +00:00
echo " <th class= $class $span > $title </th> " ;
2004-02-02 23:34:39 +00:00
}
echo " </tr> \n " ;
}
2006-06-16 23:53:56 +00:00
/**
* End the forum table , currently just close the open table tag .
**/
2004-02-02 23:34:39 +00:00
function end_forum_table () {
2004-12-18 18:13:46 +00:00
echo " </table> \n " ;
2004-02-02 23:34:39 +00:00
}
2006-06-16 23:53:56 +00:00
/**
* Output the forum / thread title .
**/
2007-05-13 18:41:34 +00:00
function show_forum_title ( $forum = NULL , $thread = NULL , $extended = true ) {
if ( $extended ) {
start_table_noborder ();
echo " <tr> \n " ;
2007-07-18 15:48:07 +00:00
2007-05-13 18:41:34 +00:00
// Search
echo " <td><form action= \" forum_search_action.php \" method= \" POST \" >
< input type = \ " hidden \" name= \" search_max_time \" value= \" 30 \" >
< input type = \ " hidden \" name= \" search_forum \" value= \" -1 \" >
< input type = \ " hidden \" name= \" search_sort \" value= \" 5 \" >
< input type = \ " text \" name= \" search_keywords \" >
2007-11-01 17:54:44 +00:00
< input class = \ " btn \" title= \" Search for words in forum messages \" type= \" submit \" value= \" Search forums \" ><br>
2007-11-02 15:57:19 +00:00
< span class = \ " smalltext \" ><a href= \" forum_search.php \" >Advanced search</a></span>
2007-05-13 18:41:34 +00:00
</ form >
" ;
2007-04-29 14:22:28 +00:00
echo " </td> \n " ;
2007-07-18 15:48:07 +00:00
2007-05-13 18:41:34 +00:00
$logged_in_user = get_logged_in_user ( false );
// Custom stuff for logged in user
if ( $logged_in_user ) {
echo " <td align= \" right \" > \n " ;
// Private messages
2007-10-31 23:50:21 +00:00
echo " <p> " , pm_notification ( $logged_in_user );
2007-05-13 18:41:34 +00:00
echo " </td> \n " ;
}
echo " </tr> \n " ;
end_table ();
2007-04-29 14:22:28 +00:00
}
2004-02-02 23:34:39 +00:00
echo " <p> \n " ;
2006-08-09 19:12:54 +00:00
if ( $forum ) {
$category = $forum -> getCategory ();
$is_helpdesk = $category -> getType ();
} else {
$is_helpdesk = false ;
}
2007-11-02 14:43:02 +00:00
$where = $is_helpdesk ? tra ( " Questions and Answers " ) : tra ( " Message boards " );
2006-08-09 19:12:54 +00:00
$top_url = $is_helpdesk ? " forum_help_desk.php " : " forum_index.php " ;
2004-02-02 23:34:39 +00:00
if ( ! $forum && ! $thread ) {
echo " <p class= \" title \" > " ;
2006-07-12 16:18:12 +00:00
echo $where ;
2006-06-16 23:53:56 +00:00
2004-02-02 23:34:39 +00:00
} else if ( $forum && ! $thread ) {
echo " <span class=title> " ;
2006-07-12 16:18:12 +00:00
echo " <a href= \" $top_url\ " > $where </ a > : " ;
2006-06-16 23:53:56 +00:00
echo $forum -> getTitle ();
2004-02-02 23:34:39 +00:00
echo " </span><br> " ;
} else if ( $forum && $thread ) {
echo " <span class=title> " ;
2006-07-12 16:18:12 +00:00
echo " <a href= \" $top_url\ " > $where </ a > : " ;
2006-06-16 23:53:56 +00:00
echo " <a href= \" forum_forum.php?id= " . $forum -> getID () . " \" > " , $forum -> getTitle (), " </a> : " ;
echo cleanup_title ( $thread -> getTitle ());
2004-02-02 23:34:39 +00:00
echo " </span><br> " ;
} else {
2006-06-16 23:53:56 +00:00
echo " Invalid input to show_forum_title<br> " ; // TODO: handle this condition gracefully
2004-02-02 23:34:39 +00:00
}
echo " </p> \n " ;
}
2006-06-16 23:53:56 +00:00
/**
* show a thread with its context ( e . g . for search results )
**/
2004-02-02 23:34:39 +00:00
function show_thread ( $thread , $n ) {
$forum = getForum ( $thread -> forum );
$category = getCategory ( $forum -> category );
$first_post = getFirstPost ( $thread -> id );
2005-01-09 21:52:22 +00:00
$title = cleanup_title ( $thread -> title );
2004-02-02 23:34:39 +00:00
$where = $category -> is_helpdesk ? " Questions and answers " : " Message boards " ;
2004-05-31 19:15:23 +00:00
$top_url = $category -> is_helpdesk ? " forum_help_desk.php " : " forum_index.php " ;
2004-02-02 23:34:39 +00:00
$excerpt = sub_sentence ( stripslashes ( $first_post -> content ), ' ' , EXCERPT_LENGTH , true );
$posted = time_diff_str ( $thread -> create_time , time ());
$last = time_diff_str ( $thread -> timestamp , time ());
$m = $n % 2 ;
echo "
2004-12-18 18:13:46 +00:00
< tr class = \ " row $m\ " >
< td >< font size = \ " -2 \" >
2004-02-02 23:34:39 +00:00
$n ) Posted $posted
< br >
Last response $last
</ td >
< td valign = top >
2004-12-18 18:13:46 +00:00
< a href = \ " $top_url\ " > $where </ a > : $category -> name :
< a href = \ " forum_forum.php?id= $forum->id\ " > $forum -> title </ a > :
< a href = \ " forum_thread.php?id= $thread->id\ " > $title </ a >
2004-02-02 23:34:39 +00:00
< br >
2004-12-18 18:13:46 +00:00
< font size = \ " -2 \" > $excerpt </font>
2004-02-02 23:34:39 +00:00
</ td >
</ tr >
" ;
}
2006-06-16 23:53:56 +00:00
/**
* Show a post with its context ( e . g . for search results )
**/
2005-09-20 17:54:52 +00:00
function show_post2 ( $post , $n ) {
$thread = getThread ( $post -> thread );
2004-02-02 23:34:39 +00:00
$forum = getForum ( $thread -> forum );
$category = getCategory ( $forum -> category );
$where = $category -> is_helpdesk ? " Questions and answers " : " Message boards " ;
2004-05-31 19:15:23 +00:00
$top_url = $category -> is_helpdesk ? " forum_help_desk.php " : " forum_index.php " ;
2005-05-13 19:11:04 +00:00
$content = output_transform ( $post -> content );
2004-02-02 23:34:39 +00:00
$when = time_diff_str ( $post -> timestamp , time ());
$user = lookup_user_id ( $post -> user );
2005-01-09 21:52:22 +00:00
$title = cleanup_title ( $thread -> title );
2004-02-02 23:34:39 +00:00
$m = $n % 2 ;
2007-07-18 15:48:07 +00:00
if ( $post -> hidden ) {
2007-07-02 14:15:28 +00:00
$deleted = " <br><font color=red>[Deleted by a moderator]</font> " ;
2005-01-23 10:05:15 +00:00
} else {
$deleted = " " ;
2005-09-20 17:54:52 +00:00
}
2004-02-02 23:34:39 +00:00
echo "
< tr class = row $m >
< td >
2004-12-18 18:13:46 +00:00
$n ) < a href = \ " $top_url\ " > $where </ a > : $category -> name :
< a href = \ " forum_forum.php?id= $forum->id\ " > $forum -> title </ a > :
< a href = \ " forum_thread.php?id= $thread->id\ " > $title </ a >
2007-07-02 14:15:28 +00:00
( < a href = \ " forum_thread.php?id= " . $thread -> id . " &nowrap=true# " . $post -> id . " \" >Message " . $post -> id . " </a>)
2004-02-02 23:34:39 +00:00
< br >
2005-01-23 10:05:15 +00:00
Posted $when by $user -> name $deleted
2004-02-02 23:34:39 +00:00
< hr >
$content
</ td >
</ tr >
" ;
}
2004-05-24 03:40:38 +00:00
2006-06-16 23:53:56 +00:00
function post_rules () {
return "
2006-06-12 18:53:09 +00:00
< ul >
2006-09-25 18:51:50 +00:00
< li > Posts must be 'kid friendly' : they may not contain
content that is obscene , hate - related ,
sexually explicit or suggestive .
2006-06-12 18:53:09 +00:00
< li > No commercial advertisements .
2006-09-25 18:51:50 +00:00
< li > No links to web sites involving sexual content ,
gambling , or intolerance of others .
< li > No messages intended to annoy or antagonize other people ,
or to hijack a thread .
2006-06-12 18:53:09 +00:00
< li > No messages that are deliberately hostile or insulting .
< li > No abusive comments involving race , religion ,
2006-09-25 18:51:50 +00:00
nationality , gender , class or sexuality .
2006-06-12 18:53:09 +00:00
</ ul >
2006-06-16 23:53:56 +00:00
" ;
}
function post_warning () {
return " <br><br>
< table >< tr >< td >
< font size =- 2 >
Rules :
" .post_rules(). "
2006-06-12 18:53:09 +00:00
< a href = moderation . php > More info </ a >
</ font >
</ td ></ tr ></ table >
2005-02-16 00:24:53 +00:00
" ;
}
2006-08-08 20:32:37 +00:00
function check_banished ( $user ) {
$x = $user -> getBanishedUntil ();
if ( $x > time ()) {
error_page (
" You may not post or rate messages until " . gmdate ( 'M j, Y' , $x )
);
}
}
2006-12-29 20:57:29 +00:00
function can_reply ( $thread , $user ) {
if ( ! $thread -> isLocked () || ( $user && $user -> isSpecialUser ( S_MODERATOR ))) {
return true ;
} else {
return false ;
}
}
2004-02-02 23:34:39 +00:00
?>