Hmm double checked edits... now the stats have gone completely... ?
Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
/**
* @ignore
*/
define('IN_FORUM_INDEX', true);
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
display_forums('', $config['load_moderators']);
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts = $config['num_posts'];
$total_topics = $config['num_topics'];
$total_users = $config['num_users'];
$total_files = $config['num_files'];
$start_date = date("d M Y, H:i:s", $config['board_startdate'] );
$boarddays = ceil((time() - $config['board_startdate']) / 86400);
$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
$l_total_file_s = ($total_files == 0) ? 'TOTAL_FILES_ZERO' : 'TOTAL_FILES_OTHER';
$posts_per_day = $total_posts / $boarddays;
$l_posts_per_day_s = ($posts_per_day == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
$posts_per_year = $posts_per_day * 364.25;
$l_posts_per_year_s = ($posts_per_year == 0) ? 'POSTS_PER_YEAR_ZERO' : 'POSTS_PER_YEAR_OTHER';
$posts_per_user = $total_posts / $total_users;
$l_posts_per_user_s = ($posts_per_user == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
$posts_per_topic = $total_posts / $total_topics;
$l_posts_per_topic_s = ($posts_per_topic == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';
$topics_per_day = $total_topics / $boarddays;
$l_topics_per_day_s = ($topics_per_day == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
$topics_per_year = $topics_per_day * 364.25;
$l_topics_per_year_s = ($topics_per_year == 0) ? 'TOPICS_PER_YEAR_ZERO' : 'TOPICS_PER_YEAR_OTHER';
$topics_per_user = $total_topics / $total_users;
$l_topics_per_user_s = ($topics_per_user == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
$files_per_day = $total_files / $boarddays;
$l_files_per_day_s = ($files_per_day == 0) ? 'FILES_PER_DAY_ZERO' : 'FILES_PER_DAY_OTHER';
$files_per_year = $files_per_day * 364.25;
$l_files_per_year_s = ($files_per_year == 0) ? 'FILES_PER_YEAR_ZERO' : 'FILES_PER_YEAR_OTHER';
$files_per_user = $total_files / $total_users;
$l_files_per_user_s = ($files_per_day == 0) ? 'FILES_PER_USER_ZERO' : 'FILES_PER_USER_OTHER';
$users_per_day = $total_users / $boarddays;
$l_users_per_day_s = ($users_per_day == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
$users_per_year = $users_per_day * 364.25;
$l_users_per_year_s = ($users_per_year == 0) ? 'USERS_PER_YEAR_ZERO' : 'USERS_PER_YEAR_OTHER';
// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
$sql = 'SELECT group_id, group_name, group_colour, group_type
FROM ' . GROUPS_TABLE . '
WHERE group_legend = 1
ORDER BY group_name ASC';
}
else
{
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
ON (
g.group_id = ug.group_id
AND ug.user_id = ' . $user->data['user_id'] . '
AND ug.user_pending = 0
)
WHERE g.group_legend = 1
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);
$legend = array();
while ($row = $db->sql_fetchrow($result))
{
$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
{
$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
}
else
{
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
}
}
$db->sql_freeresult($result);
$legend = implode(', ', $legend);
// Generate birthday list if required ...
$birthday_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
{
$now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
// Display birthdays of 29th february on 28th february in non-leap-years
$leap_year_birthdays = '';
if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L'))
{
$leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
}
$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
FROM ' . USERS_TABLE . ' u
LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
WHERE (b.ban_id IS NULL
OR b.ban_exclude = 1)
AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)
AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
if ($age = (int) substr($row['user_birthday'], -4))
{
$birthday_list .= ' (' . max(0, $now['year'] - $age) . ')';
}
}
$db->sql_freeresult($result);
}
// Show amount of reported and queue posts for authenticated users
if ($auth->acl_getf_global('m_report') || $auth->acl_getf_global('m_approve'))
{
if (!function_exists('get_forum_list'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
}
$user->add_lang('mcp');
// Reported Posts
$forum_list = get_forum_list('m_report');
if (!empty($forum_list))
{
$sql = 'SELECT COUNT(r.report_id) AS total_reported
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
WHERE r.post_id = p.post_id
AND r.report_closed = 0
AND ' . $db->sql_in_set('p.forum_id', $forum_list);
$result = $db->sql_query($sql);
$total_reported = (int) $db->sql_fetchfield('total_reported');
$db->sql_freeresult($result);
if ($total_reported)
{
$template->assign_vars(array(
'L_REPORTS_TOTAL' => ($total_reported == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total_reported),
'U_MCP_REPORTS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports'))
);
}
}
// Reported PMs
$sql = 'SELECT COUNT(report_id) AS total_pm_reported
FROM ' . REPORTS_TABLE . '
WHERE pm_id <> 0
AND report_closed = 0';
$result = $db->sql_query($sql);
$total_pm_reported = (int) $db->sql_fetchfield('total_pm_reported');
$db->sql_freeresult($result);
if ($total_pm_reported)
{
$template->assign_vars(array(
'L_PM_REPORTS_TOTAL' => ($total_pm_reported == 1) ? $user->lang['PM_REPORT_TOTAL'] : sprintf($user->lang['PM_REPORTS_TOTAL'], $total_pm_reported),
'U_MCP_PM_REPORTS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports'))
);
}
// Posts and Topics in the Queue
$forum_list = get_forum_list('m_approve');
if (!empty($forum_list))
{
// Get the queue topics and posts in 1 query :)
$sql = 'SELECT COUNT(t.topic_id) AS total_queue_topics, (
SELECT COUNT(p.post_id)
FROM ' . POSTS_TABLE . ' p
WHERE p.post_approved = 0
AND ' . $db->sql_in_set('p.forum_id', $forum_list) . ' ) AS total_queue_posts
FROM ' . TOPICS_TABLE . ' t
WHERE t.topic_approved = 0
AND ' . $db->sql_in_set('t.forum_id', $forum_list);
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// Topics contain posts, so let's remove these
$total_queue_posts = $row['total_queue_posts'] - $row['total_queue_topics'];
$total_queue_topics = $row['total_queue_topics'];
if ($total_queue_posts)
{
$template->assign_vars(array(
'L_UNAPPROVED_POSTS_TOTAL' => ($total_queue_posts == 1) ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total_queue_posts),
'U_MCP_POSTS_QUEUE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_posts'))
);
}
if ($total_queue_topics)
{
$template->assign_vars(array(
'L_UNAPPROVED_TOPICS_TOTAL' => ($total_queue_topics == 1) ? $user->lang['UNAPPROVED_TOPIC_TOTAL'] : sprintf($user->lang['UNAPPROVED_TOPICS_TOTAL'], $total_queue_topics),
'U_MCP_TOPICS_QUEUE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics'))
);
}
}
}
// BEGIN Welcome Mod
//--Welcome_Mod--get the hour number-->
$date = $user->format_date(time(), 'H');
if ($user->data['is_registered'])
{
$u_user_name = get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']);
}
else
{
$u_user_name = $user->lang['WELCOME_GUEST'];
}
switch (true)
{
case ($date < 1):
// if the hour is 11am-12am (18-23)
$s_welcome = sprintf($user->lang['GOOD_NIGHT'], $u_user_name);;
break;
case ($date < 4):
// if the hour is 1-3 am
$s_welcome = sprintf($user->lang['UP_LATE'], $u_user_name);
break;
case ($date < 8):
// if the hour is 4-7 am
$s_welcome = sprintf($user->lang['UP_EARLY'], $u_user_name);
break;
case ($date < 12):
// if the hour is 8-11 am
$s_welcome = sprintf($user->lang['GOOD_MORNING'], $u_user_name);
break;
case ($date < 18):
// if the hour is 12-5pm
$s_welcome = sprintf($user->lang['GOOD_AFTERNOON'], $u_user_name);
break;
case ($date < 24):
// if the hour is 6pm-11pm
$s_welcome = sprintf($user->lang['GOOD_EVENING'], $u_user_name);;
break;
}
// how long a member for
$member_for = '';
if ($user->data['is_registered'] && !$user->data['is_bot'])
{
$member_length = time() - $user->data['user_regdate'];
$years = $months = $days = 0;
$member_for = '';
if ($member_length)
{
if ($member_length >= 31536000)
{
$years = floor($member_length / 31536000);
$member_length = $member_length - ($years * 31536000);
$member_for .= $years > 1 ? ($years . ' ' . $user->lang['WELCOME_YEARS'] . ', ') : ($years . ' ' . $user->lang['WELCOME_YEAR'] . ', ');
}
$months = floor($member_length / 2628000);
if ($months)
{
$months = $months > 1 ? ($months . ' ' . $user->lang['WELCOME_MONTHS'] . ', ') : ($months . ' ' . $user->lang['WELCOME_MONTHS'] . ', ');
$member_length = $member_length - ($months * 2628000);
$member_for .= $months;
}
$days = floor($member_length / 86400);
if ($days)
{
$days = $days > 1 ? ($days . ' ' . $user->lang['WELCOME_DAYS']) : ($days . ' ' . $user->lang['WELCOME_DAY']);
$member_for .= $days;
}
}
}
//END Welcome Mod
if (!class_exists('phpbb_mods_who_was_here'))
{
include($phpbb_root_path . 'includes/mods/who_was_here.' . $phpEx);
phpbb_mods_who_was_here::update_session();
}
phpbb_mods_who_was_here::display();
switch ($db->sql_layer)
{
case 'postgres':
$order_by = 'RANDOM()';
break;
case 'mssql':
case 'mssql_odbc':
$order_by = 'NEWID()';
break;
default:
$order_by = 'RAND()';
break;
}
$sql = 'SELECT user_id, user_type, username, user_colour
FROM ' . USERS_TABLE . ' WHERE group_id = 18 OR group_id = 21
ORDER BY ' . $order_by;
$result = $db->sql_query_limit($sql, 1);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('users', array(
'BOT_NAME' => $row['username'],
'BOT_COLOUR' => $row['user_colour'],
));
}
$db->sql_freeresult($result);
// Assign index specific vars
$template->assign_vars(array(
'TOTAL_POSTS' => sprintf($user->lang[$l_total_post_s], $total_posts),
'TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics),
'TOTAL_USERS' => sprintf($user->lang[$l_total_user_s], $total_users),
'POSTS_PER_DAY' => sprintf($user->lang[$l_posts_per_day_s], $posts_per_day),
'POSTS_PER_YEAR' => sprintf($user->lang[$l_posts_per_year_s], $posts_per_year),
'POSTS_PER_TOPIC' => sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic),
'POSTS_PER_USER' => sprintf($user->lang[$l_posts_per_user_s], $posts_per_user),
'TOPICS_PER_DAY' => sprintf($user->lang[$l_topics_per_day_s], $topics_per_day),
'TOPICS_PER_YEAR' => sprintf($user->lang[$l_topics_per_year_s], $topics_per_year),
'TOPICS_PER_USER' => sprintf($user->lang[$l_topics_per_user_s], $topics_per_user),
'TOTAL_FILES' => sprintf($user->lang[$l_total_file_s], $total_files),
'FILES_PER_DAY' => sprintf($user->lang[$l_files_per_day_s], $files_per_day),
'FILES_PER_YEAR' => sprintf($user->lang[$l_files_per_year_s], $files_per_year),
'FILES_PER_USER' => sprintf($user->lang[$l_files_per_user_s], $files_per_user),
'USERS_PER_DAY' => sprintf($user->lang[$l_users_per_day_s], $users_per_day),
'USERS_PER_YEAR' => sprintf($user->lang[$l_users_per_year_s], $users_per_year),
'START_DATE' => $start_date,
// BEGIN Welcome Mod
'S_WELCOME' => $s_welcome,
'S_JOINED_DATE' => $user->lang['JOINED'] . ': ' . $user->format_date($user->data['user_regdate']),
'USER_AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']),
'MEMBER_FOR' => (!empty($member_for)) ? $user->lang['MEMBER_FOR'] . ' ' . $member_for : '',
// END Welcome Mod
'FORUM_GOAL_TOP' => (!empty($config['forum_goals_display_top'])) ? true : false,
'FORUM_GOAL_BOTTOM' => (!empty($config['forum_goals_display_bottom'])) ? true : false,
'LEGEND' => $legend,
'BIRTHDAY_LIST' => $birthday_list,
'FORUM_IMG' => $user->img('forum_read', 'NO_UNREAD_POSTS'),
'FORUM_UNREAD_IMG' => $user->img('forum_unread', 'UNREAD_POSTS'),
'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
'FORUM_UNREAD_LOCKED_IMG' => $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false,
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums') : '',
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
//-- mod: Forum Goals ---------------------------------------------------------//
include($phpbb_root_path . 'includes/functions_forum_goals.' . $phpEx);
//-- end: Forum Goals ---------------------------------------------------------//
//-- mod: Top Stats ---------------------------------------------------------//
include($phpbb_root_path . 'includes/functions_top_stats.' . $phpEx);
//-- end: Top Stats ---------------------------------------------------------//
if (!empty($config['donation_index_enable']) && $config['donation_index_enable'] == 1)
{
$user->add_lang('mods/donate');
$template->assign_vars(array(
'DONATION_ACHIEVEMENT_ENABLE' => (isset($config['donation_achievement_enable'])) ? $config['donation_achievement_enable']:false,
'DONATION_ACHIEVEMENT' => (isset($config['donation_achievement'])) ? $config['donation_achievement']:false,
'DONATION_INDEX_ENABLE' => (isset($config['donation_index_enable'])) ? $config['donation_index_enable']:false,
'DONATION_GOAL_ENABLE' => (isset($config['donation_goal_enable'])) ? $config['donation_goal_enable']:false,
'DONATION_GOAL' => (isset($config['donation_goal'])) ? $config['donation_goal']:false,
'DONATION_GOAL_CURRENCY_ENABLE' => (isset($config['donation_goal_currency_enable'])) ? $config['donation_goal_currency_enable']:false,
'DONATION_GOAL_CURRENCY' => (isset($config['donation_goal_currency'])) ? $config['donation_goal_currency']:false,
));
}
if (!empty($config['donation_goal_enable']) && $config['donation_goal'] > 0)
{
$donation_goal_number = ($config['donation_achievement'] * 100) / $config['donation_goal'];
$donation_goal_rest = $config['donation_goal'] - $config['donation_achievement'];
$template->assign_vars(array(
'DONATION_GOAL_NUMBER' => number_format($donation_goal_number),
'DONATION_GOAL_REST' => $donation_goal_rest,
));
}
// Output page
page_header($user->lang['INDEX']);
$template->set_filenames(array(
'body' => 'index_body.html')
);
page_footer();
?>