phpBB
Statistics
| Revision:

root / trunk / phpBB / index.php

History | View | Annotate | Download (5.2 kB)

1
<?php
2
/**
3
*
4
* @package phpBB3
5
* @copyright (c) 2005 phpBB Group
6
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
*
8
*/
9
10
/**
11
*/
12
13
/**
14
* @ignore
15
*/
16
define('IN_PHPBB', true);
17
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
18
$phpEx = substr(strrchr(__FILE__, '.'), 1);
19
include($phpbb_root_path . 'common.' . $phpEx);
20
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
21
22
// Start session management
23
$user->session_begin();
24
$auth->acl($user->data);
25
$user->setup('viewforum');
26
27
display_forums('', $config['load_moderators']);
28
29
$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
30
// Grab group details for legend display
31
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
32
{
33
        $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
34
                FROM ' . GROUPS_TABLE . '
35
                WHERE group_legend > 0
36
                ORDER BY ' . $order_legend . ' ASC';
37
}
38
else
39
{
40
        $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend
41
                FROM ' . GROUPS_TABLE . ' g
42
                LEFT JOIN ' . USER_GROUP_TABLE . ' ug
43
                        ON (
44
                                g.group_id = ug.group_id
45
                                AND ug.user_id = ' . $user->data['user_id'] . '
46
                                AND ug.user_pending = 0
47
                        )
48
                WHERE g.group_legend > 0
49
                        AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
50
                ORDER BY g.' . $order_legend . ' ASC';
51
}
52
$result = $db->sql_query($sql);
53
54
$legend = array();
55
while ($row = $db->sql_fetchrow($result))
56
{
57
        $colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
58
        $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
59
60
        if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
61
        {
62
                $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
63
        }
64
        else
65
        {
66
                $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
67
        }
68
}
69
$db->sql_freeresult($result);
70
71
$legend = implode(', ', $legend);
72
73
// Generate birthday list if required ...
74
$birthday_list = array();
75
if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
76
{
77
        $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
78
79
        // Display birthdays of 29th february on 28th february in non-leap-years
80
        $leap_year_birthdays = '';
81
        if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L'))
82
        {
83
                $leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
84
        }
85
86
        $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
87
                FROM ' . USERS_TABLE . ' u
88
                LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
89
                WHERE (b.ban_id IS NULL
90
                        OR b.ban_exclude = 1)
91
                        AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)
92
                        AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
93
        $result = $db->sql_query($sql);
94
95
        while ($row = $db->sql_fetchrow($result))
96
        {
97
                $birthday_username        = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
98
                $birthday_year                = (int) substr($row['user_birthday'], -4);
99
                $birthday_age                = ($birthday_year) ? max(0, $now['year'] - $birthday_year) : '';
100
101
                $template->assign_block_vars('birthdays', array(
102
                        'USERNAME'        => $birthday_username,
103
                        'AGE'                => $birthday_age,
104
                ));
105
106
                // For 3.0 compatibility
107
                if ($age = (int) substr($row['user_birthday'], -4))
108
                {
109
                        $birthday_list[] = $birthday_username . (($birthday_year) ? ' (' . $birthday_age . ')' : '');
110
                }
111
        }
112
        $db->sql_freeresult($result);
113
}
114
115
// Assign index specific vars
116
$template->assign_vars(array(
117
        'TOTAL_POSTS'        => $user->lang('TOTAL_POSTS', (int) $config['num_posts']),
118
        'TOTAL_TOPICS'        => $user->lang('TOTAL_TOPICS', (int) $config['num_topics']),
119
        'TOTAL_USERS'        => $user->lang('TOTAL_USERS', (int) $config['num_users']),
120
        'NEWEST_USER'        => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
121
122
        'LEGEND'                => $legend,
123
        'BIRTHDAY_LIST'        => (empty($birthday_list)) ? '' : implode(', ', $birthday_list),
124
125
        'FORUM_IMG'                                => $user->img('forum_read', 'NO_UNREAD_POSTS'),
126
        'FORUM_UNREAD_IMG'                        => $user->img('forum_unread', 'UNREAD_POSTS'),
127
        'FORUM_LOCKED_IMG'                => $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
128
        'FORUM_UNREAD_LOCKED_IMG'        => $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),
129
130
        'S_LOGIN_ACTION'                        => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
131
        'S_DISPLAY_BIRTHDAY_LIST'        => ($config['load_birthdays']) ? true : false,
132
133
        'U_MARK_FORUMS'                => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
134
        'U_MCP'                                => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '')
135
);
136
137
// Output page
138
page_header($user->lang['INDEX']);
139
140
$template->set_filenames(array(
141
        'body' => 'index_body.html')
142
);
143
144
page_footer();