authenticate("U_Display,U_Groups,U_PostsPer,U_PicturePosts,U_FlatPosts,U_TimeOffset,U_TimeFormat"); $html = new html; !isset($user['U_TimeFormat']) && $user['U_TimeFormat'] = $theme['timeformat']; // ----------------------------------------- // require the language file for this script require "languages/{$_SESSION['myprefs']['language']}/showflat.php"; // ------------------------- // Reassign $main to $Number $Number = $main; $folder = "icons"; // ------------------------------------------------------------- // 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); } // Set the default of viewing pictures with posts $PicturePosts = $user['U_PicturePosts']; if (!$PicturePosts) { $PicturePosts = $theme['PicturePosts']; } // ------------------------------------------------------ // Let's find out what Groups we are dealing with $Board_q = addslashes($Board); $Groups = $user['U_Groups']; if (!$Groups) { $Groups = "-4-"; } // -------------------------------------------------------------- // We need to format a SQL query to see what boards this user can // view $Grouparray = split("-",$Groups); $gsize = sizeof($Grouparray); $groupquery = "AND ("; $g = 0; for ($i=0; $i<=$gsize;$i++) { if (!isset($Grouparray[$i])) { continue; } if (!preg_match("/[0-9]/",$Grouparray[$i])) { continue; }; $g++; if ($g > 1) { $groupquery .= " OR "; } $groupquery .= "Bo_Read_Perm LIKE '%-$Grouparray[$i]-%'"; } $groupquery .= ")"; // -------------------------------------------- // Let's find out if they should be here or not $query = " SELECT Bo_Title,Bo_Write_Perm,Bo_CatName,Bo_Cat FROM {$config['tbprefix']}Boards WHERE Bo_Keyword = '$Board_q' AND Bo_Active = '1' $groupquery "; $sth = $dbh -> do_query($query); list($title,$CanWrite,$CatName,$CatNumber) = $dbh -> fetch_array($sth); if (!$title) { $html -> not_right($ubbt_lang['BAD_GROUP'],$Cat); } // --------------------------------------------------------------- // If they are a normal user then they can only see approved posts $ismod = "no"; // By default they are not a moderator $Viewable = "And B_Approved = 'yes'"; if ($user['U_Status'] == "Administrator") { $Viewable = ""; } if ($user['U_Status'] == "Moderator") { // --------------------------------- // Check if they moderate this board $Board_q = addslashes($Board); $query = " SELECT Mod_Board FROM {$config['tbprefix']}Moderators WHERE Mod_Uid = '{$user['U_Number']}' AND Mod_Board = '$Board_q' "; $sth = $dbh -> do_query($query); list($check) = $dbh -> fetch_array($sth); if ($check) { $Viewable = ""; $ismod = "yes"; } } // ----------------------------------------------------------------------------- // Once and a while if people try to just put a number into the url, lets trap it if (!$Number) { $html -> not_right($ubbt_lang['POST_PROB'],$Cat); } // ------------------------------------------ // Grab the main post number for this thread $query = " SELECT B_Number,B_Posted FROM {$config['tbprefix']}Posts WHERE B_Number = '$Number' $Viewable ORDER BY B_Number "; $sth = $dbh -> do_query($query); list($current,$posted,$counter,$ip,$tsubject,) = $dbh -> fetch_array($sth); // ------------------------------------------------------------- // If we didn't find the main post, then this post doesn't exist if (!$current) { $html -> not_right("The post you are looking for could not be found",$Cat); } $extra = ""; if ($type == "thread") { $extra = "AND B_Main = $current"; } else { $extra = "AND B_Number='$Number'"; } // ------------------------------- // Now cycle through all the posts $query = " SELECT t1.B_Number,t1.B_Posted,t2.U_Username,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,t1.B_Posterid,t2.U_PicWidth,t2.U_PicHeight FROM {$config['tbprefix']}Posts AS t1, {$config['tbprefix']}Users AS t2 WHERE t1.B_Posterid = t2.U_Number $extra $Viewable ORDER BY B_Number "; $sth = $dbh -> do_query($query); $totalthread = $dbh -> total_rows($sth); for ( $i = 0;$i< $totalthread;$i++){ list ($Number,$Posted,$Username,$IP,$Subject,$Body,$File,$Open,$Approved,$Picture,$Reged,$Title,$Color,$Icon,$Poll,$Parent,$PostStatus,$Posterid,$picwidth,$picheight) = $dbh -> fetch_array($sth); $time = $html -> convert_time($Posted,$user['U_TimeOffset'],$user['U_TimeFormat']); $EUsername = $Posterid; $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']}\""; } if ($PostStatus == "Moderator" && $ismod == "yes") { if (!$Color) { $PUsername = "$PUsername"; } $UserStatus = "\"{$ubbt_lang['USER_MOD']}\""; } // IF it isn't approved we need to mark it if ($Approved == "no") { $Subject = "({$ubbt_lang['NOT_APPROVED']}) $Subject"; } $folder = "icons"; $showicon = ""; if (!$Icon) { $Icon ="blank.gif"; } // --------------------------------------------------------- // If its an anonymous post, dont' give a link to the profile if($Reged == "n") { // ------------------------------------------------------------------- // If we aren't allowing anonymous users to choose their own username // then we display the basic Anonymous user in the user's selected // language if(!$config['anonnames']) { $Username = $ubbt_lang['ANON_TEXT']; } $Title = $ubbt_lang['UNREGED_USER']; } else { $Username = "$PUsername"; } if ( ($config['showip'] == 1) && ($IP) ) { } elseif ( ($config['showip'] == 2) && ( ($user['U_Status'] == "Administrator") || ($user['U_Status'] == "Moderator") ) && ($IP) ) { } elseif ( ($config['showip'] == 3) && ($user['U_Status'] == "Administrator") && ($IP) ) { } else { $IP = ""; } $fileurl = ""; if ($File){ $fileurl = "{$ubbt_lang['FILE_ATTACH']}"; } $picture = ""; if ( ($Picture) && ($Picture != "http://") && ( ($PicturePosts) || ($PicturePosts == 'on')) ) { $picsize = ""; if ($picwidth && $picheight) { $picsize = "width=\"$picwidth\" height=\"$picheight\""; } else { $picsize = "width=\"{$theme['PictureWidth']}\" height=\"{$theme['PictureHeight']}\""; } $picture = "\"\""; } // -------------------------------------------------------------------- // 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) { $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); 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); list($check) = $dbh -> fetch_array($sta); } if (!$check || ($pnoresults && ($currtime < $pstop) ) ) { include("$thispath/includepoll.php"); } else { include("$thispath/includepollresults.php"); } $postrow[$i]['showpoll'] = $showpoll; } $postrow[$i]['Username'] = $Username; $postrow[$i]['UserStatus'] = $UserStatus; $postrow[$i]['Title'] = $Title; $postrow[$i]['time'] = $time; $postrow[$i]['IP'] = $IP; $postrow[$i]['fileurl'] = $fileurl; $postrow[$i]['picture'] = $picture; $postrow[$i]['folder'] = $folder; $postrow[$i]['Icon'] = $Icon; $postrow[$i]['Subject'] = $Subject; $postrow[$i]['Body'] = $Body; } $postrowsize = sizeof($postrow); // --------------------- // Grab the tablewrapper list($tbopen,$tbclose) = $html -> table_wrapper(); if (!$debug) { include("$thispath/templates/$tempstyle/printthread.tmpl"); } // ---------------- // Send the footer $html -> send_footer(); ?>