The only change currently is that I moved the Birthdays to its own table. All the other changes weren't reinstalled since they involved integrating kkroo's Simple User Color mod which isn't needed since I'm using AGCM now. I'm currently using Birthdays 3.0.
edcrain is one of our Global Moderators. He should show up as purple, but instead shows up in the default anchor link color.
Code: Select all
<?php
/***************************************************************************
* index.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : [email protected]
*
* $Id: index.php,v 1.99.2.7 2006/01/28 11:13:39 acydburn Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
$viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1;
if( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
{
$mark_read = ( isset($HTTP_POST_VARS['mark']) ) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
}
else
{
$mark_read = '';
}
//
// Handle marking posts
//
if( $mark_read == 'forums' )
{
if( $userdata['session_logged_in'] )
{
setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
$template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="3;url=' .append_sid("index.$phpEx") . '">')
);
$message = $lang['Forums_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a> ');
message_die(GENERAL_MESSAGE, $message);
}
// Start Mark Category Read MOD
if ( $mark_read == 'category' && $viewcat )
{
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
if ( $userdata['session_logged_in'] )
{
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . "
WHERE cat_id = $viewcat";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain category information', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
$forum_id = $row['forum_id'];
$sql = 'SELECT MAX(post_time) AS last_post
FROM ' . POSTS_TABLE . "
WHERE forum_id = $forum_id";
if ( !($result2 = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
}
if ( $row2 = $db->sql_fetchrow($result2) )
{
if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
{
asort($tracking_forums);
unset($tracking_forums[key($tracking_forums)]);
}
if ( $row2['last_post'] > $userdata['user_lastvisit'] )
{
$tracking_forums[$forum_id] = time();
}
}
}
setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
);
$message = $lang['Category_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
}
// End Mark Category Read MOD
//
// End handle marking posts
//
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
//
// If you don't use these stats on your index you may want to consider
// removing them
//
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];
// Topics a user has started MOD, by Manipe (Begin)
$total_topics = get_db_stat('topiccount');
if( $total_topics == 0 )
{
$l_total_topic_s = $lang['Posted_topics_zero_total'];
}
else if( $total_topics == 1 )
{
$l_total_topic_s = $lang['Posted_topic_total'];
}
else
{
$l_total_topic_s = $lang['Posted_topics_total'];
}
// Topics a user has started MOD, by Manipe (End)
//-- mod : Advanced Group Color Management -------------------------------------
//-- add
$newest_user_group_id = $newest_userdata['user_group_id'];
$newest_user_session_time = $newest_userdata['user_session_time'];
//-- fin mod : Advanced Group Color Management ---------------------------------
if( $total_posts == 0 )
{
$l_total_post_s = $lang['Posted_articles_zero_total'];
}
else if( $total_posts == 1 )
{
$l_total_post_s = $lang['Posted_article_total'];
}
else
{
$l_total_post_s = $lang['Posted_articles_total'];
}
if( $total_users == 0 )
{
$l_total_user_s = $lang['Registered_users_zero_total'];
}
else if( $total_users == 1 )
{
$l_total_user_s = $lang['Registered_user_total'];
}
else
{
$l_total_user_s = $lang['Registered_users_total'];
}
//
// Start page proper
//
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
FROM " . CATEGORIES_TABLE . " c
ORDER BY c.cat_order";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
}
$category_rows = array();
while ($row = $db->sql_fetchrow($result))
{
$category_rows[] = $row;
}
$db->sql_freeresult($result);
// Begin Simple Subforums MOD
$subforums_list = array();
// End Simple Subforums MOD
if( ( $total_categories = count($category_rows) ) )
{
//
// Define appropriate SQL
//
switch(SQL_LAYER)
{
case 'postgresql':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE p.post_id = f.forum_last_post_id
AND u.user_id = p.poster_id
UNION (
SELECT f.*, NULL, NULL, NULL, NULL
FROM " . FORUMS_TABLE . " f
WHERE NOT EXISTS (
SELECT p.post_time
FROM " . POSTS_TABLE . " p
WHERE p.post_id = f.forum_last_post_id
)
)
ORDER BY cat_id, forum_order";
//-- mod : Advanced Group Color Management -------------------------------------
//-- add
$sql = str_replace('SELECT ', 'SELECT u.user_group_id, u.user_session_time, ', $sql);
//-- fin mod : Advanced Group Color Management ---------------------------------
break;
case 'oracle':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE p.post_id = f.forum_last_post_id(+)
AND u.user_id = p.poster_id(+)
ORDER BY f.cat_id, f.forum_order";
//-- mod : Advanced Group Color Management -------------------------------------
//-- add
$sql = str_replace('SELECT ', 'SELECT u.user_group_id, u.user_session_time, ', $sql);
//-- fin mod : Advanced Group Color Management ---------------------------------
break;
default:
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM (( " . FORUMS_TABLE . " f
LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
ORDER BY f.cat_id, f.forum_order";
//-- mod : Advanced Group Color Management -------------------------------------
//-- add
$sql = str_replace('SELECT ', 'SELECT u.user_group_id, u.user_session_time, ', $sql);
//-- fin mod : Advanced Group Color Management ---------------------------------
break;
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
}
$forum_data = array();
while( $row = $db->sql_fetchrow($result) )
{
$forum_data[] = $row;
}
$db->sql_freeresult($result);
if ( !($total_forums = count($forum_data)) )
{
message_die(GENERAL_MESSAGE, $lang['No_forums']);
}
//
// Obtain a list of topic ids which contain
// posts made since user last visited
//
if ($userdata['session_logged_in'])
{
// 60 days limit
if ($userdata['user_lastvisit'] < (time() - 5184000))
{
$userdata['user_lastvisit'] = time() - 5184000;
}
$sql = "SELECT t.forum_id, t.topic_id, p.post_time
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE p.post_id = t.topic_last_post_id
AND p.post_time > " . $userdata['user_lastvisit'] . "
AND t.topic_moved_id = 0";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
}
$new_topic_data = array();
while( $topic_data = $db->sql_fetchrow($result) )
{
$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
}
$db->sql_freeresult($result);
}
//
// Obtain list of moderators of each forum
// First users, then groups ... broken into two queries
//
$sql = "SELECT aa.forum_id, u.user_id, u.username
FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
WHERE aa.auth_mod = " . TRUE . "
AND g.group_single_user = 1
AND ug.group_id = aa.group_id
AND g.group_id = aa.group_id
AND u.user_id = ug.user_id
GROUP BY u.user_id, u.username, aa.forum_id
ORDER BY aa.forum_id, u.user_id";
//-- mod : Advanced Group Color Management -------------------------------------
//-- add
$sql = str_replace('SELECT ', 'SELECT u.user_group_id, u.user_session_time, ', $sql);
//-- fin mod : Advanced Group Color Management ---------------------------------
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}
$forum_moderators = array();
while( $row = $db->sql_fetchrow($result) )
{
//-- mod : Advanced Group Color Management -------------------------------------
//-- here we added
// class="' . $color->get_user_color($row['user_group_id'], $row['user_session_time']) . '"
//-- modify
$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '" class="' . $color->get_user_color($row['user_group_id'], $row['user_session_time']) . '">' . $row['username'] . '</a>';
//-- fin mod : Advanced Group Color Management ---------------------------------
}
$db->sql_freeresult($result);
if ( !$board_config['bday_hide'] || $userdata['session_logged_in'] )
{
// if birthday_display is set to "Display age (but not day or month)" (eg. BIRTHDAY_AGE), we don't display it here,
// since this code would make it trivially easy to extrapolate that information.
$sql = "SELECT user_id, username, user_birthday, birthday_display, user_level
FROM " . USERS_TABLE . "
WHERE user_birthday >= " . gmdate('md0000',time() + (3600 * $board_config['board_timezone'])) . "
AND user_birthday <= " . gmdate('md9999',time() + (3600 * $board_config['board_timezone']))."
AND user_active = 1
AND birthday_display <> " . BIRTHDAY_NONE . "
AND birthday_display <> " . BIRTHDAY_AGE . "
ORDER BY username DESC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query members birthday information', '', __LINE__, __FILE__, $sql);
}
$user_birthdays = array();
while ( $row = $db->sql_fetchrow($result) )
{
// if birthday_display is set to "Display day and month (but not year)" (eg. BIRTHDAY_DATE), set the year
// to 0.
$bday_year = ( $row['birthday_display'] != BIRTHDAY_DATE ) ? $row['user_birthday'] % 10000 : 0;
$age = ( $bday_year ) ? ' ('.(gmdate('Y')-$bday_year).')' : '';
$birthday_color = '';
if ( $row['user_level'] == ADMIN )
{
$birthday_color = ' style="color:#' . $theme['fontcolor3'] . '"';
}
else if ( $row['user_level'] == MOD )
{
$birthday_color = ' style="color:#' . $theme['fontcolor2'] . '"';
}
$user_birthdays[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $birthday_color . '>' . $row['username'] . '</a>' . $age;
}
$db->sql_freeresult($result);
$birthdays = (!empty($user_birthdays)) ?
sprintf($lang['Congratulations'],implode(', ',$user_birthdays)) :
$lang['No_birthdays'];
if ( $board_config['bday_lookahead'] != -1 )
{
$start = gmdate('md9999',strtotime('+'.$board_config['bday_lookahead'].' day') + (3600 * $board_config['board_timezone']));
$end = gmdate('md0000',strtotime('+1 day') + (3600 * $board_config['board_timezone']));
$operator = ($start > $end) ? 'AND' : 'OR';
$sql = "SELECT user_id, username, user_birthday, birthday_display, user_level
FROM " . USERS_TABLE . "
WHERE (user_birthday <= $start
$operator user_birthday >= $end)
AND user_birthday <> 0
AND user_active = 1
AND birthday_display <> " . BIRTHDAY_NONE . "
AND birthday_display <> " . BIRTHDAY_AGE . "
ORDER BY user_birthday ASC, username DESC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query upcoming birthday information', '', __LINE__, __FILE__, $sql);
}
$upcoming_birthdays = array();
while ( $row = $db->sql_fetchrow($result) )
{
$bday_month_day = floor($row['user_birthday'] / 10000);
$bday_year_age = ( $row['birthday_display'] != BIRTHDAY_DATE ) ? $row['user_birthday'] - 10000*$bday_month_day : 0;
$fudge = ( gmdate('md') < $bday_month_day ) ? 0 : 1;
$age = ( $bday_year_age ) ? ' ('.(gmdate('Y')-$bday_year_age+$fudge).')' : '';
$birthday_color = '';
if ( $row['user_level'] == ADMIN )
{
$birthday_color = ' style="color:#' . $theme['fontcolor3'] . '"';
}
else if ( $row['user_level'] == MOD )
{
$birthday_color = ' style="color:#' . $theme['fontcolor2'] . '"';
}
$upcoming_birthdays[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $birthday_color . '>' . $row['username'] . '</a>' . $age;
}
$upcoming = (!empty($upcoming_birthdays)) ?
sprintf($lang['Upcoming_birthdays'],$board_config['bday_lookahead'],implode(', ',$upcoming_birthdays)) :
sprintf($lang['No_upcoming'],$board_config['bday_lookahead']);
}
if ( !empty($user_birthdays) || !empty($upcoming_birthdays) || $board_config['bday_show'] )
{
$template->assign_block_vars('birthdays',array());
if ( !empty($upcoming_birthdays) || $board_config['bday_show'] )
{
$template->assign_block_vars('birthdays.upcoming',array());
}
}
}
$sql = "SELECT aa.forum_id, g.group_id, g.group_name
FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
WHERE aa.auth_mod = " . TRUE . "
AND g.group_single_user = 0
AND g.group_type <> " . GROUP_HIDDEN . "
AND ug.group_id = aa.group_id
AND g.group_id = aa.group_id
GROUP BY g.group_id, g.group_name, aa.forum_id
ORDER BY aa.forum_id, g.group_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
//-- mod : Advanced Group Color Management -------------------------------------
//-- here we added
// class="' . $color->get_user_color($row['group_id']) . '"
//-- modify
$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '" class="' . $color->get_user_color($row['group_id']) . '">' . $row['group_name'] . '</a>';
//-- fin mod : Advanced Group Color Management ---------------------------------
}
$db->sql_freeresult($result);
//
// Find which forums are visible for this user
//
$is_auth_ary = array();
$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);
//
// Start output of page
//
define('SHOW_ONLINE', true);
$page_title = $lang['Index'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
//START Remove Cookies
$cookie_link = '<a href="' . append_sid("remove_cookies.$phpEx") . '">' . $lang['Remove_cookies'] . '</a>';
//END Remove Cookies
$template->set_filenames(array(
'body' => 'index_body.tpl')
);
// User Stealth mod - start
if ($board_config['username_hide_inac'] && $userdata['user_level'] == ADMIN)
{
$fetched_rows = get_db_stat('inactive_total');
}
$username_inac_on = ( $board_config['username_hide_inac'] && $userdata['session_logged_in'] ) ? $lang['Newest_user_winac'] : $lang['Newest_user'];
$non_active = ( $board_config['username_hide_inac'] && $userdata['user_level'] == ADMIN ) ? ( $fetched_rows == 1 ) ? $lang['Non_active_on_index'] : $lang['Non_actives_on_index'] : '';
// User Stealth mod - end
$template->assign_vars(array(
'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
// Topics a user has started MOD, By Manipe (Begin)
'TOTAL_TOPICS' => sprintf($l_total_topic_s, $total_topics),
// Topics a user has started MOD, By Manipe (End)
'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
//-- mod : Advanced Group Color Management -------------------------------------
//-- delete
// 'NEWEST_USER' => sprintf($username_inac_on, '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">' , $newest_user , '</a>'),
'BIRTHDAYS' => $birthdays,
'UPCOMING' => $upcoming,
//-- add
'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '" class="' . $color->get_user_color($newest_user_group_id, $newest_user_session_time) . '">' , $newest_user , '</a>'),
//-- fin mod : Advanced Group Color Management ---------------------------------
// User Stealth mod - start (also replaced $lang['Newest_user'] with $username_inac_on on the line above)
'NON_ACTIVATED_FOR_ADMIN' => sprintf($non_active, '<b>' . $fetched_rows . '</b>', '<a href="' . append_sid("memberlist.$phpEx?mode=inactive") . '" . title="' . $lang['Non_active_explain'] . '". >', $lang['Non_active_link'], '</a>'),
// User Stealth mod - end
'FORUM_IMG' => $images['forum'],
'FORUM_NEW_IMG' => $images['forum_new'],
'FORUM_LOCKED_IMG' => $images['forum_locked'],
'L_TODAYS_BIRTHDAYS' => $lang['Todays_Birthdays'],
'L_VIEW_BIRTHDAYS' => $lang['View_Birthdays'],
'L_FORUM' => $lang['Forum'],
// Begin Simple Subforums MOD
'L_SUBFORUMS' => $lang['Subforums'],
// End Simple Subforums MOD
'L_TOPICS' => $lang['Topics'],
'L_REPLIES' => $lang['Replies'],
'L_VIEWS' => $lang['Views'],
'L_POSTS' => $lang['Posts'],
'L_LASTPOST' => $lang['Last_Post'],
'L_NO_NEW_POSTS' => $lang['No_new_posts'],
'L_NEW_POSTS' => $lang['New_posts'],
'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
'L_MODERATOR' => $lang['Moderators'],
'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],
//START Remove Cookies
'COOKIE_LINK' => $cookie_link,
//END Remove Cookies
'U_MARK_READ' => append_sid("index.$phpEx?mark=forums"))
);
//
// Let's decide which categories we should display
//
$display_categories = array();
for ($i = 0; $i < $total_forums; $i++ )
{
if ($is_auth_ary[$forum_data[$i]['forum_id']]['auth_view'])
{
$display_categories[$forum_data[$i]['cat_id']] = true;
}
}
//
// Okay, let's build the index
//
for($i = 0; $i < $total_categories; $i++)
{
$cat_id = $category_rows[$i]['cat_id'];
//
// Yes, we should, so first dump out the category
// title, then, if appropriate the forum list
//
if (isset($display_categories[$cat_id]) && $display_categories[$cat_id])
{
$template->assign_block_vars('catrow', array(
'CAT_ID' => $cat_id,
'CAT_DESC' => $category_rows[$i]['cat_title'],
// Start Mark Category Read MOD
'L_MARK_CAT_READ' => $lang['Mark_category_read'],
'U_MARK_CAT_READ' => append_sid("index.$phpEx?mark=category&" . POST_CAT_URL . "=$cat_id"),
// End Mark Category Read MOD
'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
);
// Start Mark Category Read MOD
if ( $userdata['session_logged_in'] )
{
$template->assign_block_vars('catrow.switch_user_logged_in', array() );
}
// End Mark Category Read MOD
if ( $viewcat == $cat_id || $viewcat == -1 )
{
for($j = 0; $j < $total_forums; $j++)
{
if ( $forum_data[$j]['cat_id'] == $cat_id )
{
$forum_id = $forum_data[$j]['forum_id'];
if ( $is_auth_ary[$forum_id]['auth_view'] )
{
if ( $forum_data[$j]['forum_status'] == FORUM_LOCKED )
{
$folder_image = $images['forum_locked'];
$folder_alt = $lang['Forum_locked'];
// Begin Simple Subforums MOD
$unread_topics = false;
$folder_images = array(
'default' => $folder_image,
'new' => $images['forum_locked'],
'sub' => ( isset($images['forums_locked']) ) ? $images['forums_locked'] : $images['forum_locked'],
'subnew' => ( isset($images['forums_locked']) ) ? $images['forums_locked'] : $images['forum_locked'],
'subalt' => $lang['Forum_locked'],
'subaltnew' => $lang['Forum_locked'],
);
// End Simple Subforums MOD
}
else
{
$unread_topics = false;
if ( $userdata['session_logged_in'] )
{
if ( !empty($new_topic_data[$forum_id]) )
{
$forum_last_post_time = 0;
while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
{
if ( empty($tracking_topics[$check_topic_id]) )
{
$unread_topics = true;
$forum_last_post_time = max($check_post_time, $forum_last_post_time);
}
else
{
if ( $tracking_topics[$check_topic_id] < $check_post_time )
{
$unread_topics = true;
$forum_last_post_time = max($check_post_time, $forum_last_post_time);
}
}
}
if ( !empty($tracking_forums[$forum_id]) )
{
if ( $tracking_forums[$forum_id] > $forum_last_post_time )
{
$unread_topics = false;
}
}
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
{
$unread_topics = false;
}
}
}
}
$folder_image = ( $unread_topics ) ? $images['forum_new'] : $images['forum'];
$folder_alt = ( $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts'];
// Begin Simple Subforums MOD
$folder_images = array(
'default' => $folder_image,
'new' => $images['forum_new'],
'sub' => ( isset($images['forums']) ) ? $images['forums'] : $images['forum'],
'subnew' => ( isset($images['forums_new']) ) ? $images['forums_new'] : $images['forum_new'],
'subalt' => $lang['No_new_posts'],
'subaltnew' => $lang['New_posts'],
);
// End Simple Subforums MOD
}
$posts = $forum_data[$j]['forum_posts'];
$topics = $forum_data[$j]['forum_topics'];
if ( $forum_data[$j]['forum_last_post_id'] )
{
$last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);
$last_post = $last_post_time . '<br />';
//-- mod : Advanced Group Color Management -------------------------------------
//-- delete
// $last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
//-- add
$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? '<span class="' . $color->get_user_color(GROUP_ANONYMOUS) . '">' . ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) . '</span>' : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $forum_data[$j]['user_id']) . '" class="' . $color->get_user_color($forum_data[$j]['user_group_id'], $forum_data[$j]['user_session_time']) . '">' . $forum_data[$j]['username'] . '</a> ';
//-- fin mod : Advanced Group Color Management ---------------------------------
$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
// Begin Simple Subforums MOD
$last_post_sub = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . ($unread_topics ? $images['icon_newest_reply'] : $images['icon_latest_reply']) . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
$last_post_time = $forum_data[$j]['post_time'];
// End Simple Subforums MOD
}
else
{
$last_post = $lang['No_Posts'];
// Begin Simple Subforums MOD
$last_post_sub = '<img src="' . $images['icon_minipost'] . '" border="0" alt="' . $lang['No_Posts'] . '" title="' . $lang['No_Posts'] . '" />';
$last_post_time = 0;
// End Simple Subforums MOD
}
if ( count($forum_moderators[$forum_id]) > 0 )
{
$l_moderators = ( count($forum_moderators[$forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
$moderator_list = implode(', ', $forum_moderators[$forum_id]);
}
else
{
$l_moderators = ' ';
$moderator_list = '';
}
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('catrow.forumrow', array(
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'FORUM_FOLDER_IMG' => $folder_image,
'FORUM_NAME' => $forum_data[$j]['forum_name'],
'FORUM_DESC' => $forum_data[$j]['forum_desc'],
'POSTS' => $forum_data[$j]['forum_posts'],
'TOPICS' => $forum_data[$j]['forum_topics'],
'LAST_POST' => $last_post,
'MODERATORS' => $moderator_list,
'L_MODERATOR' => $l_moderators,
'L_FORUM_FOLDER_ALT' => $folder_alt,
// Begin Simple Subforums MOD
'FORUM_FOLDERS' => serialize($folder_images),
'HAS_SUBFORUMS' => 0,
'PARENT' => $forum_data[$j]['forum_parent'],
'ID' => $forum_data[$j]['forum_id'],
'UNREAD' => intval($unread_topics),
'TOTAL_UNREAD' => intval($unread_topics),
'TOTAL_POSTS' => $forum_data[$j]['forum_posts'],
'TOTAL_TOPICS' => $forum_data[$j]['forum_topics'],
'LAST_POST_FORUM' => $last_post,
'LAST_POST_TIME' => $last_post_time,
'LAST_POST_TIME_FORUM' => $last_post_time,
// End Simple Subforums MOD
'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
);
// Begin Simple Subforums MOD
if( $forum_data[$j]['forum_parent'] )
{
$subforums_list[] = array(
'forum_data' => $forum_data[$j],
'folder_image' => $folder_image,
'last_post' => $last_post,
'last_post_sub' => $last_post_sub,
'moderator_list' => $moderator_list,
'unread_topics' => $unread_topics,
'l_moderators' => $l_moderators,
'folder_alt' => $folder_alt,
'last_post_time' => $last_post_time,
'desc' => $forum_data[$j]['forum_desc'],
);
}
// End Simple Subforums MOD
}
}
}
}
}
} // for ... categories
}// if ... total_categories
else
{
message_die(GENERAL_MESSAGE, $lang['No_forums']);
}
//
// Begin USERS ONLINE TODAY
// http://russ.isitaboat.co.uk/
//
$uot_this_timestamp_array = getdate();
$uot_when_from = mktime ( 0 , 0 , 0 , $uot_this_timestamp_array[mon] , $uot_this_timestamp_array[mday] , $uot_this_timestamp_array[year] );
$sql = "SELECT count(*) cnt
FROM ".USERS_TABLE." u
WHERE u.user_session_time >= ". $uot_when_from . "
ORDER BY u.username ASC";
if ( !($uot_result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($uot_result);
$uot_count = $row['cnt'];
$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, user_session_time
FROM ".USERS_TABLE." u
WHERE u.user_session_time >= ". $uot_when_from . "
ORDER BY u.username ASC";
if ( !($uot_result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
}
$users_online_today=array();
$uot_hidden_count = 0;
while ( $row = $db->sql_fetchrow($uot_result) )
{
//counter stuff
$$which_counter++;
$row_color = ( $$which_counter % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( $$which_counter % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
//generate the user name (robbed from the code above)
$uot_user_id = $row['user_id'];
//reset the style...
$uot_style = '';
if ( $uot_user_id != $prev_user )
{
$uot_username_plain = $uot_username = $row['username'];
if ( $row['user_level'] == ADMIN )
{
$uot_style = 'style="color:#' . $theme['fontcolor3'] . ';"';
$uot_username = '<b>' . $uot_username . '</b>';
}
else if ( $row['user_level'] == MOD )
{
$uot_style = 'style="color:#' . $theme['fontcolor2'] . ';"';
$uot_username = '<b>' . $uot_username . '</b>';
}
if ( !$row['user_allow_viewonline'] )
{
$uot_hidden_count++;
$view_online = ( $userdata['user_level'] == ADMIN ) ? true : false;
$uot_username = $lang['UOT_hidden_start'] . $uot_username . $lang['UOT_hidden_end'];
}
else
{
$view_online = true;
}
}
//annon does not have a profile...
if($row['user_id']>0){
$uot_username = sprintf('<a href="profile.php?mode=viewprofile&u=%d" title="%s was last here at: %s" %s>%s</a>',$uot_user_id,$uot_username_plain,create_date('g:ia', $row['user_session_time'], $board_config['board_timezone']),$uot_style,$uot_username);
}
//this will show just the user's name, with the time in the tool tip.
if($view_online)
{
array_push($users_online_today,$uot_username);
}
}
if(count($users_online_today)==0){
array_push($users_online_today,$lang['UOT_none']);
}
if( $userdata['user_level'] == ADMIN && $uot_hidden_count>0){
array_push($users_online_today,sprintf($lang['UOT_hidden'], $uot_hidden_count));
}
$template->assign_vars(array(
'UOT_TITLE' => $lang['UOT_title'],
'UOT_COUNT' => $uot_count,
'UOT_LIST' => implode(", ",$users_online_today)
)
);
//end of UOT
// Begin Simple Subforums MOD
unset($data);
unset($item);
unset($cat_item);
unset($row_item);
for( $i = 0; $i < count($subforums_list); $i++ )
{
$forum_data = $subforums_list[$i]['forum_data'];
$parent_id = $forum_data['forum_parent'];
// Find parent item
if( isset($template->_tpldata['catrow.']) )
{
$data = &$template->_tpldata['catrow.'];
$count = count($data);
for( $j = 0; $j < $count; $j++)
{
$cat_item = &$data[$j];
$row_item = &$cat_item['forumrow.'];
$count2 = count($row_item);
for( $k = 0; $k < $count2; $k++)
{
if( $row_item[$k]['ID'] == $parent_id )
{
$item = &$row_item[$k];
break;
}
}
if( isset($item) )
{
break;
}
}
}
if( isset($item) )
{
if( isset($item['sub.']) )
{
$num = count($item['sub.']);
$data = &$item['sub.'];
}
else
{
$num = 0;
$item[] = 'sub.';
$data = &$item['sub.'];
}
// Append new entry
$data[] = array(
'NUM' => $num,
'FORUM_FOLDER_IMG' => $subforums_list[$i]['folder_image'],
'FORUM_NAME' => $forum_data['forum_name'],
'FORUM_DESC' => $forum_data['forum_desc'],
'FORUM_DESC_HTML' => htmlspecialchars(preg_replace('@<[\/\!]*?[^<>]*?>@si', '', $forum_data['forum_desc'])),
'POSTS' => $forum_data['forum_posts'],
'TOPICS' => $forum_data['forum_topics'],
'LAST_POST' => $subforums_list[$i]['last_post'],
'LAST_POST_SUB' => $subforums_list[$i]['last_post_sub'],
'LAST_TOPIC' => $forum_data['topic_title'],
'MODERATORS' => $subforums_list[$i]['moderator_list'],
'PARENT' => $forum_data['forum_parent'],
'ID' => $forum_data['forum_id'],
'UNREAD' => intval($subforums_list[$i]['unread_topics']),
'L_MODERATOR' => $subforums_list[$i]['l_moderators'],
'L_FORUM_FOLDER_ALT' => $subforums_list[$i]['folder_alt'],
'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $forum_data['forum_id'])
);
$item['HAS_SUBFORUMS'] ++;
$item['TOTAL_UNREAD'] += intval($subforums_list[$i]['unread_topics']);
// Change folder image
$images = unserialize($item['FORUM_FOLDERS']);
$item['FORUM_FOLDER_IMG'] = $item['TOTAL_UNREAD'] ? $images['subnew'] : $images['sub'];
$item['L_FORUM_FOLDER_ALT'] = $item['TOTAL_UNREAD'] ? $images['subaltnew'] : $images['subalt'];
// Check last post
if( $item['LAST_POST_TIME'] < $subforums_list[$i]['last_post_time'] )
{
$item['LAST_POST'] = $subforums_list[$i]['last_post'];
$item['LAST_POST_TIME'] = $subforums_list[$i]['last_post_time'];
}
if( !$item['LAST_POST_TIME_FORUM'] )
{
$item['LAST_POST_FORUM'] = $item['LAST_POST'];
}
// Add topics/posts
$item['TOTAL_POSTS'] += $forum_data['forum_posts'];
$item['TOTAL_TOPICS'] += $forum_data['forum_topics'];
}
unset($item);
unset($data);
unset($cat_item);
unset($row_item);
}
// End Simple Subforums MOD
//-- mod : Advanced Group Color Management -------------------------------------
//-- add
//
// Display Legend
//
$color->display_legend();
//-- fin mod : Advanced Group Color Management ---------------------------------
//
// Generate the page
//
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>