authenticate("U_FrontPage, U_Groups, U_TimeOffset,U_Display,U_Favorites,U_WhichForums,U_Categories"); $Username = $user['U_Username']; $mode = $user['U_Display']; $Groups = $user['U_Groups']; isset($user['U_FrontPage']) && $catsonly = $user['U_FrontPage']; isset($user['U_TimeOffset']) && $useroffset = $user['U_TimeOffset']; $userstatus = $user['U_Status']; $showforums = $user['U_WhichForums']; $toggleshowstart = ""; $toggleshowstop = ""; if ($Username) { $toggleshowstart = ""; $toggleshowstop = ""; } // -------------------------------------------- // Are we showing all forums or only favorites? $only_favs = ""; if ($showforums == "fav") { $currentshow = "{$ubbt_lang['ALL_FORUMS']}"; $only_favs = "
{$ubbt_lang['ONLY_FAVS']} ({$ubbt_lang['ALL_FORUMS']})
"; } else { $currentshow = "{$ubbt_lang['FAV_FORUMS']}"; } if (!$mode) { $mode = $theme['postlist']; } $linker = "show$mode"; // ------------------ // Send a html header $html = new html; $html -> send_header($config['title'],$Cat,0,$user); // -------------------------------------------------------------------- // If they are logged in then we check their groups, otherwise they get // set to the guest group if (!$Groups) { $Groups = "-4-"; } // ----------------------------------------- // Grab all of the moderators for all forums $query = " SELECT t1.Mod_Board,t1.Mod_Uid,t2.U_Username FROM {$config['tbprefix']}Moderators AS t1, {$config['tbprefix']}Users AS t2 WHERE t1.Mod_Uid = t2.U_Number "; $sth = $dbh -> do_query($query); while (list($modboard,$modid,$modname) = $dbh -> fetch_array($sth)) { $moderator[$modid] = $modname; if (!isset($modarray[$modboard])) { $modarray[$modboard] = ",$modid,"; } else { $modarray[$modboard] .= "$modid,"; } } // ----------------------------------------------------------------- // If we have a Cat variable then we need to set it up for the query if ($Cat) { $pattern = ","; $replace = " OR Cat_Number = "; $catonly = str_replace($pattern,$replace,$Cat); $catonly = "AND (Cat_Number = $catonly)"; } // ------------------------------------ // Are we just looking at one category? $main = "ubbthreads"; if ($config['catsonly']) { $main = "categories"; } if (!$catsonly) { $catsonly = $main; } if ( (isset($C)) && ($catsonly == "categories") ) { $C = addslashes($C); $catonly = "AND Cat_Number = '$C'"; } // -------------------------------------------------------------------------- // Let's see how many total registered users there are but only if we want to // display this information $sth = $dbh->do_query("SELECT COUNT(*) FROM {$config['tbprefix']}Users WHERE U_Approved='yes'"); list($registered) = $dbh -> fetch_array($sth); $dbh -> finish_sth($sth); // ------------------------------------------------------------------------- // let's grab the name of the most recently registered user $query = " SELECT U_Username,U_Number FROM {$config['tbprefix']}Users WHERE U_Approved='yes' ORDER BY U_Number DESC LIMIT 0,1 "; $sth = $dbh -> do_query($query); list($newusername,$newnumber) = $dbh -> fetch_array($sth); $encnewusername = $newnumber; $dbh -> finish_sth($sth); // Must define welcome message here for the template since it is different // if the user isn't logged in. if ($Username) { $welcomemessage = "{$ubbt_lang['INTRO_SUB']} {$user['U_Username']}"; } else { $welcomemessage = $ubbt_lang['WEL_PRIV_NO']; } // ----------------------------------------- // Get this user's last visit to each forum if ($Username) { $Username_q = addslashes($Username); $query = " SELECT L_Board,L_Last FROM {$config['tbprefix']}Last WHERE L_Uid = '{$user['U_Number']}' "; $sth = $dbh -> do_query($query); while(list($Board,$Last) = $dbh -> fetch_array($sth)) { $Lastvisit[$Board] = $Last; } } // ----------------------- // Grab the total # online $date = $html -> get_date(); $LastOn = $date - 600; $query = " SELECT O_Type,COUNT(*) FROM {$config['tbprefix']}Online WHERE O_Last > '$LastOn' GROUP BY O_Type "; $sth = $dbh -> do_query($query); while(list ($type,$count) = $dbh -> fetch_array($sth)) { ${$type} = $count; } if (!isset($a)) { $a = "0"; } if (!isset($r)) { $r = "0"; } // -------------------------- // Get the list of categories $query = " SELECT DISTINCT Cat_Title,Cat_Number,Cat_Description FROM {$config['tbprefix']}Category WHERE Cat_Type = 'forum' $catonly ORDER BY Cat_Number "; $categories = $dbh -> do_query($query); $j = 0; // ------------------------------------------------------------------- // 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 (!preg_match("/[0-9]/",$Grouparray[$i])) { continue; }; $g++; if ($g > 1) { $groupquery .= " OR "; } $groupquery .= "t1.Bo_Read_Perm LIKE '%-$Grouparray[$i]-%'"; } $groupquery .= ")"; // ---------------------------- // Cycle through the categories $x = 0; while ( $row = $dbh -> fetch_array($categories)) { $CatNumber = $row['1']; // This variable lets us know if there were any boards in this category // that were visible to the user. As soon as we come across a board that // they can see, it gets set to "yes" $table_done = "no"; $isboards = 0; $notshown = 0; $totalincat = 0; $newincat = 0; // ------------------------------------------- // Now get the list of boards in this category $query = " SELECT t1.Bo_Title,t1.Bo_Description,t1.Bo_Keyword,t1.Bo_Total,t1.Bo_Last,t1.Bo_Number,t1.Bo_Moderated,t1.Bo_Read_Perm,t1.Bo_Write_Perm,t1.Bo_Threads,t1.Bo_Sorter,t1.Bo_Posterid,t1.Bo_LastMain,t1.Bo_LastNumber,t2.U_Username,t3.B_Subject,t3.B_Icon,t3.B_Reged,t3.B_AnonName FROM {$config['tbprefix']}Boards AS t1 LEFT JOIN {$config['tbprefix']}Users AS t2 ON t1.Bo_Posterid = t2.U_Number LEFT JOIN {$config['tbprefix']}Posts AS t3 ON t1.Bo_LastNumber = t3.B_Number WHERE t1.Bo_Cat = $CatNumber AND (t1.Bo_Posterid = t2.U_Number OR t1.Bo_Posterid = '0') AND (t1.Bo_LastNumber = t3.B_Number OR t1.Bo_LastNumber ='0') $groupquery ORDER BY t1.Bo_Sorter "; $boards = $dbh -> do_query($query); // --------------------------------------------- // Now cycle through the boards in this category $firstpass = 0; $y = 0; while ( $boardrows = $dbh -> fetch_array($boards)) { list($Title,$Description,$Keyword,$Total,$Last,$Number,$Moderated,$ReadPerm,$WritePerm,$Threads,$Sorter,$Posterid,$lastmain,$lastnumber,$Poster,$Subject,$Icon,$Reged,$AnonName) = $boardrows; $Board_q = addslashes($Keyword); // We have boards in this category $isboards = 1; if (isset($Lastvisit[$Keyword])) { $checker = $Lastvisit[$Keyword]; } else { $checker = 0; } if ( ($checker < $Last) ){ $newincat = 1; } // ------------------------- // Set a default for $Poster if ($Reged == "n") { if (!$config['anonnames']) { $Poster = $ubbt_lang['ANON_TEXT']; } else { $Poster = $AnonName; } } // ------------------------------------------------- // Set the new markers to blank on each pass through $shownew = ""; $shownewt= ""; $showposts = ""; $showthreads = ""; $showna = ""; $notapproved = ""; if (!$firstpass) { $j = 1; $firstpass = 1; } $time = ""; if (!$Threads) { $Threads = 0; } // ------------------------------------------------------------------ // If Last = 0 then this is a new board so set last post to New Board if (!$Last) { $time = $ubbt_lang['NEW_BOARD']; } else { $time = $html -> convert_time($Last,$useroffset); // Do a conversion; } // --------------------------------------------------------------- // If they are a normal user then they can only see approved posts $Viewable = "AND B_Approved = 'yes'"; if ($userstatus == "Administrator") { $Viewable = ""; } elseif ($userstatus == "Moderator") { if (preg_match("/(,|^){$user['U_Number']}(,|$)/i",$modarray[$Keyword])) { $Viewable=""; } } // -------------------------- // Which folder do we display $boardfolder = "nonewposts.gif"; if ( ($checker < $Last) ){ $boardfolder = "newposts.gif"; } // ------------------------------------- // Let's see how many NA posts there are $notapproved=""; if ( ($Moderated == "yes") && ($Viewable == "") ) { $query = " SELECT COUNT(*) FROM {$config['tbprefix']}Posts WHERE B_Approved = 'no' AND B_Board = '$Board_q' "; $nap = $dbh -> do_query($query); $notapproved = $dbh -> fetch_array($nap); $notapproved = $notapproved['0']; $dbh -> finish_sth($nap); } if ($notapproved) { $showna = " ($notapproved {$ubbt_lang['NOT_APPROVED']})"; $boardfolder = "newposts.gif"; $newincat = "1"; } else { $showna = ""; } if ( (!stristr($user['U_Favorites'],"-$Number-")) && ($showforums == "fav") ) { $notshown++; continue; } if ( stristr($user['U_Categories'],"-$CatNumber-")){ $totalincat++; continue; } // --------------------------------------------------------------- // If we are tracking the number of new posts, then we need to do // some extra queries. if ( ($config['newcounter'] == 2 ) && ($Username) && ($boardfolder == "newposts.gif") ) { if (!$checker) { $checker = "0"; } // -------------------------------------------------------------- // Let's see how many new posts there are. We have to do some // tricky AND/OR operations because we don't want sticky posts to // be counted as new if they are not $query = " SELECT COUNT(*), SUM(B_Topic) FROM {$config['tbprefix']}Posts WHERE B_Posted > $checker $Viewable AND B_Board = '$Board_q' "; $newp1 = $dbh -> do_query($query); $newposts1 = $dbh -> fetch_array($newp1); $dbh -> finish_sth($newposts1); $newthreads = $newposts1[1]; $newposts = $newposts1[0]; if ( ($checker < $Last) && ($user['U_Username']) && ($newthreads) ) { $showthreads = " ($newthreads)"; $boardfolder = "newposts.gif"; } if ( ($checker < $Last) && ($user['U_Username']) && ($newposts) ) { $showposts = " ($newposts)"; $boardfolder = "newposts.gif"; } if (!$newthreads && !$newposts && !$notapproved) { $boardfolder = "nonewposts.gif"; } } // ---------------- // SHow moderators? if (isset($modarray[$Keyword])) { $thismodarray = split(",",$modarray[$Keyword]); $modsize = sizeof($thismodarray); $comma =0; $modlist = ""; for ($i=0;$i<$modsize;$i++) { if ($thismodarray[$i]) { if ($comma) { $modlist .= ", "; } $modlist .= "{$moderator[$thismodarray[$i]]}"; $comma++; } else { $modlist .= " "; } } } else { $modlist = " "; } // If we have a last post for this board we link to it $lastpost = ""; if ($Poster) { $append = ""; if (strlen($Subject) > 26) { $append = "..."; } $Subject = substr($Subject,0,26); $Subject .= $append; if (!$Icon) { $Icon = "book.gif"; } $lastpost = "\"*\" $Subject"; $forum[$x][$y]['lastposter'] = "($Poster)"; } else { $forum[$x][$y]['lastposter'] = ""; } $forum[$x][$y]['boardfolder'] = $boardfolder; $forum[$x][$y]['Keyword'] = $Keyword; $forum[$x][$y]['Title'] = $Title; $forum[$x][$y]['Description'] = $Description; $forum[$x][$y]['Threads'] = $Threads; $forum[$x][$y]['showthreads'] = $showthreads; $forum[$x][$y]['Total'] = $Total; $forum[$x][$y]['showposts'] = $showposts; $forum[$x][$y]['showna'] = $showna; $forum[$x][$y]['time'] = $time; $forum[$x][$y]['lastpost'] = $lastpost; if ( ($config['showmods'] == 1) && ($modlist) ) { $forum[$x][$y]['modlist'] = "   {$ubbt_lang['USER_MOD']}: $modlist"; } else { $forum[$x][$y]['modlist'] = ""; } $y++; } if (isset($forum[$x])) { $forumsize[$x] = sizeof($forum[$x]); } else { $forumsize[$x] = 0; } $dbh -> finish_sth($boards); // If we had boards in this category then we add to the array if ($isboards) { $catrow[$x]['NewMarker'] = ""; $catrow[$x]['ToggleLink'] = ""; if ( ($showforums != "fav") && ($Username) ) { if (stristr($user['U_Categories'],"-$CatNumber-")) { $extra = "\n$totalincat {$ubbt_lang['TOTAL_FORUMS']}"; $class = ""; if ($newincat) { $extra = "\n\n{$ubbt_lang['NEWINCAT']}"; $class = "class=\"newpostsincat\""; } $catrow[$x]['ToggleLink'] = "\"{$ubbt_lang['EXP_ICON']}$extra\""; } else { $catrow[$x]['ToggleLink'] = "\"{$ubbt_lang['COL_ICON']}\""; } } $catrow[$x]['CatTitle'] = $row['0']; $catrow[$x]['NotShown'] = ""; if ($notshown) { $catrow[$x]['NotShown'] = "\n\n($notshown {$ubbt_lang['NOT_SHOWN']})"; } if(isset($row['2'])) { $catrow[$x]['CatDesc'] = "{$row['2']}"; } else { $catrow[$x]['CatDesc'] = ""; } $x++; } } $catsize = 0; if (isset($catrow)) { $catsize = sizeof($catrow); } $dbh -> finish_sth($categories); // --------------------------- // Show them their time offset $date = $html -> get_date(); $time = $html -> convert_time($date,$useroffset); if ($userstatus) { $edittimelinkstart = ""; $edittimelinkstop = ""; } else { $edittimelinkstart = ""; $edittimelinkstop = ""; } // --------------------- // Grab the tablewrapper list($tbopen,$tbclose) = $html -> table_wrapper(); if (!$debug) { include("$thispath/templates/$tempstyle/ubbthreads.tmpl"); } // Send the footer $html -> send_footer(); ?>