");
/**
* Process a user-supplied title to remove HTML stuff
**/
function cleanup_title($title) {
$x = trim(htmlspecialchars(strip_tags($title)));
$x = stripslashes($x); // clean up funky old titles in DB
if (strlen($x)==0) return "(no title)";
else return $x;
}
/**
* Check if user has special user bit enabled
**/
function isSpecialUser($user, $specialbit){
return (substr($user->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?
}
/*** 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;
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;
$no_wraparound = get_str("nowrap",true);
foreach ($posts as $key => $post){
$postnumber++;
// There *HAS* to be a better way to do this. WOW.
if ((!$logged_in_user) // If the user isn't logged in
|| (!$logged_in_user->getMinimumWrapPostcount()) //or If the user hasn't enabled the feature to display only a certain amount of posts, simply display all of them.
|| ($postcount <= $logged_in_user->getMinimumWrapPostcount()) //If it is enabled and we havent yet hit the limit, simply display all
|| ($no_wraparound) // If the user has asked to display all the posts just display them
||
(
($postcount > $logged_in_user->getMinimumWrapPostcount()) //If it is enabled and we have hit the limit AND we have the minimum wraparound number of posts or more
&&
(
($postnumber==1 || $postnumber==($postcount+1)) // Let's display the post only if it is the first post
||
(
(($postnumber > $postcount-$logged_in_user->getDisplayWrapPostcount()) //or it is one of the last wrap_display_postcount posts.
&& ($sort_style==CREATE_TIME_OLD))
||
(($postnumber <= $logged_in_user->getDisplayWrapPostcount()) //or it is one of the last wrap_display_postcount posts.
&& ($sort_style==CREATE_TIME_NEW))
|| ($sort_style!=CREATE_TIME_NEW && $sort_style!=CREATE_TIME_OLD)
)
|| ($post->getTimestamp() > $last_visit) //or if this post is unread
)
)
) {
if ($postnumber!=$previous_post+1){
//A number of posts were hidden, display a way to unhide them:
echo "
";
}
$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;
//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){
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 {
$time_limit = $post->getTimestamp()+MAXIMUM_EDIT_TIME;
$can_edit = time()<$time_limit;
}
}
}
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->create_time>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\"> ";
}
echo "Joined: ", gmdate('M j, Y', $user->getCreateTime()), " Posts: ".$user->getPostCount()." ";
}
// 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 "ID: ".$user->getID()." ";
echo "Credit: ".number_format($user->getTotalCredit())." ";
echo "RAC: ".number_format($user->getExpavgCredit())." ";
echo "
";
if ($controls == FORUM_CONTROLS) {
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 "
";
}
/*** utility functions ***/
/**
* Start the forum table, output the proper headings and such.
**/
function start_forum_table($headings, $extra="width=100%") {
start_table($extra." cellspacing=0 cellpadding=2");
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";
}
/**
* generate a "select" HTML element from an array of values
**/
function select_from_array($name, $array, $selection) {
$out= "";
return $out;
}
/**
* Call and output the above. Why is this a function, exactly?
**/
function show_select_from_array($name, $array, $selection) {
echo select_from_array($name,$array,$selection);
}
/**
* Output the forum/thread title.
**/
function show_forum_title($forum=NULL, $thread=NULL) {
echo "