authenticate("U_FrontPage, U_Groups, U_TimeOffset,U_Display,U_Favorites,U_WhichForums,U_Categories,U_TimeFormat,U_LastOn"); $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']; !isset($user['U_TimeFormat']) && $user['U_TimeFormat'] = $theme['timeformat']; $userstatus = $user['U_Status']; $showforums = $user['U_WhichForums']; $laston = $user['U_LastOn']; // ------------------------------------------------------------------- // If this is their first visit for this browser session, set a cookie // and grab all entries to the w3t_Last table if ((empty($user['U_LastOn']))) { $user['U_LastOn'] = $html->get_date(); } // The _SESSION['forumvisit']['visit']['boardname'] array holds the real last visit time // for each forum // The _SESSION['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; } } // $_SESSION['forumvisit'] = $forumvisit; } // if user is moderator, grab their moderator permissions if ($userstatus == "Moderator"){ $modperms = $userob->get_mod_perms($user['U_Number']); } else { $modperms = array(); } $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 -> 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 if needed $moderator = array(); $modarray = array(); if ($config['showmods'] == "1") { $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,__LINE__,__FILE__); 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 $bocatonly = ""; if ($Cat) { $inlist = str_replace(",","','",$Cat); $catonly = "AND (Cat_Entry IN ('$inlist'))"; $bocatonly = "AND (t1.Bo_Cat IN ('$inlist'))"; } // ------------------------------------ // Are we just looking at one category? $main = "ubbthreads"; if ($config['catsonly']) { $main = "categories"; } if (!$catsonly) { $catsonly = $main; } if ( (isset($C)) && ($catsonly == "categories") ) { $catonly = "AND Cat_Entry = '$C'"; $bocatonly = "AND t1.Bo_Cat = '$C'"; } // ------------------------- // Are we doing any caching? $update_cache_users = 0; $update_cache_birthday = 0; if ($config['cache_users'] < 15) { $config['cache_users'] = '15'; } $query = " SELECT C_Users,C_NewUsername,C_NewUid,C_Users_timestamp,C_Birthdays,C_Birthdays_timestamp,C_MaxOnline,C_MaxOnline_timestamp FROM {$config['tbprefix']}Cache "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list ($registered,$newusername,$encnewusername,$c_users_timestamp,$birthdays,$c_birthdays_timestamp,$c_maxonline,$c_maxonline_timestamp) = $dbh -> fetch_array($sth); $cachenow = $html->get_date(); date_default_timezone_set("UTC");//mlp $temp = getdate(); $thisday = $temp['mday']; $temp = getdate($c_birthdays_timestamp); $cacheday = $temp['mday']; if ( ( ($cacheday != $thisday) || !$c_birthdays_timestamp) && $config['cache_birthday']) { $update_cache_birthday = 1; } // ------------------------------------ // Are we showing birthday's for today? if ( (!$config['cache_birthday'] || $update_cache_birthday) && $config['main_bday']) { $birthdays = ""; $comma = ""; // --------------------------------- // Get some info on the current date $temp = getdate(); $month = $temp["mon"]; $day = $temp["mday"]; $year = $temp["year"]; $query = " SELECT U_Username,U_Number,U_Birthday,U_CoppaUser FROM {$config['tbprefix']}Users WHERE U_Birthday LIKE '$month/$day/%' AND U_ShowBday = '1' "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); while(list($uname,$unumber,$birthday,$coppauser) = $dbh -> fetch_array($sth)) { @list($bmonth,$bday,$byear) = @split("/",$birthday); $age = ""; if ($config['showage'] && !$coppauser) { $age = $year - $byear; $age = " ($age)"; } if ($birthdays) { $comma = ","; } $birthdays .= "$comma$uname $age"; } } // ------------------------------------------------ // Let's see how many user's are viewing each forum $Outdated = $html -> get_date() - ($config['onlinetime'] * 60 ); $query = " SELECT O_Board,COUNT(*),O_Type FROM {$config['tbprefix']}Online WHERE O_Last > '$Outdated' GROUP BY O_Board,O_Type "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); $r = 0 ; $a = 0; while (list($forum,$onlinecount,$type) = $dbh -> fetch_array($sth)) { if (!isset($Boardview[$forum])) { $Boardview[$forum] = $onlinecount; } else { $Boardview[$forum] = $Boardview[$forum] + $onlinecount; } ${$type} = ${$type} + $onlinecount; } if (!isset($a)) { $a = "0"; } if (!isset($r)) { $r = "0"; } // ------------ // Total online $totalon = $a + $r; // ------------------------------- // DO we need to update the cache? $update_maxonline = 0; if ($totalon > $c_maxonline) { $c_maxonline = $totalon; $c_maxonline_timestamp = $cachenow; $update_maxonline = 1; } if (!$c_maxonline_timestamp) { $c_maxonline_timestamp = $html->get_date(); } if (!$c_maxonline) { $c_maxonline = 1; } $maxonlinetime = $html -> convert_time($c_maxonline_timestamp,$useroffset,$user['U_TimeFormat']); // -------------------------- // Get the list of categories $query = " SELECT Cat_Title,Cat_Entry,Cat_Description FROM {$config['tbprefix']}Category WHERE Cat_Type = 'forum' $catonly ORDER BY Cat_Number "; $categories = $dbh -> do_query($query,__LINE__,__FILE__); $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 .= ")"; // ------------------------------------------- // Now get the entire 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,t1.Bo_Image,t1.Bo_Cat 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_Active = '1' $bocatonly $groupquery ORDER BY t1.Bo_Cat,t1.Bo_Sorter "; $boards = $dbh->do_query($query,__LINE__,__FILE__); while ( $boardrow = $dbh -> fetch_array($boards)) { $catboards[$boardrow['Bo_Cat']][] = $boardrow; } // ---------------------------- // 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 cycle through the boards in this category $firstpass = 0; $y = 0; if (!sizeof($catboards[$CatNumber])) { continue; } foreach($catboards[$CatNumber] as $brow => $thisboard) { list($Title,$Description,$Keyword,$Total,$Last,$Number,$Moderated,$ReadPerm,$WritePerm,$Threads,$Sorter,$Posterid,$lastmain,$lastnumber,$Poster,$Subject,$Icon,$Reged,$AnonName,$forumimage,$catnum) = $thisboard; $Board_q = addslashes($Keyword); $notapproved = ""; // We have boards in this category $isboards = 1; // What timestamp are we checking against for new posts if (isset($_SESSION['forumvisit']['visit'][$Keyword])) { $laston = $_SESSION['forumvisit']['visit'][$Keyword]; } if ( ($laston < $Last) && $user['U_Username']){ $newincat = 1; } // ------------------------- // Set a default for $Poster if ($Reged == "n") { if (!$config['anonnames']) { $Poster = $ubbt_lang['ANON_TEXT']; } else { if ($AnonName) { $Poster = $AnonName; } else { $Poster = $ubbt_lang['ANON_TEXT']; } } } // ------------------------------------------------- // Set the new markers to blank on each pass through $showposts = ""; $showthreads = ""; 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,$user['U_TimeFormat']); // 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" && $modperms['P_CanApprovePosts']) { if (isset($modarray[$Keyword])) { if (preg_match("/(,|^){$user['U_Number']}(,|$)/i",$modarray[$Keyword])) { $Viewable=""; } } } // -------------------------- // Which folder do we display $boardfolder = "nonewposts.gif"; if ( ($laston < $Last) && $user['U_Username'] ){ $boardfolder = "newposts.gif"; // Are we showing the total # of new posts? if ($config['newtotals']) { $query = " SELECT COUNT(*) AS posts, SUM(B_Topic) AS topics FROM {$config['tbprefix']}Posts WHERE B_Posted > '$laston' $Viewable AND B_Board = '$Board_q' "; $newp1 = $dbh -> do_query($query); $newposts1 = $dbh -> fetch_array($newp1); $dbh -> finish_sth($newposts1); if ($newposts1['topics']) { $showthreads = "({$newposts1['topics']})"; } if ($newposts1['posts']) { $showposts = "({$newposts1['posts']})"; } } } if ( (!stristr($user['U_Favorites'],"-$Number-")) && ($showforums == "fav") ) { $notshown++; continue; } if ( stristr($user['U_Categories'],"-$CatNumber-")){ $totalincat++; continue; } // ---------------- // SHow moderators? if (($config['showmods'] == 1) && (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 && $Subject) { $append = ""; if (strlen($Subject) > 26) { $append = "..."; } $Subject = substr($Subject,0,26); $Subject .= $append; if (!$Icon) { $Icon = "blank.gif"; } $imagesize = $images['icons']; $lastpost = "\"*\" $Subject"; $lastposter = "($Poster)"; } else { $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]['time'] = $time; $forum[$x][$y]['lastpost'] = $lastpost; $forum[$x][$y]['lastposter'] = "$lastposter"; $forum[$x][$y]['forumimage'] = ""; if ($forumimage) { $forum[$x][$y]['forumimage'] = "\"*\""; } if (!isset($Boardview[$Keyword])) { $forum[$x][$y]['viewing'] = ""; } else { $forum[$x][$y]['viewing'] = "($Boardview[$Keyword] {$ubbt_lang['VIEWING']})"; } 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,$user['U_TimeFormat']); if ($userstatus) { $edittimelinkstart = ""; $edittimelinkstop = ""; } else { $edittimelinkstart = ""; $edittimelinkstop = ""; } // ------------------------------------- // Do we have to update the cache table if ( ($update_cache_birthday) || ($update_maxonline) ) { $params = ""; if ($update_cache_birthday) { $birthdays = addslashes($birthdays); $params .= " C_Birthdays = '$birthdays', C_Birthdays_timestamp = '$cachenow',"; } if ($update_maxonline) { $params .= " C_MaxOnline = '$c_maxonline', C_MaxOnline_timestamp = '$c_maxonline_timestamp' "; } $params = preg_replace("/,$/","",$params); $query = " UPDATE {$config['tbprefix']}Cache SET $params "; $dbh -> do_query($query,__LINE__,__FILE__); } if ($birthdays) { $birthdays = "
{$ubbt_lang['HAPPY_BDAY']}: $birthdays"; } else { $birthdays = "
{$ubbt_lang['NOBDAY']}"; } // --------------------- // Grab the tablewrapper list($tbopen,$tbclose) = $html -> table_wrapper(); if (!$debug) { include("$thispath/templates/$tempstyle/ubbthreads.tmpl"); } // Send the footer $html -> send_footer(); ?>