convert_time($Posted,$offset,$timeformat); // ---------------- // Folder or icon? $alt = ""; $imagesize = $images['icons']; if (isset($_SESSION['topicread'][$Main])) { $unreadcheck = $_SESSION['topicread'][$Main]; } else { $unreadcheck = $unread; } if ($Posted > $unreadcheck) { $isnew = 1; $alt = "*"; $specialicon = "newfolder.gif"; } else { $isnew = 0; $alt = "."; $specialicon = "nonewfolder.gif"; } if ($topiclock) { $icon = "lock.gif"; } // --------------------------------------- // If it isn't approved we need to mark it if ($Approved == "no") { $Subject = "({$ubbt_lang['NOT_APPROVED']}) $Subject"; } if ($Reged == "n") { // ------------------------------------------------------------------ // If we aren't allowing anon users to choose their own username then // we display the basic anon user in the user's selected lang if (!$config['anonnames']){ $Username = $ubbt_lang['ANON_TEXT']; } else { $Username = $anonname; } } else { $PUsername = $Username; if ($Color) { $PUsername = "$PUsername"; } // --------------------------------------------------------- // We need to know if this was made by an admin or moderator if ($UserStatus == "Administrator") { if (!$Color) { $PUsername = "$PUsername"; } $UserStatus = "\"{$ubbt_lang['USER_ADMIN']}\""; } elseif (($UserStatus == "Moderator") && (stristr($modlist,",$Uid,"))) { if (!$Color) { $PUsername = "$PUsername"; } $UserStatus = "\"{$ubbt_lang['USER_MOD']}\""; } else { $UserStatus = ""; } $Username = "$PUsername"; } // Setup the postrow array $thiscolor = $color; if ($isnew) { $thiscolor = "new$color"; } $postrow[$z]['color'] = $thiscolor; $postrow[$z]['indentsize'] = $indentsize; $postrow[$z]['icon'] = "blank.gif"; $postrow[$z]['imagesize'] = $imagesize; $postrow[$z]['Number'] = $PNumber; $postrow[$z]['Subject'] = " $Subject"; $postrow[$z]['Username'] = $Username; $postrow[$z]['UserStatus'] = $UserStatus; $postrow[$z]['Views'] = " "; $postrow[$z]['Replies'] = " "; $postrow[$z]['time'] = $time; $postrow[$z]['pageprint'] = ""; $postrow[$z]['UserNumber'] = $Uid; $postrow[$z]['goto'] = "#Post{$PNumber}"; $postrow[$z]['Rating'] = ""; $postrow[$z]['lastposter'] = ""; $postrow[$z]['specialicon'] = "blank.gif"; $postrow[$z]['announce'] = "0"; if ($Sticky == '2') { $postrow[$z]['announce'] = "$Board"; } $postrow[$z]['newreplies'] = ""; // -------------------- // alternate the colors //$color = $html -> switch_colors($color); $indent++; if (isset($tree[$PNumber]['children'])) { $color = show_replies($Cat,$PNumber,$Board,$indent,$unread,$read,$color,$page,$view,$sb,$sort,$Viewable,$offset,$C,$mode,$o,$PNumber,$user['U_TimeFormat'],$Main,$Sticky,$topiclock); } } $indent--; return $color; } // -------------------------------- // END OF THE SHOW_REPLIES FUNCTION // ----------------- // Get the user info $html = new html; $userob = new user; $user = $userob -> authenticate("U_Display, U_Groups, U_View, U_PostsPer, U_FlatPosts, U_TimeOffset,U_TimeFormat,U_LastOn"); $Username = $user['U_Username']; isset($user['U_Display']) && $mode = $user['U_Display']; isset($user['U_Groups']) && $Groups = $user['U_Groups']; isset($user['U_View']) && $userview = $user['U_View']; isset($user['U_StyleSheet']) && $mystyle = $user['U_StyleSheet']; isset($user['U_PostsPer']) && $PostsPer = $user['U_PostsPer']; isset($user['U_Status']) && $userstatus = $user['U_Status']; isset($user['U_TimeOffset']) && $useroffset = $user['U_TimeOffset']; !isset($user['U_TimeFormat']) && $user['U_TimeFormat'] = $theme['timeformat']; // If they are a moderator, grab their moderator permissions if ($user['U_Status'] == "Moderator") { $modperms = $userob->get_mod_perms($user['U_Number']); } else { $modperms = array(); } // --------------------- // Grab the tablewrapper list($tbopen,$tbclose) = $html -> table_wrapper(); // -------------------------------- // Get some default display options if (empty($user['U_FlatPosts'])) { $user['U_FlatPosts'] = $theme['flatposts']; } // Postrow array key holder $z=0; // -------------------------------------- // Do we link to showthreaded or showflat if (!$mode) { $mode = $theme['postlist']; } $mode = "show$mode"; // ---------------------------------------------------------------- // If they are logged in then we check their groups, otherwise they // get set to the guest group if (!$Groups) { $Groups = "-4-"; } // -------------------------- // Set the default sort order if ($sb && !is_numeric($sb)) { $sb = 5; } if(empty($sb) && !isset($_SESSION['myprefs']['sort'])) { $sb = 5; } // ------------------------------------ // Check for default hot topic settings if (!isset($config['hot_views'])) { $config['hot_views'] = "100"; } if (!isset($config['hot_replies'])) { $config['hot_replies'] = "10"; } // ------------------------------------------------------- // If $view isn't set then it gets set to the default view if ( (empty($view)) && ($userview) ) { $view = $user['U_View']; } elseif ( (empty($view)) && (!$userview) ) { $view = $theme['threaded']; } // ---------------------------------------- // If $page isn't set then it defaults to 0 if (empty($page)) { $page = 0; } // -------------------------------------------------------------- // Let's make sure they are supposed to be looking at this board $Grouparray = split("-",$Groups); $gsize = sizeof($Grouparray); $groupquery = "AND ("; $g = 0; for ($i=0; $i<$gsize;$i++) { if (!preg_match("/[0-9]/",$Grouparray[$i])) { continue; }; $g++; if ($g > 1) { $groupquery .= " OR "; } $groupquery .= "Bo_Read_Perm LIKE '%-$Grouparray[$i]-%'"; } $groupquery .= ")"; // ------------------- // Grab the board info $Board_q = addslashes($Board); $query = " SELECT Bo_Title,Bo_Last,Bo_Read_Perm,Bo_Write_Perm,Bo_Moderated,Bo_Cat,Bo_CatName,Bo_ThreadAge,Bo_Reply_Perm,Bo_HTML,Bo_Markup,Bo_SpecialHeader,Bo_StyleSheet,Bo_Number,Bo_Threads FROM {$config['tbprefix']}Boards WHERE Bo_Keyword = '$Board_q' AND Bo_Active = '1' $groupquery "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); $rows = $dbh -> fetch_array($sth); list($Title,$Last,$CanRead,$CanWrite,$Moderated,$C,$CatName,$ThreadAge,$CanReply,$HTML,$Markup,$fheader,$fstyle,$bonumber,$totaltopics) = $rows; $dbh -> finish_sth($rows); if (!$Title) { $html -> not_right($ubbt_lang['BAD_GROUP'],$Cat); } // If this is a visit to a new forum then we need // to track any preferences for this forum $updatemyprefs = 0; if ((!isset($_SESSION['myprefs']['Board'])) || ($_SESSION['myprefs']['Board'] != $Board)) { $_SESSION['myprefs']['Board'] = $Board; $_SESSION['myprefs']['age'] = $ThreadAge; $_SESSION['myprefs']['sort'] = 5; $_SESSION['myprefs']['view'] = $view; $updatemyprefs = 1; } else { if (($o) && ($_SESSION['myprefs']['age'] != $o)) { $_SESSION['myprefs']['age'] = $o; $updatemyprefs = 1; } if (($sb) && ($_SESSION['myprefs']['sort'] != $sb)) { $_SESSION['myprefs']['sort'] = $sb; $updatemyprefs = 1; } if (($view) && ($_SESSION['myprefs']['view'] != $view)) { $_SESSION['myprefs']['view'] = $view; $updatemyprefs = 1; } } $sb = $_SESSION['myprefs']['sort']; $o = $_SESSION['myprefs']['age']; // $_SESSION['myprefs'] = $myprefs; // ---------------------------------- // Grab all moderators for this board $query = " SELECT t1.Mod_Uid,t2.U_Username FROM {$config['tbprefix']}Moderators AS t1, {$config['tbprefix']}Users AS t2 WHERE t1.Mod_Board='$Board_q' AND t1.Mod_Uid = t2.U_Number "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); $modlist = ","; while (list($modid,$modname) = $dbh -> fetch_array($sth)) { $moderator[$modid] = $modname; $modlist .="$modid,"; } // ------------------------------------------------- // Here we need to figure out what stylesheet to use if (!$mystyle) { $mystyle = "usedefault"; } if ($mystyle == "usedefault") { $mystyle = $fstyle; if ($mystyle == "usedefault") { $mystyle = $theme['stylesheet']; } } // fstyle will now be a global variable to use in send_header $fstyle = $mystyle; // --------------------- // Give them the jump box $jumpbox = $html -> jump_box($Cat,$groupquery,$Board); // Let's see if the can post or reply $replyperm = $ubbt_lang['CANTREPLY']; $writeperm = $ubbt_lang['CANTWRITE']; for ($i=0; $i<$gsize; $i++) { if (strstr($CanReply,"-$Grouparray[$i]-") ) { $replyperm = $ubbt_lang['CANREPLY']; $canreply = 1; } if (strstr($CanWrite,"-$Grouparray[$i]-") ) { $writeperm = $ubbt_lang['CANWRITE']; $canwrite = 1; } if (($canwrite) && ($canreply)) { break; } } if ($Markup == "On") { $ubbcode = "{$ubbt_lang['UBBCODE']} {$ubbt_lang['ENABLED']}"; } else { $ubbcode = "{$ubbt_lang['UBBCODE']} {$ubbt_lang['DISABLED']}"; } if ($HTML == "On") { $htmlcode = "{$ubbt_lang['HTMLIS']} {$ubbt_lang['ENABLED']}"; } else { $htmlcode = "{$ubbt_lang['HTMLIS']} {$ubbt_lang['DISABLED']}"; } // --------------------------------------- // How old of threads should we be showing if (!isset($o)) { if (!$o) { $o = $ThreadAge; } } if ( (!empty($o)) && ($o != "all") ) { $time = $html -> get_date(); $time = $time - ($o * 86400); $activethread = "AND t1.B_Last_Post > $time"; } if (empty($o)) { $o = ""; } if ($o == "1") { $d1 = "selected=\"selected\""; } elseif ($o == 2) { $d2 = "selected=\"selected\""; } elseif ($o == 7) { $w1 = "selected=\"selected\""; } elseif ($o == 14) { $w2 = "selected=\"selected\""; } elseif ($o == 21) { $w3 = "selected=\"selected\""; } elseif ($o == 31) { $m1 = "selected=\"selected\""; } elseif ($o == 93) { $m3 = "selected=\"selected\""; } elseif ($o == 186) { $m6 = "selected=\"selected\""; } elseif ($o == 365) { $y1 = "selected=\"selected\""; } else { $allofthem = "selected=\"selected\""; } // The forumvisit['visit']['boardname'] array holds the real last visit time // for each forum // The forumvisit['boardname'] array holds the first visit time for each // forum for this particular session. if (!is_array($_SESSION['forumvisit']['visit'])) { $_SESSION['forumvisit']['lastonline'] = $user['U_LastOn']; if ($user['U_Number']) { $query = " SELECT L_Last,L_Board FROM {$config['tbprefix']}Last WHERE L_Uid = '{$user['U_Number']}' "; $sth = $dbh->do_query($query,__LINE__,__FILE__); while(list($l_last,$l_board) = $dbh->fetch_array($sth)) { $_SESSION['forumvisit']['visit'][$l_board] = $l_last; } } } // ------------------------------------------------------------ // Set up some stuff so we know what the last post they saw was // and update this to the current last post of the board $Username_q = addslashes($Username); $rightnow = $html->get_date(); if (isset($_SESSION['forumvisit'][$Board])) { $unread = $_SESSION['forumvisit'][$Board]; } elseif (isset($_SESSION['forumvisit']['visit'][$Board])) { $unread = $_SESSION['forumvisit']['visit'][$Board]; $_SESSION['forumvisit'][$Board] = $_SESSION['forumvisit']['visit'][$Board]; $updatelast = 1; } else { if ($user['U_LastOn']) { $unread = $user['U_LastOn']; } else { $unread = $rightnow; } } // Update their last visit time stamp to this forum for the main forum listing $_SESSION['forumvisit']['visit'][$Board] = $html->get_date(); // $_SESSION['forumvisit'] = $forumvisit; // ------------------ // Send a html header $html -> send_header("{$ubbt_lang['VIEWFORUM']} $Title",$Cat,0,$user,$Board,$CanRead); // Find out how many are browsing this forum $query = " SELECT O_Type,O_Board,COUNT(*) FROM {$config['tbprefix']}Online WHERE O_Board = '$Board_q' GROUP BY O_Type "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); $a = "0"; $r = "0"; while (list($Type,$Extra,$count) = $dbh -> fetch_array($sth)) { ${$Type} = $count; } // ------------------------- // Set up some sorting stuff if ($sb == 1) { $SubjectS = "\"\""; } elseif ($sb == 2) { $SubjectS = "\"\""; } elseif ($sb == 3) { $PosterS = "\"\""; } elseif ($sb == 4) { $PosterS = "\"\""; } elseif ($sb == 5) { $LastS = "\"\""; } elseif ($sb == 6) { $LastS = "\"\""; } elseif ($sb == 7) { $ViewsS = "\"\""; } elseif ($sb == 8) { $ViewsS = "\"\""; } elseif ($sb == 9) { $RepliesS = "\"\""; } elseif ($sb == 10) { $RepliesS = "\"\""; } elseif ($sb == 11) { $RatingS = "\"\""; } elseif ($sb == 12) { $RatingS = "\"\""; } // --------------------------------------------------------------------- // We need to check and see if they have write privileges for this forum $gsize = sizeof($Grouparray); for ($i=0; $i <$gsize; $i++) { if (strstr($CanWrite,"-$Grouparray[$i]-") ) { $makepost = "yes"; break; } } if ($makepost == "yes") { $newpoststart = ""; $postoption = "newpost.gif"; $newpoststop = ""; } else { $postoption = "greynewpost.gif"; } // --------------------- // Set some sorting opts $sortsubject = 1; $sortposter = 3; $sortdate = 6; $sortviews = 7; $sortreplies = 9; $sortrating = 11; // ----------------------------------------------- // Make sure we are giving the proper sort options if ($sb == 1) { $sortsubject = 2; } else { $sortsubject = 1; } if ($sb == 3) { $sortposter = 4; } else { $sortposter = 3; } if ($sb == 5) { $sortdate = 6; } else { $sortdate = 5; } if ($sb == 7) { $sortviews = 8; } else { $sortviews = 7; } if ($sb == 9) { $sortreplies = 10; } else { $sortreplies = 9; } if ($sb == 11) { $sortrating = 12; } else { $sortrating = 11; } // -------------------------------------------------------------------- // If dateslip is on, we sort by Last_Post, otherwise we sort by Posted if (!$config['dateslip']) { $sort_opt = array( 1 => 't1.B_Subject DESC', 2 => 't1.B_Subject ASC', 3 => 't2.U_Username DESC', 4 => 't2.U_Username ASC', 5 => 't1.B_Posted DESC', 6 => 't1.B_Posted ASC', 7 => 't1.B_Counter DESC', 8 => 't1.B_Counter ASC', 9 => 't1.B_Replies DESC', 10 => 't1.B_Replies ASC', 11 => 't1.B_RealRating DESC', 12 => 't1.B_RealRating ASC' ); $sort_by = $sort_opt[$sb]; } else { $sort_opt = array( 1 => 't1.B_Subject DESC', 2 => 't1.B_Subject ASC', 3 => 't2.U_Username DESC', 4 => 't2.U_Username ASC', 5 => 't1.B_Last_Post DESC', 6 => 't1.B_Last_Post ASC', 7 => 't1.B_Counter DESC', 8 => 't1.B_Counter ASC', 9 => 't1.B_Replies DESC', 10 => 't1.B_Replies ASC', 11 => 't1.B_RealRating DESC', 12 => 't1.B_RealRating ASC' ); $sort_by = $sort_opt[$sb]; } // ----------------------------------------- // Find out how many posts to show per page if (!$PostsPer) { $PostsPer = $theme['postsperpage']; } // --------------------------------------------------------------------- // Now we calculate which posts to grab for this page. We want to grab // one from the previous page and one from the next page so we know what // the previous and nexts posts will be if (!($page > 0)) { $Totalgrab = $PostsPer + 1; $Posts = $PostsPer + 1; } else { $Startat = $page * $PostsPer; $Posts = $PostsPer + 1; $Totalgrab = "$Startat, $Posts"; } // --------------------------------------------------------------- // If they are a normal user then they can only see approved posts $t1Viewable = "AND t1.B_Approved = 'yes'"; $Viewable = "AND B_Approved = 'yes'"; if ($userstatus == "Administrator") { $Viewable = ""; $t1Viewable = ""; } if ($userstatus == "Moderator" && $modperms['P_CanApprovePosts']) { if (preg_match("/(,|^){$user['U_Number']}(,|$)/i",$modlist)) { $Viewable = ""; $t1Viewable = ""; } } // First stop, grab all posts from the announcements table that // we need to display in this forum. $stickies = ""; $totalstickies = 0; if (!$page || $page == 0) { $a_inlist = "('$Board_q','ubbt_all_forums')"; $query = " SELECT A_Topic FROM {$config['tbprefix']}Announcements WHERE A_Board IN $a_inlist "; $sth = $dbh->do_query($query,__LINE__,__FILE__); $stickies = ""; $totalstickies = 0; while(list($atopic) = $dbh->fetch_array($sth)) { $stickies .= "'$atopic',"; $totalstickies++; } } // If we got any stickes then we need to grab them first $result = array(); $totalstickies = 0; if ($stickies) { $stickies = preg_replace("/,$/","",$stickies); $query = " SELECT t1.B_Number,t1.B_Parent,t2.U_Username,t1.B_Posted,t1.B_Last_Post,t1.B_Subject,t1.B_Main,t1.B_Status,t1.B_Approved,t1.B_Icon,t1.B_Reged,t1.B_Counter,t1.B_Replies,t1.B_Rating,t1.B_Rates,t1.B_RealRating,t2.U_Color,t2.U_Status,t1.B_PosterId,t1.B_File,t2.U_Number,t1.B_Sticky,t1.B_AnonName,t1.B_LastPosterId,t1.B_LastPostNum,t1.B_Poll,t1.B_CalDay FROM {$config['tbprefix']}Posts AS t1, {$config['tbprefix']}Users AS t2 WHERE t1.B_Number IN ($stickies) AND t1.B_PosterId = t2.U_Number ORDER BY B_Sticky DESC, $sort_by "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); while($row = $dbh->fetch_array($sth)) { $result[] = $row; } $totalstickies = sizeof($result); $dbh->finish_sth($sth); $Totalgrab = $Totalgrab + sizeof($result); } // -------------------- // Setup the limit call $endpage = 1; $limit = "LIMIT $Totalgrab"; $query = " SELECT t1.B_Number,t1.B_Parent,t2.U_Username,t1.B_Posted,t1.B_Last_Post,t1.B_Subject,t1.B_Main,t1.B_Status,t1.B_Approved,t1.B_Icon,t1.B_Reged,t1.B_Counter,t1.B_Replies,t1.B_Rating,t1.B_Rates,t1.B_RealRating,t2.U_Color,t2.U_Status,t1.B_PosterId,t1.B_File,t2.U_Number,t1.B_Sticky,t1.B_AnonName,t1.B_LastPosterId,t1.B_LastPostNum,t1.B_Poll,t1.B_CalDay FROM {$config['tbprefix']}Posts AS t1, {$config['tbprefix']}Users AS t2 WHERE t1.B_Topic = 1 AND t1.B_Board = '$Board_q' AND t1.B_PosterId = t2.U_Number AND t1.B_Sticky = '0' $activethread $t1Viewable ORDER BY $sort_by $limit "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); while($row = $dbh->fetch_array($sth)) { $result[] = $row; } $nums = $dbh->total_rows($sth); $dbh->finish_sth($sth); // ------------------------------------------------------------------- // If $page is greater than 0 then we need a link to the previous page if ($page > 0) { $prev = $page - 1; $prevstart = ""; $prevoption = "previous.gif"; $prevstop = ""; } else { $prevoption = "greyprevious.gif"; } // ---------------------------------------------------------------------- // If total parent posts is greater than $PostsPer*Page then we give them // a link to the next page if ($nums >= ($PostsPer + 1) ) { $next = $page + 1; $nextstart = ""; $nextstop = ""; $nextoption = "next.gif"; } else { $nextoption = "greynext.gif"; } // ------------------------------------------------------------- // If $postlist is threaded then we need to give them the proper // button to expand or collapse the threads $changestart = ""; $changestop = ""; $changealt = ""; if ($view == "collapsed") { $changestart = ""; $changestop = ""; $changeoption = "expand.gif"; $changetext = $ubbt_lang['EXP_ICON']; $changealt = $ubbt_lang['TEXT_EXP']; } else { $changestart = ""; $changestop = ""; $changeoption = "collapse.gif"; $changetext = $ubbt_lang['COL_ICON']; $changealt = $ubbt_lang['TEXT_COLL']; } if ( ($config['dateslip']) && ($view != "expanded") ){ $datecolumn = $ubbt_lang['LAST_POST']; } else { $datecolumn = $ubbt_lang['POSTON_TEXT']; } // ---------------------------- // List the posts for this page $color = "lighttable"; for ($i=0; $i= $config['hot_replies'] || $Counter >= $config['hot_views']) { $icon = "hottopic.gif"; } // ---------------------------------------------------------- // If this post is sticky then we need to add a sticky icon if ($Sticky == 1) { $icon = "sticky.gif"; } if ($Sticky == 2) { $icon = "announce.gif"; } if ($view != "expanded") { $time = $html -> convert_time($Last_Post,$useroffset,$user['U_TimeFormat']); } else { $time = $html -> convert_time($Posted,$useroffset,$user['U_TimeFormat']); } $alt = ""; $newthread = ""; $imagesize = $images['icons']; if (isset($_SESSION['topicread'][$Main])) { $unreadcheck = $_SESSION['topicread'][$Main]; } else { $unreadcheck = $unread; } // Don't mark announcements as new in every forum $aread = 0; if ( (isset($Main,$_SESSION['topicread'])) && $Sticky == '2') { $aread = 1; } if (($Last_Post > $unreadcheck) && !$aread) { $updatelast = 1; $isnew = 1; $specialicon = "newfolder.gif"; $alt = "*"; $newthread = $unreadcheck; // If set in the config file, determine how many new replies there are in this // topic if ($config['newintopic'] && $Replies) { $query = " SELECT COUNT(*) FROM {$config['tbprefix']}Posts WHERE B_Main='$Number' AND B_Posted > '$unreadcheck' AND B_Topic != '1' "; $resultrow = $dbh->do_query($query,__LINE__,__FILE__); list($newreplies) = $dbh->fetch_array($resultrow); if ($newreplies) { $newreplies = "($newreplies)"; } } } else { $isnew = 0; $specialicon = "nonewfolder.gif"; $alt = "."; $newreplies = ""; } $topiclock = 0; if ($Open == "C") { if ($specialicon != "sticky.gif") { $topiclock = 1; $specialicon = "lock.gif"; } } if ($Open == "M") { $specialicon = "moved.gif"; } // ------------------------------------------------------------------- // If we are doing flat posts or the view is collapsed we need to list // the number of replies // We also need to do this before printing out the initial folder/icon // color so we can let the user know there are new messages in the thread $pagejump = 1; $postmarker = ""; $partnumber = ""; // ------------------------------------------------------ // If the post isn't approved we show it in the new color if ($Approved == "no") { $Subject = "({$ubbt_lang['NOT_APPROVED']}) $Subject"; } // ---------------------------------------------------------------- // If we are going to be viewing in flat mode, let's show all pages $pageprint = ""; if ( ($mode == "showflat") && ($Replies >= $user['U_FlatPosts']) && ($view == "collapsed")) { $pages = $Replies; if ($Replies <= $user['U_FlatPosts']) { $pages= $pages + 1; } if ($user['U_FlatPosts']) { $pages = ($pages) / $user['U_FlatPosts']; } $midprint = ""; if ($pages !=1) { $pageprint = "
( \"{$ubbt_lang['PAGE_TEXT']}\" "; for ($prints = 1; $prints < ($pages + 1 ); $prints++) { if ($pages > 9) { if ( ($prints < 5) || ($prints > ($pages - 2) ) ) { $pageprint .= "$prints "; } else { if (!$midprint) { $half = ($pages +1) / 2; @list($plink,$extra) = @split("\.",$half); $pageprint .= "... "; $midprint = 1; } } } else { $pageprint .= "$prints "; } } $pageprint .= "{$ubbt_lang['TEXT_ALL']} )
"; } } if ($Reged == "n") { // ------------------------------------------------------------------ // If we aren't allowing anon users to choose their own username then // we display the basic anon user in the user's selected lang if (!$config['anonnames']) { $Username = $ubbt_lang['ANON_TEXT']; } else { $Username = $anonname; } $UserStatus = ""; } else { $PUsername = $Username; if ($Color) { $PUsername = "$PUsername"; } // --------------------------------------------------------- // We need to know if this was made by an admin or moderator $UserStatus = ""; if ($PostStatus == "Administrator") { if (!$Color) { $PUsername = "$PUsername"; } $UserStatus = "\"{$ubbt_lang['USER_ADMIN']}\""; } elseif (($PostStatus == "Moderator") && (stristr($modlist,",$posterid,"))) { if (!$Color) { $PUsername = "$PUsername"; } $UserStatus = "\"{$ubbt_lang['USER_MOD']}\""; } else { $UserStatus = ""; } $Username = "$PUsername"; } $ThreadRating = " "; if ($stars) { $ThreadRating = ""; for ($x=1;$x<=$stars;$x++) { $ThreadRating .= "\"*\""; } } if (!$ThreadRating) { $ThreadRating = " "; } // Setup the postrow array if ($isnew) { $rowcolor = "new$color"; } else { $rowcolor = $color; } $postrow[$z]['color'] = $rowcolor; $postrow[$z]['indentsize'] = "0"; $postrow[$z]['icon'] = $icon; $postrow[$z]['specialicon'] = $specialicon; $postrow[$z]['imagesize'] = $imagesize; $postrow[$z]['Number'] = $Number; $postrow[$z]['goto'] = "#Post{$Number}"; if ($newthread) { $postrow[$z]['goto'] = "{$var_sep}gonew{$var_eq}1#UNREAD"; } $postrow[$z]['Subject'] = $Subject; $postrow[$z]['Username'] = $Username; $postrow[$z]['UserStatus'] = $UserStatus; $postrow[$z]['Views'] = $Counter; $postrow[$z]['Replies'] = $Replies; $postrow[$z]['time'] = $time; $postrow[$z]['pageprint'] = $pageprint; $postrow[$z]['Rating'] = $ThreadRating; $postrow[$z]['posterid'] = $posterid; $postrow[$z]['UserNumber'] = $UserNumber; $postrow[$z]['lastposter'] = ""; $postrow[$z]['announce'] = "0"; if ($Sticky == '2') { $postrow[$z]['announce'] = "$Board"; } if ($newreplies == "0") { $newreplies = ""; } $postrow[$z]['newreplies'] = $newreplies; // ------------------------------------------------------ // Setup an array to track the last poster on each thread if ($lastposterid) { if (!preg_match("/'$lastposterid'/",$lastposters)) { $lastposters .= "'$lastposterid',"; } $lparray[$postercount]['threadrow'] = $z; $lparray[$postercount]['lastposter'] = $lastposterid; $lparray[$postercount]['lastpostnum'] = $lastpostnum; $postercount++; } // --------------------------------------------------------------- // If we are not doing flat posts and the view is expanded then we // will list all the replies out in a threaded format $tree = array(); if ($view == "expanded") { $query = " SELECT t1.B_Number,t1.B_Parent,t1.B_Posted,t2.U_Username,t1.B_Subject,t1.B_Status,t1.B_Approved,t1.B_Icon,t1.B_Reged,t2.U_Color,t2.U_Status,t2.U_Number,t1.B_AnonName FROM {$config['tbprefix']}Posts AS t1, {$config['tbprefix']}Users AS t2 WHERE t1.B_Main = $Number AND t1.B_Number <> $Number AND t1.B_PosterId = t2.U_Number $Viewable ORDER BY t1.B_Number Desc "; $stj = $dbh -> do_query($query,__LINE__,__FILE__); $results = 0; while(list($anumber,$aparent,$aposted,$ausername,$asubject,$astatus,$aapproved,$aicon,$areged,$acolor,$austatus,$ausernumber,$aanonname) = $dbh -> fetch_array($stj)) { if ($aparent == 0) { $aparent = $Number; } $results = 1; $tree[$aparent][$anumber]['Uid'] = $ausernumber; $tree[$aparent][$anumber]['Posted'] = $aposted; $tree[$aparent][$anumber]['Username'] = $ausername; $tree[$aparent][$anumber]['Subject'] = $asubject; $tree[$aparent][$anumber]['Approved'] = $aapproved; $tree[$aparent][$anumber]['Icon'] = $aicon; $tree[$aparent][$anumber]['Reged'] = $areged; $tree[$aparent][$anumber]['Color'] = $acolor; $tree[$aparent][$anumber]['UserStatus'] = $austatus; $tree[$aparent][$anumber]['Number'] = $anumber; $tree[$aparent][$anumber]['Status'] = $astatus; $tree[$aparent][$anumber]['AnonName'] = $aanonname; } if ($results) { // Find out the number of replies to each parent $parentkeys = array_keys($tree); $parentsize = sizeof($parentkeys); for($x=0;$x<$parentsize;$x++) { $childkeys = array_keys($tree[$parentkeys[$x]]); $childsize = sizeof($childkeys); $tree[$parentkeys[$x]]['children'] = $childsize; } $color = show_replies($Cat,$Number,$Board,0,$unread,$read,$color,$page,$view,$sb,$sort,$Viewable,$user['U_TimeOffset'],$C,$mode,$o,$Number,$user['U_TimeFormat'],$Number,$Sticky,$topiclock); } } $z++; // -------------------- // alternate the colors $color = $html -> switch_colors($color); } $dbh -> finish_sth($sth); // ---------------------------------------------- // Figure out the last poster name on each thread if ($lastposters) { $lastposters = preg_replace("/,$/","",$lastposters); $query = " SELECT U_Number,U_Username FROM {$config['tbprefix']}Users WHERE U_Number IN ($lastposters) "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); while (list($pnumber,$pname) = $dbh -> fetch_array($sth)) { if ($pname == "**DONOTDELETE**") { $pname = $ubbt_lang['ANON_TEXT']; } $lastarray[$pnumber] = $pname; } for ($i=0; $i < $postercount; $i++) { $rownum = $lparray[$i]['threadrow']; $rowuser = $lparray[$i]['lastposter']; $postnum = $lparray[$i]['lastpostnum']; $postrow[$rownum]['lastposter'] = "{$ubbt_lang['TEXT_BY']} {$lastarray[$rowuser]}"; } } // ------------------------------------------- // Here is where we let them jump around pages // If this is a moderated board and this user is an admin or moderator // then we need to add the total # of unapproved topics to the count if ( ( ($user['U_Status'] == "Administrator") || (($user['U_Status'] == "Moderator") && ( (stristr($modlist,",{$user['U_Number']},")) && $modperms['P_CanApprovePosts']))) || $activethread) { $query = " SELECT COUNT(*) FROM {$config['tbprefix']}Posts AS t1 WHERE t1.B_Topic = 1 $activethread AND t1.B_Board='$Board_q' AND t1.B_Sticky='0' $t1Viewable "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($totaltopics) = $dbh -> fetch_array($sth); $dbh -> finish_sth($sth); } $Threads = $totaltopics + $totalstickies; $TotalP = ceil($Threads/$PostsPer); $pagejumpers = "{$ubbt_lang['PAGE_TEXT']}: "; $Startpage = $page - 5; $Endpage = $page + 5; if ($Startpage < 0) { $Endpage = $Endpage - $Startpage; $Startpage = 0; } if ($Endpage > $TotalP) { $Endpage = $TotalP; $Startpage = $Endpage - 10; } if ($Startpage < 0) { $Startpage = 0; } if ($Startpage > 0) { $midprint = intval($Startpage / 2) - 1; $pagejumpers .= "1 "; $pagejumpers .= "... "; } if ($Threads > $PostsPer) { for ($i = $Startpage; $i <= $Endpage; $i++) { $printedpage = $i + 1; if ($i == $page) { $pagejumpers .= "$printedpage "; } else { if ($printedpage <= $Endpage) { $pagejumpers .= "$printedpage "; } } } } else { $pagejumpers .= "1"; } if ($Endpage < $TotalP) { $Totalprint = $TotalP - 1; $midprint = $TotalP - intval(($TotalP - $Endpage) / 2); $pagejumpers .= "... "; $pagejumpers .= "$TotalP "; } $pagejumpers .= ""; // Only give the favorite board and subscribe links to users that have // logged in if ($user['U_Username']) { $favoriteboardlink = "{$ubbt_lang['FORUM_FAV']}
"; if ($config['subscriptions']) { $subscribeboardlink = "{$ubbt_lang['FORUM_SUB']}
"; } } $postrowsize = ""; if (isset($postrow)) { $postrowsize = sizeof($postrow); } // Moderators $modarray = split(",",$modlist); $modsize = sizeof($modarray); $comma =0; $modlist = ""; for ($i=0;$i<$modsize;$i++) { if ($modarray[$i]) { if ($comma) { $modlist .= ", "; } $modlist .= "{$moderator[$modarray[$i]]}"; $comma++; } else { $modlist .= " "; } } if ($updatelast) { $query = " REPLACE INTO {$config['tbprefix']}Last (L_Last,L_Board,L_Uid) VALUES ('$rightnow','$Board_q','{$user['U_Number']}') "; $dbh->do_query($query,__LINE__,__FILE__); } if (!$debug) { include ("$thispath/templates/$tempstyle/postlist.tmpl"); } // Send the footer $html -> send_footer(); ?>