special_user, $specialbit,1)==1); } /** * Check to see if a specific user has rated a specific post before **/ function getHasRated($user, $postid){ return (strstr($user->rated_posts,"|".$postid)); } /** * Get the user's preferred sorting style. **/ function getSortStyle($user,$place){ if ($user->id!=""){ list($forum,$thread,$faq,$answer)=explode("|",$user->sorting); } else { list($forum,$thread,$faq,$answer)=explode("|",$_COOKIE['sorting']); } return $$place; // Huh? } function should_show_post($logged_in_user, $postcount, $postnumber, $post, $sort_style, $last_visit){ $no_wraparound = get_str("nowrap",true); // 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; } /*** display functions ***/ /** * Show the posts in a thread for a user. * It's a big one. **/ function show_posts( $thread, $sort_style, $filter, $logged_in_user, $show_controls=true ) { $n = 1; $first_unread_post = null; $last_visit = 0; if ($show_controls) { $controls = FORUM_CONTROLS; } else { $controls = NO_CONTROLS; } // If logged in user is moderator, // let him see all posts - including hidden ones if ($logged_in_user && $logged_in_user->isSpecialUser(S_MODERATOR)){ $show_hidden_posts = true; } else { $show_hidden_posts = false; } $posts = $thread->getPosts($sort_style, $show_hidden_posts); $postcount = (sizeof($posts)-1); if ($logged_in_user) { $last_visit = $thread->getLastReadTimestamp($logged_in_user); } $postnumber=0; $previous_post=0; foreach ($posts as $key => $post){ $postnumber++; if (should_show_post($logged_in_user, $postcount, $postnumber, $post, $sort_style, $last_visit)){ if ($postnumber!=$previous_post+1){ //A number of posts were hidden, display a way to unhide them: echo " Only the first post and the last ".($logged_in_user->getDisplayWrapPostcount())." posts (of the ".($postcount+1)." posts in this thread) are displayed.
getID()."&nowrap=true\">Click here to also display the remaining posts."; } $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; } } } if ($logged_in_user && $logged_in_user->hasJumpToUnread()){ if ($first_unread_post){ echo ""; } else { echo ""; } } if ($logged_in_user) $thread->setLastReadTimestamp($logged_in_user); } /** * 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(); global $no_forum_rating; global $config; $tokens = ""; $rated_below_threshold = false; $rated_above_threshold = false; //If the user that made this post is on the list of people to ignore, // change thresholds to be much more strict // if ($logged_in_user){ $tokens = url_tokens($logged_in_user->getAuthenticator()); 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())); } } // 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) // $can_edit = false; if ($logged_in_user) { if ($user->getID() == $logged_in_user->getID()) { if ($logged_in_user->isSpecialUser(S_MODERATOR)) { $can_edit = true; } else if (can_reply($thread, $logged_in_user)) { $time_limit = $post->getTimestamp()+MAXIMUM_EDIT_TIME; $can_edit = time()<$time_limit; } else { $can_edit = false; } } } echo " getID()."\">
"; // Print the user links echo re_user_links($user, URL_BASE); echo "
"; // Print the special user lines, if any global $special_user_bitfield; $fstatus=""; $keys = array_keys($special_user_bitfield); for ($i=0; $iisSpecialUser($keys[$i])) { $fstatus.=$special_user_bitfield[$keys[$i]]."
"; } } if ($user->getCreateTime() > time()-ST_NEW_TIME) $fstatus.=ST_NEW."
"; if ($fstatus) echo "$fstatus"; echo ""; if (!$filter || !$rated_below_threshold){ if ($user->hasAvatar() && (!$logged_in_user || ($logged_in_user->hasHideAvatars()==false))) { echo "getAvatar()."\" alt=\"Avatar\">
"; } } $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()), "
"; 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()."
"; echo "ID: ".$user->getID()."
"; echo "Credit: ".number_format($user->getTotalCredit())."
"; echo "RAC: ".number_format($user->getExpavgCredit())."
"; } echo "
"; if ($controls == FORUM_CONTROLS) { echo ""; echo "
getID(), "\" method=\"post\">"; } else { echo ""; } if ($logged_in_user && $post->getTimestamp()>$thread->getLastReadTimestamp($logged_in_user)){ show_image(NEW_IMAGE, "You haven't read this message yet", NEW_IMAGE_HEIGHT); } if ($rated_above_threshold){ show_image(EMPHASIZE_IMAGE, "This message has a high average rating", EMPHASIZE_IMAGE_HEIGHT); } echo " getID()."&nowrap=true#$post->id\">Message ".$post->getID()." - "; if ($post->isHidden()) echo "[deleted] "; echo " Posted ", pretty_time_str($post->getTimestamp()); ; if ($post->getParentPostID()) { echo " - in response to getID()."&nowrap=true#".$post->getParentPostID()."\">Message ID ".$post->getParentPostID()."."; } 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 "
Last modified: ", pretty_time_Str($post->getModificationTimestamp()); } if ($rated_below_threshold && $filter){ if ($user_is_on_ignorelist) { $andtext=" and the user is on your ignore list"; } echo "
This post has been filtered (rating: ".($post->getRating()).")$andtext, press getID()."&filter=false#".$post->getID()."\">here to view this thread without filtering"; } echo "
"; echo ""; //If either filtering is turned off or this post is not below the threshold if (!$filter || !$rated_below_threshold){ $posttext = $post->getContent(); // 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 // if ($post->hasSignature() && (!$logged_in_user || !$logged_in_user->hasHideSignatures())){ $posttext.="\n____________\n".$user->getSignature(); } if ($logged_in_user){ $options = $logged_in_user->getTextTransformSettings(); } else { $options = new output_options; } $posttext = output_transform($posttext,$options); echo "

", $posttext, "

"; echo "ID: ", $post->id; if ($no_forum_rating != NULL) { echo " | getID()."\">"; show_image(REPORT_POST_IMAGE, "Report this post as offensive", REPORT_POST_IMAGE_HEIGHT); echo ""; } else { $rating = $post->getRating(); echo " | Rating: ", $rating, " | rate: getID()."&choice=p$tokens\"> "; show_image(RATE_POSITIVE_IMAGE, "Click if you like this message", RATE_POSITIVE_IMAGE_HEIGHT); echo " / getID()."&choice=n$tokens\">"; show_image(RATE_NEGATIVE_IMAGE, "Click if you don't like this message", RATE_NEGATIVE_IMAGE_HEIGHT); echo " getID()."\">"; show_image(REPORT_POST_IMAGE, "Report this post as offensive", REPORT_POST_IMAGE_HEIGHT); echo " "; } if (($controls == FORUM_CONTROLS) && (can_reply($thread, $logged_in_user))) { echo ""; $url = "forum_reply.php?thread=" . $thread->getID() . "&post=" . $post->getID() . "#input"; show_button($url, "Reply", "Post a reply to this message"); echo ""; } else { echo ""; } echo ""; } else { echo ""; } echo ""; } /*** utility functions ***/ /** * Start the forum table, output the proper headings and such. **/ function start_forum_table($headings, $extra="width=\"100%\"") { $span = null; start_table($extra." cellspacing=\"0\""); echo ""; for ($i=0; $i$title"; } echo "\n"; } /** * End the forum table, currently just close the open table tag. **/ function end_forum_table() { echo "\n"; } /** * Output the forum/thread title. **/ function show_forum_title($forum=NULL, $thread=NULL, $extended=true) { if ($extended) { start_table_noborder(); echo "\n"; // Search echo "

Advanced search
"; echo "\n"; $logged_in_user = get_logged_in_user(false); // Custom stuff for logged in user if ($logged_in_user) { echo "\n"; // Private messages echo "

", pm_notification($logged_in_user); echo "\n"; } echo "\n"; end_table(); } echo "

\n"; if ($forum) { $category = $forum->getCategory(); $is_helpdesk = $category->getType(); } else { $is_helpdesk = false; } $where = $is_helpdesk?tra("Questions and Answers"):tra("Message boards"); $top_url = $is_helpdesk?"forum_help_desk.php":"forum_index.php"; if (!$forum && !$thread) { echo "

"; echo $where; } else if ($forum && !$thread) { echo ""; echo "$where : "; echo $forum->getTitle(); echo "
"; } else if ($forum && $thread) { echo ""; echo "$where : "; echo "getID()."\">", $forum->getTitle(), " : "; echo cleanup_title($thread->getTitle()); echo "
"; } else { echo "Invalid input to show_forum_title
"; // TODO: handle this condition gracefully } echo "

\n"; } /** * show a thread with its context (e.g. for search results) **/ function show_thread($thread, $n) { $forum = getForum($thread->forum); $category = getCategory($forum->category); $first_post = getFirstPost($thread->id); $title = cleanup_title($thread->title); $where = $category->is_helpdesk?"Questions and answers":"Message boards"; $top_url = $category->is_helpdesk?"forum_help_desk.php":"forum_index.php"; $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 " $n) Posted $posted
Last response $last $where : $category->name : id\">$forum->title : id\">$title
$excerpt "; } /** * Show a post with its context (e.g. for search results) **/ function show_post2($post, $n) { $thread = getThread($post->thread); $forum = getForum($thread->forum); $category = getCategory($forum->category); $where = $category->is_helpdesk?"Questions and answers":"Message boards"; $top_url = $category->is_helpdesk?"forum_help_desk.php":"forum_index.php"; $content = output_transform($post->content); $when = time_diff_str($post->timestamp, time()); $user = lookup_user_id($post->user); $title = cleanup_title($thread->title); $m = $n%2; if ($post->hidden) { $deleted = "
[Deleted by a moderator]"; } else { $deleted = ""; } echo " $n) $where : $category->name : id\">$forum->title : id\">$title (id."&nowrap=true#".$post->id."\">Message ".$post->id.")
Posted $when by $user->name $deleted
$content "; } function post_rules() { return " "; } function post_warning() { return "

Rules: ".post_rules()." More info
"; } 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) ); } } function can_reply($thread, $user) { if (!$thread->isLocked() || ($user && $user->isSpecialUser(S_MODERATOR))) { return true; } else { return false; } } ?>