phpBB
Statistics
| Revision:

root / trunk / phpBB / index.php

History | View | Annotate | Download (5.2 kB)

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