authenticate("U_Display, U_Groups, U_PostsPer, U_PicturePosts, U_FlatPosts, U_TimeOffset,U_ShowSigs,U_TimeFormat,U_Ignored,U_SearchSession,U_Preview,U_TextCols,U_TextRows"); isset($user['U_Username']) && $Username = $user['U_Username']; isset($user['U_PicturePosts']) && $PicturePosts = $user['U_PicturePosts']; isset($user['U_Groups']) && $Groups = $user['U_Groups']; isset($user['U_StyleSheet']) && $mystyle = $user['U_StyleSheet']; isset($user['U_Status']) && $userstatus = $user['U_Status']; isset($user['U_FlatPosts']) && $Totaldisplay = $user['U_FlatPosts']; isset($user['U_Number']) && $usernumber = $user['U_Number']; isset($user['U_PostsPer']) && $PostsPer = $user['U_PostsPer']; isset($user['U_TimeOffset']) && $useroffset = $user['U_TimeOffset']; !isset($user['U_TimeFormat']) && $user['U_TimeFormat'] = $theme['timeformat']; isset($user['U_ShowSigs']) && $ShowSigs = $user['U_ShowSigs']; isset($user['U_TimeOffset']) && $toffset = $user['U_TimeOffset']; !isset($user['U_Ignored']) && $user['U_Ignored'] = ""; $html = new html; // If user is moderator we need to grab their moderator perms if ($user['U_Status'] == "Moderator") { $modperms = $userob -> get_mod_perms($user['U_Number']); } else { $modperms['P_CanMovePosts'] = ""; $modperms['P_CanDeletePosts'] = ""; $modperms['P_CanStickPosts'] = ""; $modperms['P_CanLockPosts'] = ""; $modperms['P_CanKeepPosts'] = ""; } // Default preview for quickreply screen if ($user['U_Preview'] == "on") { $Pselected = "checked=\"checked\""; } else { $Pselected = ""; } // Default textcols/textrows if (!$user['U_TextCols']) { $TextCols = $theme['TextCols']; } else { $TextCols = $user['U_TextCols']; } if (!$user['U_TextRows']) { $TextRows = $theme['TextRows']; } else { $TextRows = $user['U_TextRows']; } // ---------------------------------- // Grab the current day/month for birthdays date_default_timezone_set("UTC");//mlp $temp = getdate(); $month = $temp["mon"]; $day = $temp["mday"]; // ------------------------------------------------------------- // If we didn't find the main post, then this post doesn't exist if (!$Number || !is_numeric($Number)) { $html -> not_right($ubbt_lang['POST_PROB'],$Cat); } // ----------------------------------------- // Grab the main post number for this thread $query = " SELECT B_Main,B_Board,B_Last_Post,B_Sticky FROM {$config['tbprefix']}Posts WHERE B_Number = $Number "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list ($current,$Board,$lastpost,$announce) = $dbh -> fetch_array($sth); $dbh -> finish_sth($sth); // IF this is an announcement then we force $Board to the announcement value if ($an && $announce == 2) { $realboard = $Board; $Board = $an; } // 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; } } } // Grab the cookie or session to mark the posts as read or unread $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] = $rightnow; //$_SESSION['forumvisit'] = $forumvisit; // ----------------------------------------- // Timestamp for unread posts in this topic. if (isset($_SESSION['topicread'][$current])) { $newintopic = $_SESSION['topicread'][$current]; } else { $newintopic = $unread; } // ------------------------------------------------------------- // If we didn't get a board or number then we give them an error if (!$Board) { $html -> not_right($ubbt_lang['NO_B_INFO'],$Cat); } $Username_q = addslashes($Username); $Board_q = addslashes($Board); // ---------------------------------------------- // Set the default of viewing pictures with posts if (!$PicturePosts) { $PicturePosts = $theme['PicturePosts']; } // ---------------------------------------- // Need to figure out the active thread age $activethread = ""; if ( ($o) && ($o != "all") ) { $time = $html -> get_date(); $time = $time - ($o * 86400); $activethread = "AND B_Last_Post > $time"; } // ---------------------------------------------------------------- // If they are logged in then we check their groups, otherwise they // get set to the guest group if (!$Groups) { $Groups = "-4-"; } // -------------------------------------------------------------- // 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 .= ")"; // ------------------------------------------------ // Keep the current thread number for page linking $pagelinker = $current; // --------------------------- // Grab some forum information $query = " SELECT Bo_Title,Bo_Write_Perm,Bo_CatName,Bo_Cat,Bo_Reply_Perm,Bo_Read_Perm,Bo_Markup,Bo_HTML,Bo_SpecialHeader,Bo_StyleSheet FROM {$config['tbprefix']}Boards WHERE Bo_Keyword = '$Board_q' AND Bo_Active = '1' $groupquery "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($title,$CanWrite,$CatName,$CatNumber,$CanReply,$ReadPerm,$Markup,$HTML,$fheader,$fstyle) = $dbh -> fetch_array($sth); $dbh -> finish_sth($sth); // ---------------------------------- // 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__); $moderatorlist = ","; while (list($modid,$modname) = $dbh -> fetch_array($sth)) { $moderator[$modid] = $modname; $moderatorlist .="$modid,"; } if (!$title) { $html -> not_right($ubbt_lang['BAD_GROUP'],$Cat); } // ------------------------------------------------- // 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; // ---------------- // SHow moderators? $modarray = split(",",$moderatorlist); $modsize = sizeof($modarray); $comma =0; $modlist = ""; $modcheck = ","; for ($i=0;$i<$modsize;$i++) { if ($modarray[$i]) { if ($comma) { $modlist .= ", "; } $modcheck .= "{$modarray[$i]},"; $modlist .= "{$moderator[$modarray[$i]]}"; $comma++; } else { $modlist .= " "; } } // 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; } } $markupselect = ""; if ($Markup == "On") { $ubbcode = "{$ubbt_lang['UBBCODE']} {$ubbt_lang['ENABLED']}"; } else { $ubbcode = "{$ubbt_lang['UBBCODE']} {$ubbt_lang['DISABLED']}"; $markupselect = ""; } if ($HTML == "On") { $htmlcode = "{$ubbt_lang['HTMLIS']} {$ubbt_lang['ENABLED']}"; if ($Markup != "On") { $markupselect = ""; } } else { $htmlcode = "{$ubbt_lang['HTMLIS']} {$ubbt_lang['DISABLED']}"; } // --------------------------------------------------------------- // If they are a normal user then they can only see approved posts $ismod = "no"; $Viewable = "AND B_Approved = 'yes'"; if ($userstatus == "Administrator") { $Viewable = ""; } if ($userstatus == "Moderator") { // Check if they moderate this board if ((preg_match("/(,|^){$user['U_Number']}(,|$)/i",$moderatorlist)) && ($user['U_Number'])){ if ($modperms['P_CanApprovePosts']) { $Viewable = ""; } $ismod = "yes"; } } // ---------------------------------------------------- // If we don't have a post number then we can't view it if (!$Number) { $html -> not_right($ubbt_lang['POST_PROB'],$Cat); } // ------------------------------------------------------------ // If we are showing thread views, we need to update the counter if (empty($vc)) { $query = " UPDATE {$config['tbprefix']}Posts SET B_Counter = B_Counter + 1 WHERE B_Number = $current "; $dbh -> do_query($query,__LINE__,__FILE__); } if (!$Totaldisplay) { $Totaldisplay = $theme['flatposts']; } // -------------------------------- // Grab some info about this thread $query = " SELECT B_Replies,B_Counter,B_Last_Post,B_Subject,B_Rating,B_Rates,B_RealRating,B_Status,B_Kept,B_Sticky,B_CalDay,B_CalMonth,B_CalYear,B_Last_Post FROM {$config['tbprefix']}Posts WHERE B_Number = $current "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($checkreplies,$count,$posted,$tsubject,$Rating,$Rates,$stars,$threadstatus,$threadkept,$issticky,$calday,$calmonth,$calyear,$lastpost) = $dbh -> fetch_array($sth); $length = $checkreplies + 1; $ThreadRating = ""; if ($stars) { for ($x=1;$x<=$stars;$x++) { $ThreadRating .= "\"*\""; } } // ------------------------------------ // Let's see if they rated this thread $username_q = addslashes($Username); $query = " SELECT R_Rating FROM {$config['tbprefix']}Ratings WHERE R_What = '$current' AND R_Rater = '$usernumber' AND R_Type = 't' "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($myrating) = $dbh -> fetch_array($sth); // ----------------------------------- // Figure out what we need to display if (!$myrating) { $ratinghtml = << {$ubbt_lang['RATETHIS']}
EOF; } else { $ratinghtml = "{$ubbt_lang['YOURATED']} $myrating.
"; } // Move the new marker up a page if necessary if ($nt && ($fpart > $nt)) { $nt = $fpart; } // If we didn't get a fpart then we need to figure out what fpart // this post is on // If gonew is set then we need to figure out the first unread // post if ( (empty($fpart)) && ($length > $Totaldisplay) ) { if ($gonew) { $AND = "AND B_Posted <= '$newintopic'"; $adder = 1; } else { $AND = "AND B_Number <=$Number"; $adder = 0; } $query = " SELECT COUNT(*) FROM {$config['tbprefix']}Posts WHERE B_Main=$current $AND "; $sti = $dbh -> do_query($query,__LINE__,__FILE__); list($totalreplies) = $dbh -> fetch_array($sti); $totalreplies = $totalreplies + $adder; $fpart = ceil($totalreplies/$Totaldisplay); } if (!$fpart) { $fpart = 1; } if ($gonew && !$nt) { $nt = $fpart; } if (!$nt) { $nt = 999; } // -------------------- // Give the jumper box $jumpbox = $html -> jump_box($Cat,$groupquery,$Board); // Find out how many are browsing this forum $query = " SELECT O_Type,O_Board,COUNT(*) FROM {$config['tbprefix']}Online WHERE O_Board = '$Board' GROUP BY O_Type "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); $a = "0"; $r = "0"; while (list($Type,$Extra,$onlinecount) = $dbh -> fetch_array($sth)) { ${$Type} = $onlinecount; } // -------------------------------------------------------------------- // If dateslip is on, we sort by Last_Post, otherwise we sort by Posted if (!$config['dateslip']) { $sort_opt = array( 1 => 'B_Subject DESC', 2 => 'B_Subject ASC', 3 => 'U_Username DESC', 4 => 'U_Username ASC', 5 => 'B_Posted DESC', 6 => 'B_Posted ASC', 7 => 'B_Counter DESC', 8 => 'B_Counter ASC', 9 => 'B_Replies DESC', 10 => 'B_Replies ASC', 11 => 'B_RealRating DESC', 12 => 'B_RealRating ASC' ); $sort_by = $sort_opt[$sb]; } else { $sort_opt = array( 1 => 'B_Subject DESC', 2 => 'B_Subject ASC', 3 => 'U_Username DESC', 4 => 'U_Username ASC', 5 => 'B_Last_Post DESC', 6 => 'B_Last_Post ASC', 7 => 'B_Counter DESC', 8 => 'B_Counter ASC', 9 => 'B_Replies DESC', 10 => 'B_Replies ASC', 11 => 'B_RealRating DESC', 12 => 'B_RealRating ASC' ); $sort_by = $sort_opt[$sb]; } if ($Search != "true") { $currentlinkstart = ""; $currentlinkstop = ""; $prevlinkstart = ""; $prevoption = "previous.gif"; $prevlinkstop = ""; $linktext = $ubbt_lang['INDEX_ICON']; $alttext = $ubbt_lang['ALL_THREADS']; $nextlinkstart = ""; $nextoption = "next.gif"; $nextlinkstop = ""; } else { // ------------------------------------------------------ // Otherwise we came from the search so we can only return $nextoption = "greynext.gif"; $currentlinkstart = ""; $currentlinkstop = ""; $linktext = $ubbt_lang['SEARCH_ICON']; $prevoption = "greyprevious.gif"; } $dbh -> finish_sth($sth); // ------------------------------------------- // Let's see how many posts are in this thread $pages = ceil($length / $Totaldisplay); // Do we need to show new posts on pages afer this? $ntlink = ""; if ($nt && ($nt != 999)) { $ntlink = "{$var_sep}nt{$var_eq}$nt"; } if ($pages > 1) { $pageprint = "{$ubbt_lang['FLAT_PAGES']} "; $StartPage = $fpart - 10; $EndPage = $fpart + 10; if ($StartPage < 1) { $EndPage = $EndPage - $StartPage; $StartPage = 1; } if ($EndPage > $pages) { $EndPage = $pages; $StartPage = $EndPage - 20; } if ($StartPage < 1) { $StartPage = 1; } if ($StartPage > 1) { $prev = $StartPage - 1; $pageprint .= "<< "; } for ($i=$StartPage; $i<=$EndPage; $i++) { if ($i == $fpart) { $pageprint .= "$i | "; } else { $pageprint .= "$i | "; } } if ($EndPage > $fpart) { $next = $EndPage; $pageprint .= ">> "; } if ($fpart == "all") { $pageprint .= "({$ubbt_lang['SHOW_ALL_F']})"; } else { $pageprint .= "({$ubbt_lang['SHOW_ALL_F']})"; } $pageprint .= ""; } if (!$pageprint) { $pageprint = "{$ubbt_lang['FLAT_PAGES']} 1"; } // ------------------------------------------------- // Only certain options for users that are logged in if ($Username) { $addfavoption = " {$ubbt_lang['ADD_FAV']}
"; } // ----------------------------------------------------------------- // We need to know how many posts of this thread to display per page if ($fpart <= 1) { $Totalgrab = $Totaldisplay; } else { $Startat = $Totaldisplay * ($fpart - 1); $Totalgrab = "$Startat, $Totaldisplay"; } $Limit = "LIMIT $Totalgrab"; if ($fpart == "all") { $Limit = ""; } $threadnumber = $Number; // ----------------------- // Cycle through the posts $query = " SELECT t1.B_Number,t2.U_Username,t1.B_Posted,t1.B_IP,t1.B_Subject,t1.B_Body,t1.B_File,t1.B_Status,t1.B_Approved,t2.U_Picture,t1.B_Reged,t2.U_Title,t2.U_Color,t1.B_Icon,t1.B_Poll,t1.B_Parent,t2.U_Status,t2.U_Signature,t1.B_LastEdit,t1.B_LastEditBy,t2.U_Location,t2.U_TotalPosts,t2.U_Registered,t2.U_Rating,t2.U_Rates,t2.U_RealRating,t2.U_PicWidth,t2.U_PicHeight,t2.U_Number,t1.B_FileCounter,t1.B_AnonName,t1.B_ParentUser,t2.U_Birthday,t2.U_ShowBday,t1.B_AddSig FROM {$config['tbprefix']}Posts AS t1, {$config['tbprefix']}Users AS t2 WHERE t1.B_Main = $current AND t1.B_PosterId = t2.U_Number AND ( t2.U_Hideposts = 0 OR t2.U_Number = '{$user['U_Number']}' ) $Viewable ORDER BY B_Number $Limit "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); $totalthread = $dbh -> total_rows($sth); // Sometimes users's get directed to a page with no posts. When // this happens we redirect with a fpart value of one less if ((!$totalthread) && ($page)) { $query = " SELECT COUNT(*) FROM {$config['tbprefix']}Posts WHERE B_Main = '$current' "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($fixit) = $dbh -> fetch_array($sth); $fixit = $fixit - 1; $query = " UPDATE {$config['tbprefix']}Posts SET B_Replies = '$fixit' WHERE B_Number = '$current' "; $dbh -> do_query($query,__LINE__,__FILE__); $fpart = $fpart - 1; header("Location: {$config['phpurl']}/showflat.php{$var_start}Cat=$Cat&Board=$Board&Number=$Number&page=$page&fpart=$fpart"); exit; } $makepost = ""; $unread = 0; for ($i=0; $i <$totalthread; $i++) { list ($Number,$Username,$Posted,$IP,$Subject,$Body,$File,$Open,$Approved,$Picture,$Reged,$Title,$Color,$Icon,$Poll,$ParentPost,$PostStatus,$Signature,$LastEdit,$LastEditBy,$Location,$TotalPosts,$Registered,$Rating,$Rates,$stars,$picwidth,$picheight,$usernum,$downloads,$anonname,$ParentUser,$bday,$showbday,$addsig) = $dbh -> fetch_array($sth); $rateimage = ""; $postrow[$i] = ""; $postrow[$i]['Registered'] = ""; $postrow[$i]['Location'] = ""; $postrow[$i]['filelink'] = ""; $postrow[$i]['Rating'] = ""; $postrow[$i]['UserStatus'] = ""; $postrow[$i]['Picture'] = ""; $postrow[$i]['TotalPosts'] = ""; $postrow[$i]['Signature'] = ""; $postrow[$i]['replylink'] = ""; $postrow[$i]['editlink'] = ""; $postrow[$i]['quotelink'] = ""; $postrow[$i]['addfavlinkstart'] = ""; $postrow[$i]['addfavlinkstop'] = ""; $postrow[$i]['notifylinkstart'] = ""; $postrow[$i]['notifylinkstop'] = ""; $postrow[$i]['mailpostlink'] = ""; $postrow[$i]['replyto'] = ""; $postrow[$i]['ParentPost'] = $ParentPost; $postrow[$i]['unread'] = ""; // New posts in topic? if (($Posted > $newintopic) || (($fpart >= $nt) && !$gonew)) { if (!$nt) { $nt = $fpart; } if (!$unread) { $postrow[$i]['unread'] = ""; $unread = 1; } $postrow[$i]['subjectclass'] = "newsubjecttable"; $postrow[$i]['newimage'] = ""; $updatelast = 1; } else { $postrow[$i]['subjectclass'] = "subjecttable"; $postrow[$i]['newimage'] = ""; } if ( ($Reged == 'y') && ($usernum != 1)){ if (isset($Registered)) { $postrow[$i]['Registered'] = $html -> convert_time($Registered,$useroffset,$user['U_TimeFormat']); @list ($one,$two,$three,$four) = split(" ",$postrow[$i]['Registered']); if (stristr($three," ")) { list ($three,$four) = split(" ",$three); } if ($user['U_TimeFormat'] == "long") { $regedon = "$two $three $four"; } elseif ($user['U_TimeFormat'] == "short5") { $regedon = "$two"; } else { $regedon = "$one"; } $postrow[$i]['Registered'] = "{$ubbt_lang['REGED_ON']} $regedon"; } $postrow[$i]['TotalPosts'] = "{$ubbt_lang['POSTS_TEXT']}: $TotalPosts"; if ($Location) { if (strlen($Location) > 30) { $TitleText = $Location; $Location = substr($Location,0,30); $Location = "$Location... "; } $postrow[$i]['Location'] = "{$ubbt_lang['USER_LOC']} $Location"; } if ($Signature) { $Signature = str_replace("\n","
",$Signature); $Signature = "

--------------------
$Signature"; } if ($ShowSigs == "no" || !$addsig) { $Signature = ""; } if (!$config['sigimage']) { $Signature = preg_replace("/]*)\">/i","",$Signature); } // -------------------------- // Are we ignoring this user? if (!stristr($user['U_Ignored'],"-$usernum-")) { $postrow[$i]['Signature'] = $Signature; } // --------------------------------------------------------- // We need to know if this was made by an admin or moderator $postrow[$i]['UserStatus'] = ""; if ($PostStatus == "Administrator") { $postrow[$i]['UserStatus'] = "\"{$ubbt_lang['USER_ADMIN']}\""; } elseif ( ($PostStatus == "Moderator") && (stristr($modcheck,",$usernum,")) ) { $postrow[$i]['UserStatus'] = "\"{$ubbt_lang['USER_MOD']}\""; } if ( ($stars) && ($config['uratings'] == "1") ) { for ($x=1;$x<=$stars;$x++) { $rateimage .= "\"*\""; } $postrow[$i]['Rating'] = $rateimage; } if ( ($Picture) && ($Picture != "http://") && ( ($PicturePosts == 1) || ($PicturePosts == "on") ) ) { $picsize = ""; if ($picwidth && $picheight) { $picsize = "width=\"$picwidth\" height=\"$picheight\""; } else { $picsize = "width=\"{$theme['PictureWidth']}\" height=\"{$theme['PictureHeight']}\""; } $postrow[$i]['Picture'] = "\"\""; } else { $Picture = ""; } } $PrintLastEdit = ""; if ($LastEdit) { $LastEdit = $html -> convert_time($LastEdit,$toffset,$user['U_TimeFormat']); $PrintLastEdit = "

{$ubbt_lang['EDITED_BY']} $LastEditBy ($LastEdit)"; } $postrow[$i]['PrintLastEdit'] = $PrintLastEdit; $time = $html -> convert_time($Posted,$toffset,$user['U_TimeFormat']); $postrow[$i]['time'] = $time; $PUsername = $Username; if ($Color) { $PUsername = "$PUsername"; } if (($PostStatus == "Administrator") && (!$Color)) { $PUsername = "$PUsername"; } elseif (($PostStatus == "Moderator") && (!$Color)) { $PUsername = "$PUsername"; } // ------------------------------------------------------------------ // If we came from the search engine then we bold the search keywords if ($Search == "true") { $searchwords = str_replace(".","",$searchwords); $searchwords = preg_quote($Words); $searchwords = preg_replace("/\//","",$searchwords); $searchwords = split(" +",$searchwords); $size = sizeof($searchwords); for ($x=0; $x<$size; $x++) { if (!$searchwords[$x]) { continue; } $Body = @preg_replace("/($searchwords[$x])/i","\\1",$Body); $Body = preg_replace("/(<(a|img)\s*[^>]+)($searchwords[$x])<\/i><\/b>([^>]*>)/i","\\1\\3\\4",$Body); } } // ------------------------------------------ // Set both the reply and edit buttons to off $reply = "off"; $edit = "off"; // ------------------- // Can they post here? $gsize = sizeof($Grouparray); for ($y=0; $y <$gsize; $y++) { if ( (strstr($CanWrite,"-$Grouparray[$y]-") ) || (strstr($CanReply,"-$Grouparray[$y]-") ) ){ $makepost = "yes"; break; } } if ( ($makepost == "yes") && ($threadstatus != "C") && ($threadstatus != "M") ) { $reply = "on"; } // Only admins can reply to global announcements if ($issticky == '2' && ($user['U_Status'] != "Administrator")) { $reply = "off"; } // ----------------------------------------------------------- // If this thread has been moved we need to send them properly if ($Open == "M") { @list($NewBoard,$NewNumber,$Body) = split("-ML-",$Body); $Body = "{$ubbt_lang['POINTER']}$Body"; } // --------------------------- // Do they get an edit button? // First, determine if the edit window has passed (if one is configured) $edit_now = time(); $edit_window = $config['edittime'] * 60 * 60; // hours -> minutes -> seconds $edit_good_until = $Posted + $edit_window; $still_editable = !$config['edittime'] ? true : ( $edit_now < $edit_good_until ? true : false ) ; // Now check to see if the user is allowed to edit the post in the first place if ($user['U_Username'] && $Open != "M") { if ( ( ($user['U_Number'] == $usernum) && ($Open != 'C') && ($Open != 'M') && $still_editable ) || ( ($ismod == "yes") && ($modperms['P_CanEditPosts']) ) || ($user['U_Status'] == "Administrator") ) { $edit = "on"; } } // ------------------------- // Mark it if it isn't approved if ($Approved == "no") { $Subject = "({$ubbt_lang['NOT_APPROVED']}) $Subject"; } $postrow[$i]['Subject'] = "$Subject"; if (!$Icon) { $Icon = "blank.gif"; } $postrow[$i]['Icon'] = $Icon; // -------------------------------------------------------------- // If it is an anonymous post, don't give a link to their profile if ($Reged == "n") { if (!$config['anonnames']) { $Username = $ubbt_lang['ANON_TEXT']; } else { $Username = $anonname; } $Title = $ubbt_lang['UNREGED_USER']; } else { $Username = "$PUsername"; } // --------------------- // Is it their birthday? if ($showbday) { if (preg_match("/^$month\/$day\//",$bday)) { $Username = "\"{$ubbt_lang['HAPPYBDAY']}\" $Username"; } } $postrow[$i]['Username'] = $Username; $postrow[$i]['Title'] = $Title; if ( ($config['showip'] == 1) && $IP) { $postrow[$i]['IP'] = "($IP)"; } elseif ( ($config['showip'] == 2) && ( ($user['U_Status'] == "Administrator") || ($ismod=='yes') ) && ($IP) ) { $postrow[$i]['IP'] = "($IP)"; } elseif ( ($config['showip'] == 3) && ($user['U_Status'] == "Administrator") && ($IP) ) { $postrow[$i]['IP'] = "($IP)"; } else { $postrow[$i]['IP'] = ""; } if ($File) { $File = rawurlencode($File); if (!$downloads) { $downloads = "0"; } $postrow[$i]['filelink'] = "{$ubbt_lang['FILE_ATTACH']} ($downloads {$ubbt_lang['DOWNLOADS']})"; } // Edit Button? $postrow[$i]['editlinkstart'] = ""; $postrow[$i]['editlinkstop'] = ""; $postrow[$i]['editdisplay'] = ""; if ($edit == "on") { $postrow[$i]['editlinkstart'] = ""; $postrow[$i]['editlinkstop'] = ""; } else { $postrow[$i]['editdisplay'] = "style=\"display: none;\""; } // Reply and Quote Button? $postrow[$i]['replylinkstart'] = ""; $postrow[$i]['replylinkstop'] = ""; $postrow[$i]['postdisplay'] = ""; $postrow[$i]['quotelinkstart'] = ""; $postrow[$i]['quotelinkstop'] = ""; if ($reply == "on") { $postrow[$i]['replylinkstart'] = ""; $postrow[$i]['replylinkstop'] = ""; $postrow[$i]['quotelinkstart'] = ""; $postrow[$i]['quotelinkstop'] = ""; } else { $postrow[$i]['postdisplay'] = "style=\"display: none;\""; } // -------------------------------------------------------------------- // If there is a poll in this post, we need to include includepoll.php // or includepollresults.php depending on if they voted or not $postrow[$i]['showpoll'] = ""; if ($Poll) { $what = "showflat"; $voter = $user['U_Number']; // -------------------------- // Grab the main poll options $query = " SELECT P_Start,P_Stop,P_MustVote,P_NoResults FROM {$config['tbprefix']}PollMain WHERE P_Id = '$Poll' "; $sta = $dbh -> do_query($query,__LINE__,__FILE__); list($pstart,$pstop,$pmustvote,$pnoresults) = $dbh -> fetch_array($sta); // ------------------------------ // Let's see if they voted or not $currtime = $html -> get_date(); if ($config['whovote']) { $voter = find_environmental('REMOTE_ADDR'); } if ($pstop && ($currtime > $pstop)) { $check = 1; } else { $query = " SELECT P_Voter FROM {$config['tbprefix']}PollVotes WHERE P_PollId = '$Poll' AND P_Voter = '$voter' "; $sta = $dbh -> do_query($query,__LINE__,__FILE__); list($check) = $dbh -> fetch_array($sta); } if (!$check || ($pnoresults && ($currtime < $pstop) ) ) { include("$thispath/includepoll.php"); } else { include("$thispath/includepollresults.php"); } $postrow[$i]['showpoll'] = $showpoll; } // -------------------------- // Are we ignoring this user? if (stristr($user['U_Ignored'],"-$usernum-")) { $postrow[$i]['Body'] = $ubbt_lang['IGNORING']; } else { $postrow[$i]['Body'] = $Body; } // ------------------------------------------------- // Only certain options for users that are logged in $addfavlinkstart = ""; $addfavlinkstop = ""; $mailpostlink = ""; $notifylinkstart = ""; $notifylinkstop = ""; if ($user['U_Username']) { $postrow[$i]['addfavlinkstart'] = ""; $postrow[$i]['addfavlinkstop'] = ""; if ($config['mailpost']) { $postrow[$i]['mailpostlink'] = " \"{$ubbt_lang['EMAIL_POST']}\" "; } $postrow[$i]['notifylinkstart'] = ""; $postrow[$i]['notifylinkstop'] = ""; } $postrow[$i]['Number'] = $Number; $postrow[$i]['anonname'] = $anonname; if ($anonname) { $anonnames[$Number] = $anonname; } // ------------------------------------- // Need to setup a query for parentusers if ($ParentUser) { if (!preg_match("/'$ParentUser'/",$parentusers)) { $parentusers .= "'$ParentUser',"; } $replyarray[$replycount]['postrow'] = $i; $replyarray[$replycount]['parentuser'] = $ParentUser; $replycount++; } } $postrowsize = $i; if ($parentusers) { $parentusers = preg_replace("/,$/","",$parentusers); $query = " SELECT U_Number,U_Username FROM {$config['tbprefix']}Users WHERE U_Number IN ($parentusers) "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); while(list($pnumber,$pname) = $dbh -> fetch_array($sth)) { if ($pname == "**DONOTDELETE**") { $pname = $ubbt_lang['ANON_TEXT']; } $parentarray[$pnumber] = $pname; } for ($i=0;$i<$replycount;$i++) { $rownum = $replyarray[$i]['postrow']; $rowparent = $replyarray[$i]['parentuser']; $parentpost = $postrow[$rownum]['ParentPost']; if ( ($rowparent == 1) && ($anonnames[$parentpost]) ) { $parentarray[$rowparent] = $anonnames[$parentpost]; } $postrow[$rownum]['replyto'] = "[Re: {$parentarray[$rowparent]}]"; } } $dbh -> finish_sth($sth); // ----------------------------------- // Do they see the manage thread link? if ( ($user['U_Status'] == "Administrator") || ($ismod == "yes") ) { $managejump = "{$ubbt_lang['MANAGE_THREAD']}"; $manageoptions .= <<
{$ubbt_lang['MANAGE_THREAD']}  
"; } // ------------------------- // Is this a calendar event? $calevent = ""; if ($calday) { $caltime = $html -> convert_time(mktime(0,0,0,$calmonth,$calday,$calyear),0,$user['U_TimeFormat']); @list ($one,$two,$three,$four) = split(" ",$caltime); if (stristr($three," ")) { list ($three,$four) = split(" ",$three); } if ($user['U_TimeFormat'] == "long") { $caltime = "$two $three $four"; } elseif ($user['U_TimeFormat'] == "short5") { $caltime = "$two"; } else { $caltime = "$one"; } $calevent = "
{$ubbt_lang['IS_CAL_EVENT']}: $caltime"; } // ------------------------------------------------------------------- // If this is the first page and there are unread posts in this thread // give them a link to jump to that first unread post $toppageprint = $pageprint; if ($lastpost > $newintopic) { if (!$updatelast) { $newlink = "{$config['phpurl']}/showflat.php{$var_start}Cat{$var_eq}$Cat{$var_sep}Number{$var_eq}$Number{$var_sep}gonew{$var_eq}1#UNREAD"; } else { $newlink = "#UNREAD"; } $toppageprint = << {$ubbt_lang['JUMP_UNREAD']} $pageprint EOF; } // ---------------------------------------------------------- // If sb is empty then we know they didn't come from postlist // so we need to update their last visit but only do this // if there are new posts in this thread if (!$page && ($page != '0')){ if ($user['U_Number'] && $updatelast) { $query = " REPLACE INTO {$config['tbprefix']}Last (L_Last,L_Board,L_Uid) VALUES ('$rightnow','" .addslashes($Board) ."','{$user['U_Number']}') "; $dbh->do_query($query,__LINE__,__FILE__); } } // ------------------------------------------------------- // If necessary set a cookie that marks this topic as read if(($lastpost > $unread) && $updatelast) { $_SESSION['topicread'][$current] = $html->get_date(); // $_SESSION['topicread'] = $topicread; } // ---------------------------------------------------------------- // --------------------- // Grab the tablewrapper list($tbopen,$tbclose) = $html -> table_wrapper(); // -------------------------- // Give the start of the page $Extra = $current."_SEP_" .$tsubject; $html -> send_header("$tsubject",$Cat,0,$user,$Board,$ReadPerm,'0',$Extra); // Load the quickreply template? $quickreply = ""; $quickdisplay = "style=\"display: none;\""; if (($config['quickreply']) && ($reply == "on")) { $qboard = $Board; if (isset($realboard)) { $qboard = $realboard; } $lastnumber = $Number; $lastsubject = $Subject; if (!preg_match("/Re:/",$lastsubject)) { $lastsubject = "Re: $lastsubject"; } $lastsubject = str_replace('"',""",$lastsubject); $what = "showflat"; $isreged = "n"; if ($user['U_Username']) { $addsig = " {$ubbt_lang['ADDSIG']}"; $isreged = "y"; } else { $addsig = ""; } // Create a form check... $form_key = mt_rand() . mt_rand() . mt_rand(); $checked_values = array( "Reged" => $isreged, "page" => $page, "Main" => $current, "Parent" => $lastnumber, "ParentUser" => "", "what" => $what, "fpart" => $fpart, "vc" => $vc, "replyto" => "", "Board" => $Board, ); $form_key_hash = create_form_check($checked_values); // Sigh. $_SESSION["form_key_" . $form_key] = $form_key_hash; include("$thispath/templates/$tempstyle/quickreply.tmpl"); $quickdisplay = ""; } // finish out the page if (!$debug) { include("$thispath/templates/$tempstyle/showflat.tmpl"); } // Send the footer $html -> send_footer(); ?>