authenticate("U_Groups, U_TimeOffset, U_FrontPage,U_TimeFormat,U_LastOn"); $Username = $user['U_Username']; $useroffset = $user['U_TimeOffset']; // ------------------------------------------------------------------- // If this is their first visit for this browser session, set a cookie // and grab all entries from the w3t_Last table if (!$user['U_LastOn']) { $user['U_LastOn'] = $html->get_date(); } if (!isset($_SESSION['forumvisit']['lastonline'])) { $_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; } // --------------- // send the 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 $Groups = $user['U_Groups']; if (!$Groups) { $Groups = "-4-"; } // ------------------------------------ // Are we just looking at one category? $catsonly = $user['U_FrontPage']; $main = "ubbthreads"; if ($config['catsonly']) { $main = "categories"; } if (!$catsonly) { $catsonly = $main; } // ----------------------------------------------------------------- // If we have a Cat variable then we need to set it up for the query if ($Cat) { $pattern = ","; $replace = " OR Cat_Entry = "; $catonly = str_replace($pattern,$replace,$Cat); $catonly = "AND (Cat_Entry = $catonly)"; } // ------------------------- // Are we doing any caching? $update_cache_users = 0; $update_cache_birthday = 0; $update_maxonline = 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 = time(); 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"; } } // -------------------------- // 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 .= "Bo_Read_Perm LIKE '%-$Grouparray[$i]-%'"; } $groupquery .= ")"; // ----------------------------------------- // 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,__LINE__,__FILE__); while (list($modboard,$modid,$modname) = $dbh -> fetch_array($sth)) { if (!isset($modarray[$modboard])) { $modarray[$modboard] = ",$modname,"; } else { $modarray[$modboard] .= "$modname,"; } } // ---------------------- // Grab all of the boards $query = " SELECT Bo_Keyword,Bo_Total,Bo_Last,Bo_Threads,Bo_Moderated,Bo_Cat FROM {$config['tbprefix']}Boards WHERE Bo_Active = '1' $groupquery "; $boards = $dbh -> do_query($query,__LINE__,__FILE__); while ($thisrow = $dbh -> fetch_array($boards)) { $allboards[$thisrow['Bo_Cat']][] = $thisrow; } // ---------------------------- // Cycle through the categories $forumtotal=0; $threadtotal=0; $posttotal=0; $x = 0; while (list ($CatTitle,$CatNumber,$CatDescription) = $dbh -> fetch_array($categories)) { $newposts = ""; $newthreads = ""; if (!$CatTitle) { continue; } // --------------------------------------------- // Now cycle through the boards in this category $firstpass = 0; $boardfolder = "nonewposts.gif"; if (!sizeof($allboards[$CatNumber])) { continue; } for ($y=0;$y do_query($query); $newposts1 = $dbh -> fetch_array($newp1); $dbh -> finish_sth($newposts1); $newposts = $newposts+$newposts1['posts']; $newthreads = $newthreads+$newposts1['topics']; } } // -------------------------------------- // Let's see how many NA posts there are if ( ($Moderated == "yes") && ($Viewable == "") ) { $query = " SELECT COUNT(*) FROM {$config['tbprefix']}Posts WHERE B_Approved = 'no' AND B_Board = '$Board_q' "; $notapp = $dbh -> do_query($query,__LINE__,__FILE__); list($notapproved) = $dbh -> fetch_array($notapp); $dbh -> finish_sth($notapp); } $showna = $showna + $notapproved; if (isset($catrow[$x]['threadtotal'])) { $catthreads = $catrow[$x]['threadtotal']; } else { $catthreads = "0"; } if (isset($catrow[$x]['posttotal'])) { $catposts = $catrow[$x]['posttotal']; } else { $catposts = "0"; } if (!isset($catrow[$x]['forumtotal'])) { $catrow[$x]['forumtotal'] = "0"; } $catrow[$x]['threadtotal'] = $catthreads + $Threads; $catrow[$x]['forumtotal']++; $catrow[$x]['posttotal'] = $catposts + $Total; $catrow[$x]['boardfolder'] = $boardfolder; } $dbh -> finish_sth($boards); if ($showna) { $showna = " ($showna {$ubbt_lang['NOT_APPROVED']})"; } else { $showna = ""; } $catrow[$x]['showna'] = $showna; if (isset($catrow[$x]['forumtotal'])) { if ($newposts) { $newposts = "
($newposts)"; } else { $newposts = ""; } $catrow[$x]['showposts'] = $newposts; if ($newthreads) { $newthreads = "
($newthreads)"; } else { $newthreads = ""; } $catrow[$x]['showthreads'] = $newthreads; $catrow[$x]['CatNumber'] = $CatNumber; $catrow[$x]['CatTitle'] = $CatTitle; $catrow[$x]['CatDescription'] = $CatDescription; $x++; } $forumtotal = 0; $threadtotal = 0; $posttotal = 0; $showna = ""; } $dbh -> finish_sth($categories); // ----------------------- // Grab the total # online $Outdated = $html -> get_date() - ($config['onlinetime'] * 60 ); $query = " SELECT O_Type,COUNT(*) FROM {$config['tbprefix']}Online WHERE O_Last > '$Outdated' GROUP BY O_Type "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); while(list ($type,$count) = $dbh -> fetch_array($sth)) { ${$type} = $count; } 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; } $maxonlinetime = $html -> convert_time($c_maxonline_timestamp,$useroffset,$user['U_TimeFormat']); // ------------------------------------- // 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']}"; } $catsize = sizeof($catrow); // --------------------- // Grab the tablewrapper list($tbopen,$tbclose) = $html -> table_wrapper(); if (!$debug) { include ("$thispath/templates/$tempstyle/categories.tmpl"); } $html -> send_footer(); ?>