authenticate("U_Display,U_Groups,U_PostsPer,U_PicturePosts,U_FlatPosts,U_TempRead,U_TimeOffset"); $html = new html; // ----------------------------------------- // require the language file for this script require "languages/${$config['cookieprefix']."w3t_language"}/showflat.php"; // ------------------------- // Reassign $main to $Number $Number = $main; $folder = "icons"; // --------------------------------------------------- // Grab the cookie to mark the posts as read or unread $piece['0'] = ""; preg_match("/-$Board=(.*?)-/",${$config['cookieprefix']."w3t_visit"},$piece); $unread = $piece['1']; // ------------------------------------------------------------- // 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' $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 $extra = "B_Number = $Number"; $query = " SELECT B_Number,B_Posted,U_Username,B_IP,B_Subject,B_Body,B_File,U_Status,B_Approved,B_Reged,U_Title,B_Sticky,U_Color,B_Icon,B_Poll,B_Parent,U_Status FROM {$config['tbprefix']}Posts, {$config['tbprefix']}Users WHERE B_PosterId = U_Number AND $extra $Viewable ORDER BY B_Number "; $sth = $dbh -> do_query($query); list($current,$posted,$counter,$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); } if ($type == "thread") { $extra = "B_Main = $current"; } // ------------------------------- // 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 FROM {$config['tbprefix']}Posts AS t1, {$config['tbprefix']}Users AS t2 WHERE $extra AND t1.B_Posterid = t2.U_Number $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) = $dbh -> fetch_array($sth); $time = $html -> convert_time($Posted,$user['U_TimeOffset']); $EUsername = $Posterid; $PUsername = $Username; if ($Color) { $PUsername = "$PUsername"; } // --------------------------------------------------------- // We need to know if this was made by an admin or moderator $UserStatus = ""; if ($PostStatus == "A") { $UserStatus = "\"{$ubbt_lang['USER_ADMIN']}\""; } if ($PostStatus == "M") { $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 ="book.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')) ) { $picture = "\"\""; } $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(); ?>