phpBB
Statistics
| Revision:

root / tags / milestone_3 / phpBB / memberlist.php

History | View | Annotate | Download (43.9 kB)

1 272 thefinn
<?php
2 5114 acydburn
/**
3 5114 acydburn
*
4 5114 acydburn
* @package phpBB3
5 5114 acydburn
* @version $Id$
6 5114 acydburn
* @copyright (c) 2005 phpBB Group
7 5114 acydburn
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 5114 acydburn
*
9 5114 acydburn
*/
10 272 thefinn
11 5114 acydburn
/**
12 5114 acydburn
*/
13 4975 psotfx
define('IN_PHPBB', true);
14 2448 psotfx
$phpbb_root_path = './';
15 4484 psotfx
$phpEx = substr(strrchr(__FILE__, '.'), 1);
16 646 psotfx
include($phpbb_root_path . 'common.'.$phpEx);
17 646 psotfx
18 272 thefinn
// Start session management
19 5247 acydburn
$user->session_begin();
20 2958 psotfx
$auth->acl($user->data);
21 4970 psotfx
$user->setup(array('memberlist', 'groups'));
22 3969 psotfx
23 3628 psotfx
// Grab data
24 4578 psotfx
$mode                = request_var('mode', '');
25 4578 psotfx
$action                = request_var('action', '');
26 4578 psotfx
$user_id        = request_var('u', ANONYMOUS);
27 4970 psotfx
$group_id        = request_var('g', 0);
28 4578 psotfx
$topic_id        = request_var('t', 0);
29 3628 psotfx
30 3953 psotfx
switch ($mode)
31 3589 psotfx
{
32 3953 psotfx
        case 'email':
33 3953 psotfx
                break;
34 3969 psotfx
35 3953 psotfx
        default:
36 4883 acydburn
                // Can this user view profiles/memberlist?
37 3969 psotfx
                if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
38 3953 psotfx
                {
39 3953 psotfx
                        if ($user->data['user_id'] != ANONYMOUS)
40 3953 psotfx
                        {
41 5138 acydburn
                                trigger_error('NO_VIEW_USERS');
42 3953 psotfx
                        }
43 3650 psotfx
44 4970 psotfx
                        login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]);
45 3953 psotfx
                }
46 3953 psotfx
                break;
47 3589 psotfx
}
48 3589 psotfx
49 3953 psotfx
50 4578 psotfx
$start        = request_var('start', 0);
51 4578 psotfx
$submit = (isset($_POST['submit'])) ? true : false;
52 2849 psotfx
53 4578 psotfx
$sort_key = request_var('sk', 'c');
54 4578 psotfx
$sort_dir = request_var('sd', 'a');
55 2849 psotfx
56 2849 psotfx
57 3589 psotfx
// Grab rank information for later
58 4145 psotfx
$ranks = array();
59 5247 acydburn
$cache->obtain_ranks($ranks);
60 3510 psotfx
61 3510 psotfx
62 3650 psotfx
// What do you want to do today? ... oops, I think that line is taken ...
63 3625 psotfx
switch ($mode)
64 3598 psotfx
{
65 3650 psotfx
        case 'leaders':
66 5160 acydburn
                // Display a listing of board admins, moderators
67 5160 acydburn
68 5160 acydburn
                $user->add_lang('groups');
69 5160 acydburn
70 5199 acydburn
                $page_title = $user->lang['THE_TEAM'];
71 5160 acydburn
                $template_html = 'memberlist_leaders.html';
72 5160 acydburn
73 4883 acydburn
                $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false);
74 4758 psotfx
75 5160 acydburn
                $admin_id_ary = $mod_id_ary = $forum_id_ary = array();
76 4758 psotfx
                foreach ($user_ary as $forum_id => $forum_ary)
77 4758 psotfx
                {
78 4758 psotfx
                        foreach ($forum_ary as $auth_option => $id_ary)
79 4758 psotfx
                        {
80 5160 acydburn
                                (!$forum_id && $auth_option == 'a_') ? $admin_id_ary += $id_ary : $mod_id_ary += $id_ary;
81 5160 acydburn
82 5160 acydburn
                                if ($forum_id)
83 5160 acydburn
                                {
84 5160 acydburn
                                        foreach ($id_ary as $id)
85 5160 acydburn
                                        {
86 5160 acydburn
                                                $forum_id_ary[$id][] = $forum_id;
87 5160 acydburn
                                        }
88 5160 acydburn
                                }
89 4758 psotfx
                        }
90 4758 psotfx
                }
91 4758 psotfx
92 5160 acydburn
                $sql = 'SELECT forum_id, forum_name
93 5160 acydburn
                        FROM ' . FORUMS_TABLE . '
94 5160 acydburn
                        WHERE forum_type = ' . FORUM_POST;
95 4758 psotfx
                $result = $db->sql_query($sql);
96 5160 acydburn
97 5160 acydburn
                $forums = array();
98 5160 acydburn
                while ($row = $db->sql_fetchrow($result))
99 5160 acydburn
                {
100 5160 acydburn
                        $forums[$row['forum_id']] = $row['forum_name'];
101 5160 acydburn
                }
102 4758 psotfx
                $db->sql_freeresult($result);
103 4758 psotfx
104 5160 acydburn
                $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_rank, u.user_posts, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id
105 5160 acydburn
                        FROM ' . USERS_TABLE . ' u, ' . GROUPS_TABLE . ' g
106 5160 acydburn
                        LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.group_id = g.group_id AND ug.user_id = ' . $user->data['user_id'] . ')
107 5160 acydburn
                        WHERE u.user_id IN (' . implode(', ', $admin_id_ary + $mod_id_ary) . ')
108 5160 acydburn
                                AND u.group_id = g.group_id
109 5160 acydburn
                        ORDER BY g.group_name ASC, u.username ASC';
110 5160 acydburn
                $result = $db->sql_query($sql);
111 5160 acydburn
112 5160 acydburn
                while ($row = $db->sql_fetchrow($result))
113 4758 psotfx
                {
114 5160 acydburn
                        $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod';
115 5160 acydburn
116 5160 acydburn
                        $s_forum_select = '';
117 5160 acydburn
                        if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']])))
118 5160 acydburn
                        {
119 5160 acydburn
                                foreach ($forum_id_ary[$row['user_id']] as $forum_id)
120 5160 acydburn
                                {
121 5160 acydburn
                                        if (isset($forums[$forum_id]) && $auth->acl_get('f_list', $forum_id))
122 5160 acydburn
                                        {
123 5160 acydburn
                                                $s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>';
124 5160 acydburn
                                        }
125 5160 acydburn
                                }
126 5160 acydburn
                        }
127 5160 acydburn
128 5160 acydburn
                        if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
129 5160 acydburn
                        {
130 5160 acydburn
                                $group_name = $user->lang['UNDISCLOSED'];
131 5160 acydburn
                                $u_group = '';
132 5160 acydburn
                        }
133 5160 acydburn
                        else
134 5160 acydburn
                        {
135 5160 acydburn
                                $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
136 5160 acydburn
                                $u_group = "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=group&amp;g={$row['group_id']}";
137 5160 acydburn
                        }
138 5160 acydburn
139 5160 acydburn
                        $rank_title = $rank_img = '';
140 5160 acydburn
                        get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img);
141 5160 acydburn
142 5160 acydburn
                        $template->assign_block_vars($which_row, array(
143 5160 acydburn
                                'USER_ID'                => $row['user_id'],
144 5160 acydburn
                                'FORUMS'                => $s_forum_select,
145 5160 acydburn
                                'USERNAME'                => $row['username'],
146 5160 acydburn
                                'USER_COLOR'        => $row['user_colour'],
147 5160 acydburn
                                'RANK_TITLE'        => $rank_title,
148 5160 acydburn
                                'GROUP_NAME'        => $group_name,
149 5160 acydburn
                                'GROUP_COLOR'        => $row['group_colour'],
150 5160 acydburn
151 5160 acydburn
                                'RANK_IMG'                => $rank_img,
152 5160 acydburn
153 5160 acydburn
                                'U_GROUP'                => $u_group,
154 5199 acydburn
                                'U_VIEWPROFILE'        => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u={$row['user_id']}",
155 5218 bartvb
                                'U_PM'                        => ($auth->acl_get('u_sendpm')) ? "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=compose&amp;u={$row['user_id']}" : '')
156 5160 acydburn
                        );
157 4758 psotfx
                }
158 5160 acydburn
                $db->sql_freeresult($result);
159 4758 psotfx
160 5160 acydburn
                $template->assign_vars(array(
161 5160 acydburn
                        'PM_IMG'                => $user->img('btn_pm', $user->lang['MESSAGE']))
162 5160 acydburn
                );
163 3650 psotfx
                break;
164 3650 psotfx
165 3848 psotfx
        case 'contact':
166 3848 psotfx
                $page_title = $user->lang['IM_USER'];
167 3848 psotfx
                $template_html = 'memberlist_im.html';
168 4145 psotfx
169 4145 psotfx
                $presence_img = '';
170 4145 psotfx
                switch ($action)
171 4145 psotfx
                {
172 4145 psotfx
                        case 'icq':
173 4145 psotfx
                                $lang = 'ICQ';
174 4145 psotfx
                                $sql_field = 'user_icq';
175 4145 psotfx
                                $s_select = 'S_SEND_ICQ';
176 4145 psotfx
                                $s_action = 'http://wwp.icq.com/scripts/WWPMsg.dll';
177 4145 psotfx
                                break;
178 4145 psotfx
179 4145 psotfx
                        case 'aim':
180 4145 psotfx
                                $lang = 'AIM';
181 4145 psotfx
                                $sql_field = 'user_aim';
182 4145 psotfx
                                $s_select = 'S_SEND_AIM';
183 4145 psotfx
                                $s_action = '';
184 4145 psotfx
                                break;
185 4970 psotfx
186 4145 psotfx
                        case 'msnm':
187 4145 psotfx
                                $lang = 'MSNM';
188 4145 psotfx
                                $sql_field = 'user_msnm';
189 4145 psotfx
                                $s_select = 'S_SEND_MSNM';
190 4145 psotfx
                                $s_action = '';
191 4145 psotfx
                                break;
192 4145 psotfx
193 4145 psotfx
                        case 'jabber':
194 4145 psotfx
                                $lang = 'JABBER';
195 4145 psotfx
                                $sql_field = 'user_jabber';
196 4145 psotfx
                                $s_select = (@extension_loaded('xml')) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER';
197 5199 acydburn
                                $s_action = "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=contact&amp;action=$action&amp;u=$user_id";
198 4145 psotfx
                                break;
199 4883 acydburn
200 4883 acydburn
                        default:
201 4883 acydburn
                                $sql_field = '';
202 4883 acydburn
                                break;
203 4145 psotfx
                }
204 4145 psotfx
205 4145 psotfx
                // Grab relevant data
206 4970 psotfx
                $sql = "SELECT user_id, username, user_email, user_lang, $sql_field
207 4970 psotfx
                        FROM " . USERS_TABLE . "
208 5108 acydburn
                        WHERE user_id = $user_id
209 5108 acydburn
                                AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
210 4145 psotfx
                $result = $db->sql_query($sql);
211 4145 psotfx
212 4145 psotfx
                if (!($row = $db->sql_fetchrow($result)))
213 4145 psotfx
                {
214 5138 acydburn
                        trigger_error('NO_USER_DATA');
215 4145 psotfx
                }
216 4145 psotfx
                $db->sql_freeresult($result);
217 4145 psotfx
218 4145 psotfx
                // Post data grab actions
219 4145 psotfx
                switch ($action)
220 4145 psotfx
                {
221 4145 psotfx
                        case 'icq':
222 5199 acydburn
                                $presence_img = '<img src="http://web.icq.com/whitepages/online?icq=' . $row[$sql_field] . '&amp;img=5" width="18" height="18" alt="" />';
223 4145 psotfx
                                break;
224 4145 psotfx
225 4145 psotfx
                        case 'jabber':
226 4578 psotfx
                                if ($submit && @extension_loaded('xml'))
227 4145 psotfx
                                {
228 4578 psotfx
                                        include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
229 4145 psotfx
230 4578 psotfx
                                        $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
231 4578 psotfx
                                        $message = $_POST['message'];
232 4145 psotfx
233 4578 psotfx
                                        $messenger = new messenger();
234 4145 psotfx
235 4578 psotfx
                                        $messenger->template('profile_send_email', $row['user_lang']);
236 4578 psotfx
                                        $messenger->subject($subject);
237 4145 psotfx
238 4578 psotfx
                                        $messenger->replyto($user->data['user_email']);
239 4583 psotfx
                                        $messenger->im($row['user_jabber'], $row['username']);
240 4145 psotfx
241 4578 psotfx
                                        $messenger->assign_vars(array(
242 4578 psotfx
                                                'SITENAME'                => $config['sitename'],
243 4578 psotfx
                                                'BOARD_EMAIL'        => $config['board_contact'],
244 4578 psotfx
                                                'FROM_USERNAME' => $user->data['username'],
245 4578 psotfx
                                                'TO_USERNAME'        => $row['username'],
246 4578 psotfx
                                                'MESSAGE'                => $message)
247 4578 psotfx
                                        );
248 4145 psotfx
249 4578 psotfx
                                        $messenger->send(NOTIFY_IM);
250 5114 acydburn
                                        $messenger->save_queue();
251 4145 psotfx
252 4145 psotfx
                                        $s_select = 'S_SENT_JABBER';
253 4145 psotfx
                                }
254 4145 psotfx
                                break;
255 4145 psotfx
                }
256 4145 psotfx
257 4145 psotfx
                // Send vars to the template
258 4145 psotfx
                $template->assign_vars(array(
259 4970 psotfx
                        'IM_CONTACT'        => $row[$sql_field],
260 4970 psotfx
                        'USERNAME'                => addslashes($row['username']),
261 4970 psotfx
                        'EMAIL'                        => $row['user_email'],
262 4970 psotfx
                        'CONTACT_NAME'        => $row[$sql_field],
263 4145 psotfx
                        'SITENAME'                => addslashes($config['sitename']),
264 4145 psotfx
265 4970 psotfx
                        'PRESENCE_IMG'                => $presence_img,
266 4145 psotfx
267 4970 psotfx
                        'L_SEND_IM_EXPLAIN'        => $user->lang['IM_' . $lang],
268 4970 psotfx
                        'L_IM_SENT_JABBER'        => sprintf($user->lang['IM_SENT_JABBER'], $row['username']),
269 4145 psotfx
270 4970 psotfx
                        $s_select                        => true,
271 4145 psotfx
                        'S_IM_ACTION'                => $s_action)
272 4145 psotfx
                );
273 4145 psotfx
274 3848 psotfx
                break;
275 3848 psotfx
276 3625 psotfx
        case 'viewprofile':
277 3625 psotfx
                // Display a profile
278 3625 psotfx
                if ($user_id == ANONYMOUS)
279 3625 psotfx
                {
280 5138 acydburn
                        trigger_error('NO_USER');
281 3625 psotfx
                }
282 3589 psotfx
283 3625 psotfx
                // Do the SQL thang
284 4970 psotfx
                $sql = 'SELECT g.group_id, g.group_name, g.group_type
285 4970 psotfx
                        FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug
286 4970 psotfx
                        WHERE ug.user_id = $user_id
287 5160 acydburn
                                AND g.group_id = ug.group_id" . ((!$auth->acl_gets('a_group')) ? ' AND group_type <> ' . GROUP_HIDDEN : '') . '
288 3629 psotfx
                        ORDER BY group_type, group_name';
289 3625 psotfx
                $result = $db->sql_query($sql);
290 3589 psotfx
291 3628 psotfx
                $group_options = '';
292 3628 psotfx
                while ($row = $db->sql_fetchrow($result))
293 3625 psotfx
                {
294 3628 psotfx
                        $group_options .= '<option value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
295 3625 psotfx
                }
296 3672 psotfx
297 3672 psotfx
                // We left join on the session table to see if the user is currently online
298 5108 acydburn
                $sql = 'SELECT username, user_id, user_type, user_colour, user_permissions, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_allow_viewemail, user_posts, user_regdate, user_rank, user_from, user_occ, user_interests, user_website, user_email, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_avatar, user_avatar_width, user_avatar_height, user_avatar_type, user_lastvisit
299 4970 psotfx
                        FROM ' . USERS_TABLE . "
300 5108 acydburn
                        WHERE user_id = $user_id
301 5108 acydburn
                                AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
302 3672 psotfx
                $result = $db->sql_query($sql);
303 3672 psotfx
304 4065 psotfx
                if (!($member = $db->sql_fetchrow($result)))
305 3672 psotfx
                {
306 5138 acydburn
                        trigger_error('NO_USER');
307 3672 psotfx
                }
308 3672 psotfx
                $db->sql_freeresult($result);
309 3969 psotfx
310 4970 psotfx
                $sql = 'SELECT MAX(session_time) AS session_time
311 4065 psotfx
                        FROM ' . SESSIONS_TABLE . "
312 4065 psotfx
                        WHERE session_user_id = $user_id";
313 4065 psotfx
                $result = $db->sql_query($sql);
314 3969 psotfx
315 4065 psotfx
                $row = $db->sql_fetchrow($result);
316 4065 psotfx
                $db->sql_freeresult($result);
317 4065 psotfx
318 4065 psotfx
                $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
319 4065 psotfx
                unset($row);
320 4065 psotfx
321 4145 psotfx
                // Obtain list of forums where this users post count is incremented
322 3672 psotfx
                $auth2 = new auth();
323 4065 psotfx
                $auth2->acl($member);
324 4145 psotfx
                $f_postcount_ary = $auth2->acl_getf('f_postcount');
325 4970 psotfx
326 4145 psotfx
                $sql_forums = array();
327 4145 psotfx
                foreach ($f_postcount_ary as $forum_id => $allow)
328 3672 psotfx
                {
329 4924 acydburn
                        if ($allow['f_postcount'])
330 3672 psotfx
                        {
331 4145 psotfx
                                $sql_forums[] = $forum_id;
332 3672 psotfx
                        }
333 3672 psotfx
                }
334 4145 psotfx
335 4145 psotfx
                $post_count_sql = (sizeof($sql_forums)) ? 'AND f.forum_id IN (' . implode(', ', $sql_forums) . ')' : '';
336 4889 acydburn
                unset($sql_forums, $f_postcount_ary, $auth2);
337 3672 psotfx
338 3672 psotfx
                // Grab all the relevant data
339 4970 psotfx
                $sql = 'SELECT COUNT(p.post_id) AS num_posts
340 4145 psotfx
                        FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f
341 4970 psotfx
                        WHERE p.poster_id = $user_id
342 4970 psotfx
                                AND f.forum_id = p.forum_id
343 3672 psotfx
                                $post_count_sql";
344 3625 psotfx
                $result = $db->sql_query($sql);
345 563 uid42062
346 4262 psotfx
                $num_real_posts = min($user->data['user_posts'], $db->sql_fetchfield('num_posts', 0, $result));
347 3625 psotfx
                $db->sql_freeresult($result);
348 3510 psotfx
349 4889 acydburn
                // Change post_count_sql to an forum_id array the user is able to see
350 4889 acydburn
                $f_forum_ary = $auth->acl_getf('f_read');
351 3510 psotfx
352 4889 acydburn
                $sql_forums = array();
353 4889 acydburn
                foreach ($f_forum_ary as $forum_id => $allow)
354 4889 acydburn
                {
355 5160 acydburn
                        if (isset($allow['f_read']) && $allow['f_read'])
356 4889 acydburn
                        {
357 4889 acydburn
                                $sql_forums[] = $forum_id;
358 4889 acydburn
                        }
359 4889 acydburn
                }
360 3510 psotfx
361 4889 acydburn
                $post_count_sql = (sizeof($sql_forums)) ? 'AND f.forum_id IN (' . implode(', ', $sql_forums) . ')' : '';
362 4889 acydburn
                unset($sql_forums, $f_forum_ary);
363 4970 psotfx
364 4889 acydburn
                if ($post_count_sql)
365 4889 acydburn
                {
366 4970 psotfx
                        $sql = 'SELECT f.forum_id, f.forum_name, COUNT(post_id) AS num_posts
367 4970 psotfx
                                FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f
368 4970 psotfx
                                WHERE p.poster_id = $user_id
369 4970 psotfx
                                        AND f.forum_id = p.forum_id
370 4889 acydburn
                                        $post_count_sql
371 4970 psotfx
                                GROUP BY f.forum_id, f.forum_name
372 4970 psotfx
                                ORDER BY num_posts DESC";
373 4889 acydburn
                        $result = $db->sql_query_limit($sql, 1);
374 563 uid42062
375 4889 acydburn
                        $active_f_row = $db->sql_fetchrow($result);
376 4889 acydburn
                        $db->sql_freeresult($result);
377 3625 psotfx
378 4970 psotfx
                        $sql = 'SELECT t.topic_id, t.topic_title, COUNT(p.post_id) AS num_posts
379 4970 psotfx
                                FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
380 4970 psotfx
                                WHERE p.poster_id = $user_id
381 4970 psotfx
                                        AND t.topic_id = p.topic_id
382 4970 psotfx
                                        AND f.forum_id = t.forum_id
383 4889 acydburn
                                        $post_count_sql
384 4970 psotfx
                                GROUP BY t.topic_id, t.topic_title
385 4889 acydburn
                                ORDER BY num_posts DESC";
386 4889 acydburn
                        $result = $db->sql_query_limit($sql, 1);
387 4889 acydburn
388 4889 acydburn
                        $active_t_row = $db->sql_fetchrow($result);
389 4889 acydburn
                        $db->sql_freeresult($result);
390 4889 acydburn
                }
391 4889 acydburn
                else
392 4889 acydburn
                {
393 4889 acydburn
                        $active_f_row = $active_t_row = array();
394 4889 acydburn
                }
395 4889 acydburn
396 4970 psotfx
                // Do the relevant calculations
397 4065 psotfx
                $memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
398 4065 psotfx
                $posts_per_day = $member['user_posts'] / $memberdays;
399 3625 psotfx
                $percentage = ($config['num_posts']) ? min(100, ($num_real_posts / $config['num_posts']) * 100) : 0;
400 3625 psotfx
401 3625 psotfx
                $active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
402 3625 psotfx
                if (!empty($active_f_row['num_posts']))
403 3598 psotfx
                {
404 3625 psotfx
                        $active_f_name = $active_f_row['forum_name'];
405 3625 psotfx
                        $active_f_id = $active_f_row['forum_id'];
406 3625 psotfx
                        $active_f_count = $active_f_row['num_posts'];
407 4920 acydburn
                        $active_f_pct = ($member['user_posts']) ? ($active_f_count / $member['user_posts']) * 100 : 0;
408 3598 psotfx
                }
409 3625 psotfx
                unset($active_f_row);
410 3598 psotfx
411 3625 psotfx
                $active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
412 3625 psotfx
                if (!empty($active_t_row['num_posts']))
413 3598 psotfx
                {
414 3625 psotfx
                        $active_t_name = $active_t_row['topic_title'];
415 3625 psotfx
                        $active_t_id = $active_t_row['topic_id'];
416 3625 psotfx
                        $active_t_count = $active_t_row['num_posts'];
417 4920 acydburn
                        $active_t_pct = ($member['user_posts']) ? ($active_t_count / $member['user_posts']) * 100 : 0;
418 3598 psotfx
                }
419 3625 psotfx
                unset($active_t_row);
420 3598 psotfx
421 4145 psotfx
                if ($member['user_sig_bbcode_bitfield'] && $member['user_sig'])
422 4065 psotfx
                {
423 4065 psotfx
                        include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
424 4065 psotfx
                        $bbcode = new bbcode();
425 4065 psotfx
                        $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
426 4065 psotfx
                }
427 3625 psotfx
428 4145 psotfx
                if ($member['user_sig'])
429 4145 psotfx
                {
430 5108 acydburn
                        $member['user_sig'] = censor_text(smiley_text($member['user_sig']));
431 4145 psotfx
                }
432 4145 psotfx
433 4065 psotfx
                $poster_avatar = '';
434 4065 psotfx
                if (!empty($member['user_avatar']))
435 4065 psotfx
                {
436 4065 psotfx
                        switch ($member['user_avatar_type'])
437 4065 psotfx
                        {
438 4065 psotfx
                                case AVATAR_UPLOAD:
439 4065 psotfx
                                        $poster_avatar = $config['avatar_path'] . '/';
440 4065 psotfx
                                        break;
441 4065 psotfx
                                case AVATAR_GALLERY:
442 4065 psotfx
                                        $poster_avatar = $config['avatar_gallery_path'] . '/';
443 4065 psotfx
                                        break;
444 4065 psotfx
                        }
445 4065 psotfx
                        $poster_avatar .= $member['user_avatar'];
446 4065 psotfx
447 4076 psotfx
                        $poster_avatar = '<img src="' . $poster_avatar . '" width="' . $member['user_avatar_width'] . '" height="' . $member['user_avatar_height'] . '" border="0" alt="" />';
448 4065 psotfx
                }
449 4065 psotfx
450 4065 psotfx
                $template->assign_vars(show_profile($member));
451 4065 psotfx
452 4984 acydburn
                // Custom Profile Fields
453 4984 acydburn
                $profile_fields = array();
454 4984 acydburn
                if ($config['load_cpf_viewprofile'])
455 4984 acydburn
                {
456 4984 acydburn
                        include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
457 4984 acydburn
                        $cp = new custom_profile();
458 4984 acydburn
                        $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
459 4984 acydburn
                        $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
460 4984 acydburn
                }
461 4984 acydburn
462 3625 psotfx
                $template->assign_vars(array(
463 3625 psotfx
                        'POSTS_DAY'                        => sprintf($user->lang['POST_DAY'], $posts_per_day),
464 3625 psotfx
                        'POSTS_PCT'                        => sprintf($user->lang['POST_PCT'], $percentage),
465 4970 psotfx
                        'ACTIVE_FORUM'                => $active_f_name,
466 4970 psotfx
                        'ACTIVE_FORUM_POSTS'=> ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
467 4970 psotfx
                        'ACTIVE_FORUM_PCT'        => sprintf($user->lang['POST_PCT'], $active_f_pct),
468 5059 psotfx
                        'ACTIVE_TOPIC'                => censor_text($active_t_name),
469 4970 psotfx
                        'ACTIVE_TOPIC_POSTS'=> ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
470 4970 psotfx
                        'ACTIVE_TOPIC_PCT'        => sprintf($user->lang['POST_PCT'], $active_t_pct),
471 3625 psotfx
472 5059 psotfx
                        'OCCUPATION'        => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
473 5059 psotfx
                        'INTERESTS'                => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
474 4970 psotfx
                        'SIGNATURE'                => (!empty($member['user_sig'])) ? str_replace("\n", '<br />', $member['user_sig']) : '',
475 3625 psotfx
476 4065 psotfx
                        'AVATAR_IMG'        => $poster_avatar,
477 4145 psotfx
                        'PM_IMG'                => $user->img('btn_pm', $user->lang['MESSAGE']),
478 4145 psotfx
                        'EMAIL_IMG'                => $user->img('btn_email', $user->lang['EMAIL']),
479 4145 psotfx
                        'WWW_IMG'                => $user->img('btn_www', $user->lang['WWW']),
480 4145 psotfx
                        'ICQ_IMG'                => $user->img('btn_icq', $user->lang['ICQ']),
481 4145 psotfx
                        'AIM_IMG'                => $user->img('btn_aim', $user->lang['AIM']),
482 4145 psotfx
                        'MSN_IMG'                => $user->img('btn_msnm', $user->lang['MSNM']),
483 4145 psotfx
                        'YIM_IMG'                => $user->img('btn_yim', $user->lang['YIM']),
484 4970 psotfx
                        'JABBER_IMG'        => $user->img('btn_jabber', $user->lang['JABBER']),
485 4970 psotfx
                        'SEARCH_IMG'        => $user->img('btn_search', $user->lang['SEARCH']),
486 4065 psotfx
487 5160 acydburn
                        'S_PROFILE_ACTION'        => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=group",
488 4970 psotfx
                        'S_GROUP_OPTIONS'        => $group_options,
489 5138 acydburn
                        'S_CUSTOM_FIELDS'        => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,
490 3628 psotfx
491 4970 psotfx
                        'U_ADD_FRIEND'                => "ucp.$phpEx$SID&amp;i=zebra&amp;add=" . urlencode($member['username']),
492 5024 acydburn
                        'U_ADD_FOE'                        => "ucp.$phpEx$SID&amp;i=zebra&amp;mode=foes&amp;add=" . urlencode($member['username']),
493 3625 psotfx
                        'U_ACTIVE_FORUM'        => "viewforum.$phpEx$SID&amp;f=$active_f_id",
494 3625 psotfx
                        'U_ACTIVE_TOPIC'        => "viewtopic.$phpEx$SID&amp;t=$active_t_id",)
495 3625 psotfx
                );
496 5138 acydburn
497 5138 acydburn
                if (isset($profile_fields['row']) && sizeof($profile_fields['row']))
498 5138 acydburn
                {
499 5138 acydburn
                        $template->assign_vars($profile_fields['row']);
500 5138 acydburn
                }
501 5138 acydburn
502 5138 acydburn
                if (isset($profile_fields['blockrow']) && sizeof($profile_fields['blockrow']))
503 5138 acydburn
                {
504 5138 acydburn
                        foreach ($profile_fields['blockrow'] as $field_data)
505 5138 acydburn
                        {
506 5138 acydburn
                                $template->assign_block_vars('custom_fields', $field_data);
507 5138 acydburn
                        }
508 5138 acydburn
                }
509 3625 psotfx
510 5247 acydburn
                // Now generate page tilte
511 5247 acydburn
                $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']);
512 5247 acydburn
                $template_html = 'memberlist_view.html';
513 5247 acydburn
514 5247 acydburn
        break;
515 5247 acydburn
516 3625 psotfx
        case 'email':
517 3625 psotfx
                // Send an email
518 3625 psotfx
                $page_title = $user->lang['SEND_EMAIL'];
519 3625 psotfx
                $template_html = 'memberlist_email.html';
520 3625 psotfx
521 5138 acydburn
                if (!$config['email_enable'])
522 3598 psotfx
                {
523 5138 acydburn
                        trigger_error('EMAIL_DISABLED');
524 4145 psotfx
                }
525 4145 psotfx
526 5138 acydburn
                if (($user_id == ANONYMOUS || !$config['board_email_form']) && !$topic_id)
527 4145 psotfx
                {
528 5138 acydburn
                        trigger_error('NO_EMAIL');
529 3625 psotfx
                }
530 3598 psotfx
531 4145 psotfx
                if (!$auth->acl_get('u_sendemail'))
532 3598 psotfx
                {
533 5138 acydburn
                        trigger_error('NO_EMAIL');
534 3625 psotfx
                }
535 3598 psotfx
536 3625 psotfx
                // Are we trying to abuse the facility?
537 3625 psotfx
                if (time() - $user->data['user_emailtime'] < $config['flood_interval'])
538 3625 psotfx
                {
539 5138 acydburn
                        trigger_error('FLOOD_EMAIL_LIMIT');
540 3625 psotfx
                }
541 3625 psotfx
542 4578 psotfx
                $name                = strip_tags(request_var('name', ''));
543 4578 psotfx
                $email                = strip_tags(request_var('email', ''));
544 4578 psotfx
                $email_lang = request_var('lang', '');
545 4578 psotfx
                $subject        = request_var('subject', '');
546 4578 psotfx
                $message        = request_var('message', '');
547 4578 psotfx
                $cc                        = (!empty($_POST['cc_email'])) ? true : false;
548 3980 psotfx
549 3980 psotfx
                // Are we sending an email to a user on this board? Or are we sending a
550 3980 psotfx
                // topic heads-up message?
551 3980 psotfx
                if (!$topic_id)
552 3625 psotfx
                {
553 3980 psotfx
                        // Get the appropriate username, etc.
554 4970 psotfx
                        $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
555 4145 psotfx
                                FROM ' . USERS_TABLE . "
556 3980 psotfx
                                WHERE user_id = $user_id
557 4603 psotfx
                                        AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
558 3980 psotfx
                        $result = $db->sql_query($sql);
559 3625 psotfx
560 3980 psotfx
                        if (!($row = $db->sql_fetchrow($result)))
561 3598 psotfx
                        {
562 5138 acydburn
                                trigger_error('NO_USER');
563 3625 psotfx
                        }
564 3980 psotfx
                        $db->sql_freeresult($result);
565 3980 psotfx
566 3980 psotfx
                        // Can we send email to this user?
567 5138 acydburn
                        if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user'))
568 3625 psotfx
                        {
569 5138 acydburn
                                trigger_error('NO_EMAIL');
570 3625 psotfx
                        }
571 3980 psotfx
                }
572 3980 psotfx
                else
573 3980 psotfx
                {
574 4970 psotfx
                        $sql = 'SELECT forum_id, topic_title
575 4145 psotfx
                                FROM ' . TOPICS_TABLE . "
576 3980 psotfx
                                WHERE topic_id = $topic_id";
577 3980 psotfx
                        $result = $db->sql_query($sql);
578 3598 psotfx
579 3980 psotfx
                        if (!($row = $db->sql_fetchrow($result)))
580 3625 psotfx
                        {
581 5138 acydburn
                                trigger_error('NO_TOPIC');
582 3598 psotfx
                        }
583 3980 psotfx
                        $db->sql_freeresult($result);
584 3980 psotfx
585 3980 psotfx
                        if (!$auth->acl_get('f_read', $row['forum_id']))
586 3980 psotfx
                        {
587 5138 acydburn
                                trigger_error('NO_FORUM_READ');
588 3980 psotfx
                        }
589 3980 psotfx
590 3980 psotfx
                        if (!$auth->acl_get('f_email', $row['forum_id']))
591 3980 psotfx
                        {
592 5138 acydburn
                                trigger_error('NO_EMAIL');
593 3980 psotfx
                        }
594 3980 psotfx
                }
595 3980 psotfx
596 3980 psotfx
                // User has submitted a message, handle it
597 3980 psotfx
                $error = array();
598 4578 psotfx
                if ($submit)
599 3980 psotfx
                {
600 3980 psotfx
                        if (!$topic_id)
601 3980 psotfx
                        {
602 4970 psotfx
                                if (!$subject)
603 3980 psotfx
                                {
604 3980 psotfx
                                        $error[] = $user->lang['EMPTY_SUBJECT_EMAIL'];
605 3980 psotfx
                                }
606 3980 psotfx
607 4970 psotfx
                                if (!$message)
608 3980 psotfx
                                {
609 3980 psotfx
                                        $error[] = $user->lang['EMPTY_MESSAGE_EMAIL'];
610 3980 psotfx
                                }
611 3980 psotfx
                        }
612 3598 psotfx
                        else
613 3598 psotfx
                        {
614 4970 psotfx
                                if (!$email || !preg_match('#^.*?@(.*?\.)?[a-z0-9\-]+\.[a-z]{2,4}$#i', $email))
615 3980 psotfx
                                {
616 3980 psotfx
                                        $error[] = $user->lang['EMPTY_ADDRESS_EMAIL'];
617 3980 psotfx
                                }
618 3980 psotfx
619 4970 psotfx
                                if (!$name)
620 3980 psotfx
                                {
621 3980 psotfx
                                        $error[] = $user->lang['EMPTY_NAME_EMAIL'];
622 3980 psotfx
                                }
623 3598 psotfx
                        }
624 2673 psotfx
625 3980 psotfx
                        if (!sizeof($error))
626 3625 psotfx
                        {
627 4145 psotfx
                                $sql = 'UPDATE ' . USERS_TABLE . '
628 4145 psotfx
                                        SET user_emailtime = ' . time() . '
629 4145 psotfx
                                        WHERE user_id = ' . $user->data['user_id'];
630 3625 psotfx
                                $result = $db->sql_query($sql);
631 3598 psotfx
632 4578 psotfx
                                include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
633 3598 psotfx
634 4583 psotfx
                                $email_tpl        = (!$topic_id) ? 'profile_send_email' : 'email_notify';
635 3980 psotfx
                                $email_lang = (!$topic_id) ? $row['user_lang'] : $email_lang;
636 4583 psotfx
                                $email                = (!$topic_id) ? $row['user_email'] : $email;
637 3727 psotfx
638 4578 psotfx
                                $messenger = new messenger();
639 3980 psotfx
640 4578 psotfx
                                $messenger->template($email_tpl, $email_lang);
641 4578 psotfx
                                $messenger->subject($subject);
642 4578 psotfx
643 4578 psotfx
                                $messenger->replyto($user->data['user_email']);
644 4578 psotfx
                                $messenger->to($email, $row['username']);
645 4578 psotfx
646 4583 psotfx
                                if (!$topic_id)
647 4583 psotfx
                                {
648 4583 psotfx
                                        $messenger->im($row['user_jabber'], $row['username']);
649 4583 psotfx
                                }
650 4583 psotfx
651 4578 psotfx
                                if ($cc)
652 3625 psotfx
                                {
653 4578 psotfx
                                        $messenger->cc($user->data['user_email'], $user->data['username']);
654 3625 psotfx
                                }
655 3598 psotfx
656 4578 psotfx
                                $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
657 4578 psotfx
                                $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
658 4578 psotfx
                                $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
659 4578 psotfx
                                $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
660 3903 psotfx
661 4578 psotfx
                                $messenger->assign_vars(array(
662 3625 psotfx
                                        'SITENAME'                => $config['sitename'],
663 3727 psotfx
                                        'BOARD_EMAIL'        => $config['board_contact'],
664 5138 acydburn
                                        'FROM_USERNAME' => stripslashes($user->data['username']),
665 5138 acydburn
                                        'TO_USERNAME'        => ($topic_id) ? stripslashes($name) : stripslashes($row['username']),
666 4970 psotfx
                                        'MESSAGE'                => $message,
667 4970 psotfx
                                        'TOPIC_NAME'        => ($topic_id) ? strtr($row['topic_title'], array_flip(get_html_translation_table(HTML_ENTITIES))) : '',
668 4970 psotfx
669 4578 psotfx
                                        'U_TOPIC'        => ($topic_id) ? generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id" : '')
670 3625 psotfx
                                );
671 3727 psotfx
672 4758 psotfx
                                $messenger->send($row['user_notify_type']);
673 5114 acydburn
                                $messenger->save_queue();
674 3625 psotfx
675 3980 psotfx
                                meta_refresh(3, "index.$phpEx$SID");
676 4970 psotfx
                                $message = (!$topic_id) ? sprintf($user->lang['RETURN_INDEX'],  '<a href="' . "index.$phpEx$SID" . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'],  "<a href=\"viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=" . $row['topic_id'] . '">', '</a>');
677 3980 psotfx
                                trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message);
678 3625 psotfx
                        }
679 3625 psotfx
                }
680 3625 psotfx
681 3980 psotfx
                if ($topic_id)
682 3980 psotfx
                {
683 3980 psotfx
                        $template->assign_vars(array(
684 4970 psotfx
                                'EMAIL'                        => htmlspecialchars($email),
685 4970 psotfx
                                'NAME'                        => htmlspecialchars($name),
686 4970 psotfx
                                'TOPIC_TITLE'        => $row['topic_title'],
687 3980 psotfx
688 5138 acydburn
                                'U_TOPIC'        => "{$phpbb_root_path}viewtopic.$phpEx$SID&amp;f={$row['forum_id']}&amp;t=$topic_id",
689 3980 psotfx
690 3980 psotfx
                                'S_LANG_OPTIONS'=> ($topic_id) ? language_select($email_lang) : '')
691 3980 psotfx
                        );
692 3980 psotfx
                }
693 5138 acydburn
694 3598 psotfx
                $template->assign_vars(array(
695 4970 psotfx
                        'USERNAME'                => (!$topic_id) ? addslashes($row['username']) : '',
696 4970 psotfx
                        'ERROR_MESSAGE'        => (sizeof($error)) ? implode('<br />', $error) : '',
697 3510 psotfx
698 4970 psotfx
                        'L_EMAIL_BODY_EXPLAIN'        => (!$topic_id) ? $user->lang['EMAIL_BODY_EXPLAIN'] : $user->lang['EMAIL_TOPIC_EXPLAIN'],
699 3980 psotfx
700 5138 acydburn
                        'S_POST_ACTION' => (!$topic_id) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=email&amp;u=$user_id" : "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=email&amp;f=$forum_id&amp;t=$topic_id",
701 3980 psotfx
                        'S_SEND_USER'        => (!$topic_id) ? true : false)
702 3598 psotfx
                );
703 3625 psotfx
                break;
704 3024 psotfx
705 4970 psotfx
        case 'group':
706 3625 psotfx
        default:
707 3625 psotfx
                // The basic memberlist
708 3625 psotfx
                $page_title = $user->lang['MEMBERLIST'];
709 3625 psotfx
                $template_html = 'memberlist_body.html';
710 3024 psotfx
711 3625 psotfx
                // Sorting
712 5010 acydburn
                $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'e' => $user->lang['SORT_EMAIL'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER'], 'l' => $user->lang['SORT_LAST_ACTIVE'], 'm' => $user->lang['SORT_RANK']);
713 5010 acydburn
                $sort_key_sql = array('a' => 'u.username', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'e' => 'u.user_email', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber', 'l' => 'u.user_lastvisit', 'm' => 'u.user_rank DESC, u.user_posts');
714 3625 psotfx
715 3625 psotfx
                $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
716 3625 psotfx
717 3650 psotfx
                $s_sort_key = '';
718 3625 psotfx
                foreach ($sort_key_text as $key => $value)
719 3598 psotfx
                {
720 3625 psotfx
                        $selected = ($sort_key == $key) ? ' selected="selected"' : '';
721 3625 psotfx
                        $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
722 3625 psotfx
                }
723 3598 psotfx
724 3650 psotfx
                $s_sort_dir = '';
725 3625 psotfx
                foreach ($sort_dir_text as $key => $value)
726 3625 psotfx
                {
727 3625 psotfx
                        $selected = ($sort_dir == $key) ? ' selected="selected"' : '';
728 3625 psotfx
                        $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
729 3625 psotfx
                }
730 3598 psotfx
731 3848 psotfx
                // Additional sorting options for user search ... if search is enabled, if not
732 3848 psotfx
                // then only admins can make use of this (for ACP functionality)
733 5160 acydburn
                $sql_select = $sql_from = $sql_where = $order_by = '';
734 5160 acydburn
735 5160 acydburn
                $form        = request_var('form', '');
736 5160 acydburn
                $field        = request_var('field', '');
737 5160 acydburn
738 4578 psotfx
                if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_')))
739 3625 psotfx
                {
740 4578 psotfx
                        $username        = request_var('username', '');
741 4578 psotfx
                        $email                = request_var('email', '');
742 4578 psotfx
                        $icq                = request_var('icq', '');
743 4578 psotfx
                        $aim                = request_var('aim', '');
744 4578 psotfx
                        $yahoo                = request_var('yahoo', '');
745 4578 psotfx
                        $msn                = request_var('msn', '');
746 5010 acydburn
                        $jabber                = request_var('jabber', '');
747 5199 acydburn
                        $search_group_id        = request_var('search_group_id', 0);
748 4578 psotfx
749 4578 psotfx
                        $joined_select        = request_var('joined_select', 'lt');
750 4578 psotfx
                        $active_select        = request_var('active_select', 'lt');
751 4578 psotfx
                        $count_select        = request_var('count_select', 'eq');
752 4578 psotfx
                        $joined                        = explode('-', request_var('joined', ''));
753 4578 psotfx
                        $active                        = explode('-', request_var('active', ''));
754 5114 acydburn
                        $count                        = (request_var('count', '')) ? request_var('count', 0) : '';
755 4578 psotfx
                        $ipdomain                = request_var('ip', '');
756 4578 psotfx
757 3625 psotfx
                        $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
758 3625 psotfx
759 3625 psotfx
                        $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
760 3625 psotfx
                        $s_find_count = '';
761 3625 psotfx
                        foreach ($find_count as $key => $value)
762 3625 psotfx
                        {
763 3625 psotfx
                                $selected = ($count_select == $key) ? ' selected="selected"' : '';
764 3625 psotfx
                                $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
765 3625 psotfx
                        }
766 3625 psotfx
767 3625 psotfx
                        $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
768 3625 psotfx
                        $s_find_join_time = '';
769 3625 psotfx
                        foreach ($find_time as $key => $value)
770 3625 psotfx
                        {
771 3625 psotfx
                                $selected = ($joined_select == $key) ? ' selected="selected"' : '';
772 3625 psotfx
                                $s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
773 3625 psotfx
                        }
774 3625 psotfx
775 3625 psotfx
                        $s_find_active_time = '';
776 3625 psotfx
                        foreach ($find_time as $key => $value)
777 3625 psotfx
                        {
778 3625 psotfx
                                $selected = ($active_select == $key) ? ' selected="selected"' : '';
779 3625 psotfx
                                $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
780 3625 psotfx
                        }
781 3625 psotfx
782 5114 acydburn
                        $sql_where .= ($username) ? " AND u.username LIKE '" . str_replace('*', '%', $db->sql_escape($username)) . "'" : '';
783 5114 acydburn
                        $sql_where .= ($email) ? " AND u.user_email LIKE '" . str_replace('*', '%', $db->sql_escape($email)) . "' " : '';
784 5114 acydburn
                        $sql_where .= ($icq) ? " AND u.user_icq LIKE '" . str_replace('*', '%', $db->sql_escape($icq)) . "' " : '';
785 5114 acydburn
                        $sql_where .= ($aim) ? " AND u.user_aim LIKE '" . str_replace('*', '%', $db->sql_escape($aim)) . "' " : '';
786 5114 acydburn
                        $sql_where .= ($yahoo) ? " AND u.user_yim LIKE '" . str_replace('*', '%', $db->sql_escape($yahoo)) . "' " : '';
787 5114 acydburn
                        $sql_where .= ($msn) ? " AND u.user_msnm LIKE '" . str_replace('*', '%', $db->sql_escape($msn)) . "' " : '';
788 5010 acydburn
                        $sql_where .= ($jabber) ? " AND u.user_jabber LIKE '" . str_replace('*', '%', $db->sql_escape($jabber)) . "' " : '';
789 5114 acydburn
                        $sql_where .= (is_numeric($count)) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
790 4970 psotfx
                        $sql_where .= (sizeof($joined) > 1) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
791 4970 psotfx
                        $sql_where .= (sizeof($active) > 1) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
792 5199 acydburn
                        $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id " : '';
793 5199 acydburn
794 5199 acydburn
                        if ($search_group_id)
795 5199 acydburn
                        {
796 5199 acydburn
                                $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
797 5199 acydburn
                        }
798 3625 psotfx
799 5160 acydburn
                        if ($ipdomain && $auth->acl_get('m_ip'))
800 3625 psotfx
                        {
801 3625 psotfx
                                $ips = (preg_match('#[a-z]#', $ipdomain)) ? implode(', ', preg_replace('#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#', "'\\1'", gethostbynamel($ipdomain))) : "'" . str_replace('*', '%', $ipdomain) . "'";
802 3625 psotfx
803 4970 psotfx
                                $sql = 'SELECT DISTINCT poster_id
804 4970 psotfx
                                        FROM ' . POSTS_TABLE . '
805 4262 psotfx
                                        WHERE poster_ip ' . ((preg_match('#%#', $ips)) ? 'LIKE' : 'IN') . " ($ips)";
806 3625 psotfx
                                $result = $db->sql_query($sql);
807 3625 psotfx
808 3625 psotfx
                                if ($row = $db->sql_fetchrow($result))
809 3625 psotfx
                                {
810 4578 psotfx
                                        $ip_sql = array();
811 3625 psotfx
                                        do
812 3625 psotfx
                                        {
813 4578 psotfx
                                                $ip_sql[] = $row['poster_id'];
814 3625 psotfx
                                        }
815 3625 psotfx
                                        while ($row = $db->sql_fetchrow($result));
816 3625 psotfx
817 4970 psotfx
                                        $sql_where .= ' AND u.user_id IN (' . implode(', ', $ip_sql) . ')';
818 3625 psotfx
                                }
819 3625 psotfx
                                else
820 3625 psotfx
                                {
821 3625 psotfx
                                        // A minor fudge but it does the job :D
822 4970 psotfx
                                        $sql_where .= " AND u.user_id IN ('-1')";
823 3625 psotfx
                                }
824 3625 psotfx
                        }
825 3625 psotfx
                }
826 3625 psotfx
827 5160 acydburn
                $first_char = request_var('first_char', '');
828 5160 acydburn
829 5160 acydburn
                if ($first_char == 'other')
830 5160 acydburn
                {
831 5160 acydburn
                        $sql_where = '';
832 5160 acydburn
                        for ($i = 65; $i < 91; $i++)
833 5160 acydburn
                        {
834 5160 acydburn
                                $sql_where .= " AND u.username NOT LIKE '" . chr($i) . "%'";
835 5160 acydburn
                        }
836 5160 acydburn
                }
837 5160 acydburn
                else if ($first_char)
838 5160 acydburn
                {
839 5160 acydburn
                        $sql_where = " AND u.username LIKE '" . $db->sql_escape(substr($first_char, 0, 1)) . "%'";
840 5160 acydburn
                }
841 5199 acydburn
842 4970 psotfx
                // Are we looking at a usergroup? If so, fetch additional info
843 4970 psotfx
                // and further restrict the user info query
844 4970 psotfx
                if ($mode == 'group')
845 4970 psotfx
                {
846 5160 acydburn
                        // We JOIN here to save a query for determining membership for hidden groups. ;)
847 5160 acydburn
                        $sql = 'SELECT g.*, ug.user_id
848 5160 acydburn
                                FROM ' . GROUPS_TABLE . ' g
849 5160 acydburn
                                LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_id = ' . $user->data['user_id'] . " AND ug.group_id = $group_id)
850 5160 acydburn
                                WHERE g.group_id = $group_id";
851 4970 psotfx
                        $result = $db->sql_query($sql);
852 4970 psotfx
853 5160 acydburn
                        if (!$group_row = $db->sql_fetchrow($result))
854 4970 psotfx
                        {
855 5138 acydburn
                                trigger_error('NO_GROUP');
856 4970 psotfx
                        }
857 4970 psotfx
                        $db->sql_freeresult($result);
858 4970 psotfx
859 5160 acydburn
                        switch ($group_row['group_type'])
860 4970 psotfx
                        {
861 4970 psotfx
                                case GROUP_OPEN:
862 5199 acydburn
                                        $group_row['l_group_type'] = 'OPEN';
863 4970 psotfx
                                        break;
864 4970 psotfx
                                case GROUP_CLOSED:
865 5199 acydburn
                                        $group_row['l_group_type'] = 'CLOSED';
866 4970 psotfx
                                        break;
867 4970 psotfx
                                case GROUP_HIDDEN:
868 5199 acydburn
                                        $group_row['l_group_type'] = 'HIDDEN';
869 5160 acydburn
870 5160 acydburn
                                        // Check for membership or special permissions
871 5160 acydburn
                                        if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id'])
872 5160 acydburn
                                        {
873 5160 acydburn
                                                trigger_error('NO_GROUP');
874 5160 acydburn
                                        }
875 4970 psotfx
                                        break;
876 4970 psotfx
                                case GROUP_SPECIAL:
877 5199 acydburn
                                        $group_row['l_group_type'] = 'SPECIAL';
878 4970 psotfx
                                        break;
879 4970 psotfx
                                case GROUP_FREE:
880 5199 acydburn
                                        $group_row['l_group_type'] = 'FREE';
881 4970 psotfx
                                        break;
882 4970 psotfx
                        }
883 4970 psotfx
884 4970 psotfx
                        $avatar_img = '';
885 5160 acydburn
                        if ($group_row['group_avatar'])
886 4970 psotfx
                        {
887 5160 acydburn
                                switch ($group_row['group_avatar_type'])
888 4970 psotfx
                                {
889 4970 psotfx
                                        case AVATAR_UPLOAD:
890 4970 psotfx
                                                $avatar_img = $phpbb_root_path . $config['avatar_path'] . '/';
891 4970 psotfx
                                                break;
892 4970 psotfx
                                        case AVATAR_GALLERY:
893 4970 psotfx
                                                $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
894 4970 psotfx
                                                break;
895 4970 psotfx
                                }
896 5160 acydburn
                                $avatar_img .= $group_row['group_avatar'];
897 4970 psotfx
898 5160 acydburn
                                $avatar_img = '<img src="' . $avatar_img . '" width="' . $group_row['group_avatar_width'] . '" height="' . $group_row['group_avatar_height'] . '" border="0" alt="" />';
899 4970 psotfx
                        }
900 4970 psotfx
901 4970 psotfx
                        $rank_title = $rank_img = '';
902 5160 acydburn
                        if ($group_row['group_rank'] != -1)
903 4970 psotfx
                        {
904 5160 acydburn
                                $rank_title = $ranks['special'][$group_row['group_rank']]['rank_title'];
905 5160 acydburn
                                $rank_img = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] . '" border="0" alt="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" title="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" /><br />' : '';
906 4970 psotfx
                        }
907 5160 acydburn
                        else if ($group_row['group_rank'] == -1)
908 5160 acydburn
                        {
909 5160 acydburn
                                $rank_title = '';
910 5160 acydburn
                                $rank_img = '';
911 5160 acydburn
                        }
912 4970 psotfx
913 4970 psotfx
                        $template->assign_vars(array(
914 5160 acydburn
                                'GROUP_DESC'        => $group_row['group_description'],
915 5199 acydburn
                                'GROUP_NAME'        => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],
916 5160 acydburn
                                'GROUP_COLOR'        => $group_row['group_colour'],
917 5199 acydburn
                                'GROUP_TYPE'        => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
918 4970 psotfx
                                'GROUP_RANK'        => $rank_title,
919 4970 psotfx
920 4970 psotfx
                                'AVATAR_IMG'        => $avatar_img,
921 4970 psotfx
                                'RANK_IMG'                => $rank_img,
922 4970 psotfx
923 5160 acydburn
                                'U_PM'                        => ($auth->acl_get('u_sendpm') && $group_row['group_receive_pm'] && $config['allow_mass_pm']) ? "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=compose&amp;g=$group_id" : '',)
924 4970 psotfx
                        );
925 4970 psotfx
926 5160 acydburn
                        $sql_select = ', ug.group_leader';
927 4970 psotfx
                        $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
928 5160 acydburn
                        $order_by = 'ug.group_leader DESC, ';
929 5160 acydburn
930 4970 psotfx
                        $sql_where .= " AND u.user_id = ug.user_id AND ug.group_id = $group_id";
931 4970 psotfx
                }
932 5160 acydburn
933 3625 psotfx
                // Sorting and order
934 5160 acydburn
                $order_by .= $sort_key_sql[$sort_key] . '  ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
935 3625 psotfx
936 3625 psotfx
                // Count the users ...
937 4970 psotfx
                if ($sql_where)
938 3712 psotfx
                {
939 4970 psotfx
                        $sql = 'SELECT COUNT(u.user_id) AS total_users
940 4970 psotfx
                                FROM ' . USERS_TABLE . " u$sql_from
941 5108 acydburn
                                WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
942 4970 psotfx
                                $sql_where";
943 3712 psotfx
                        $result = $db->sql_query($sql);
944 3625 psotfx
945 3712 psotfx
                        $total_users = ($row = $db->sql_fetchrow($result)) ? $row['total_users'] : 0;
946 5160 acydburn
                        $db->sql_freeresult($result);
947 3712 psotfx
                }
948 3712 psotfx
                else
949 3712 psotfx
                {
950 3712 psotfx
                        $total_users = $config['num_users'];
951 3712 psotfx
                }
952 3625 psotfx
953 5160 acydburn
                $s_char_options = '<option value=""' . ((!$first_char) ? ' selected="selected"' : '') . '>&nbsp; &nbsp;</option>';
954 5160 acydburn
                for ($i = 65; $i < 91; $i++)
955 5160 acydburn
                {
956 5160 acydburn
                        $s_char_options .= '<option value="' . chr($i) . '"' . (($first_char == chr($i)) ? ' selected="selected"' : '') . '>' . chr($i) . '</option>';
957 5160 acydburn
                }
958 5160 acydburn
                $s_char_options .= '<option value="other"' . (($first_char == 'other') ? ' selected="selected"' : '') . '>Other</option>';
959 5160 acydburn
960 3625 psotfx
                // Pagination string
961 5160 acydburn
                $pagination_url = "{$phpbb_root_path}memberlist.$phpEx$SID";
962 3625 psotfx
963 3897 psotfx
                // Build a relevant pagination_url
964 4578 psotfx
                $global_var = ($submit) ? '_POST' : '_GET';
965 3897 psotfx
                foreach ($$global_var as $key => $var)
966 3625 psotfx
                {
967 4578 psotfx
                        if (in_array($key, array('submit', 'start', 'mode')) || !$var)
968 3650 psotfx
                        {
969 3897 psotfx
                                continue;
970 3650 psotfx
                        }
971 4578 psotfx
                        $pagination_url .= '&amp;' . $key . '=' . urlencode(htmlspecialchars($var));
972 3897 psotfx
                }
973 3650 psotfx
974 5160 acydburn
                $u_hide_find_member = $pagination_url;
975 5160 acydburn
                $pagination_url .= "&amp;mode=$mode&amp;first_char=$first_char";
976 5160 acydburn
977 3897 psotfx
                // Some search user specific data
978 4578 psotfx
                if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_')))
979 3897 psotfx
                {
980 5199 acydburn
                        $group_selected = request_var('search_group_id', 0);
981 5199 acydburn
                        $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '>&nbsp;</option>';
982 5199 acydburn
983 5199 acydburn
                        $sql = 'SELECT group_id, group_name, group_type
984 5199 acydburn
                                FROM ' . GROUPS_TABLE . '
985 5199 acydburn
                                WHERE group_type <> ' . GROUP_HIDDEN . '
986 5199 acydburn
                                ORDER BY group_name ASC';
987 5199 acydburn
                        $result = $db->sql_query($sql);
988 5199 acydburn
989 5199 acydburn
                        while ($row = $db->sql_fetchrow($result))
990 5199 acydburn
                        {
991 5199 acydburn
                                $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
992 5199 acydburn
                        }
993 5199 acydburn
                        $db->sql_freeresult($result);
994 5199 acydburn
995 3625 psotfx
                        $template->assign_vars(array(
996 3625 psotfx
                                'USERNAME'        => $username,
997 3625 psotfx
                                'EMAIL'                => $email,
998 3625 psotfx
                                'ICQ'                => $icq,
999 3625 psotfx
                                'AIM'                => $aim,
1000 3625 psotfx
                                'YAHOO'                => $yahoo,
1001 3625 psotfx
                                'MSNM'                => $msn,
1002 5010 acydburn
                                'JABBER'        => $jabber,
1003 3625 psotfx
                                'JOINED'        => implode('-', $joined),
1004 3625 psotfx
                                'ACTIVE'        => implode('-', $active),
1005 4970 psotfx
                                'COUNT'                => $count,
1006 4970 psotfx
                                'IP'                => $ipdomain,
1007 3625 psotfx
1008 3625 psotfx
                                'S_SEARCH_USER'                 => true,
1009 3625 psotfx
                                'S_FORM_NAME'                         => $form,
1010 3625 psotfx
                                'S_FIELD_NAME'                         => $field,
1011 3625 psotfx
                                'S_COUNT_OPTIONS'                 => $s_find_count,
1012 3625 psotfx
                                'S_SORT_OPTIONS'                 => $s_sort_key,
1013 3625 psotfx
                                'S_JOINED_TIME_OPTIONS' => $s_find_join_time,
1014 3625 psotfx
                                'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time,
1015 5199 acydburn
                                'S_GROUP_SELECT'                => $s_group_select,
1016 5138 acydburn
                                'S_SEARCH_ACTION'                 => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=$form&amp;field=$field")
1017 3598 psotfx
                        );
1018 3625 psotfx
                }
1019 3598 psotfx
1020 4970 psotfx
                $sql = 'SELECT session_user_id, MAX(session_time) AS session_time
1021 4970 psotfx
                        FROM ' . SESSIONS_TABLE . '
1022 5160 acydburn
                        WHERE session_time >= ' . (time() - $config['session_length']) . '
1023 3628 psotfx
                                AND session_user_id <> ' . ANONYMOUS . '
1024 3628 psotfx
                        GROUP BY session_user_id';
1025 3628 psotfx
                $result = $db->sql_query($sql);
1026 3628 psotfx
1027 3628 psotfx
                $session_times = array();
1028 3628 psotfx
                while ($row = $db->sql_fetchrow($result))
1029 3628 psotfx
                {
1030 3628 psotfx
                        $session_times[$row['session_user_id']] = $row['session_time'];
1031 3628 psotfx
                }
1032 3628 psotfx
                $db->sql_freeresult($result);
1033 3628 psotfx
1034 3625 psotfx
                // Do the SQL thang
1035 5160 acydburn
                $sql = "SELECT u.username, u.user_id, u.user_colour, u.user_allow_viewemail, u.user_posts, u.user_regdate, u.user_rank, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_msnm, u.user_jabber, u.user_avatar, u.user_avatar_type, u.user_lastvisit
1036 5160 acydburn
                                $sql_select
1037 5160 acydburn
                        FROM " . USERS_TABLE . " u
1038 5160 acydburn
                                $sql_from
1039 4970 psotfx
                        WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
1040 4970 psotfx
                                $sql_where
1041 3712 psotfx
                        ORDER BY $order_by";
1042 3712 psotfx
                $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
1043 3625 psotfx
1044 5138 acydburn
                $id_cache = array();
1045 5138 acydburn
                while ($row = $db->sql_fetchrow($result))
1046 3625 psotfx
                {
1047 5138 acydburn
                        $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : '';
1048 5138 acydburn
1049 5138 acydburn
                        $id_cache[$row['user_id']] = $row;
1050 5138 acydburn
                }
1051 5138 acydburn
                $db->sql_freeresult($result);
1052 5138 acydburn
1053 5138 acydburn
                // Load custom profile fields
1054 5138 acydburn
                if ($config['load_cpf_memberlist'])
1055 5138 acydburn
                {
1056 5138 acydburn
                        include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
1057 5138 acydburn
                        $cp = new custom_profile();
1058 5138 acydburn
1059 5138 acydburn
                        // Grab all profile fields from users in id cache for later use - similar to the poster cache
1060 5138 acydburn
                        $profile_fields_cache = $cp->generate_profile_fields_template('grab', array_keys($id_cache));
1061 5138 acydburn
                }
1062 5138 acydburn
1063 5138 acydburn
                $i = 0;
1064 5138 acydburn
                foreach ($id_cache as $user_id => $row)
1065 5138 acydburn
                {
1066 5138 acydburn
                        $cp_row = array();
1067 5138 acydburn
                        if ($config['load_cpf_memberlist'])
1068 3625 psotfx
                        {
1069 5138 acydburn
                                $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array();
1070 5138 acydburn
                        }
1071 3628 psotfx
1072 5138 acydburn
                        $memberrow = array_merge(show_profile($row), array(
1073 5138 acydburn
                                'ROW_NUMBER'                => $i + ($start + 1),
1074 5160 acydburn
1075 5138 acydburn
                                'S_CUSTOM_PROFILE'        => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
1076 5160 acydburn
                                'S_GROUP_LEADER'        => (isset($row['group_leader']) && $row['group_leader']) ? true : false,
1077 5160 acydburn
1078 5138 acydburn
                                'U_VIEWPROFILE'                => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=$user_id")
1079 5138 acydburn
                        );
1080 4970 psotfx
1081 5138 acydburn
                        if (isset($cp_row['row']) && sizeof($cp_row['row']))
1082 5138 acydburn
                        {
1083 5138 acydburn
                                $memberrow = array_merge($memberrow, $cp_row['row']);
1084 5138 acydburn
                        }
1085 3625 psotfx
1086 5138 acydburn
                        $template->assign_block_vars('memberrow', $memberrow);
1087 5138 acydburn
1088 5138 acydburn
                        if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow']))
1089 5138 acydburn
                        {
1090 5138 acydburn
                                foreach ($cp_row['blockrow'] as $field_data)
1091 5138 acydburn
                                {
1092 5138 acydburn
                                        $template->assign_block_vars('memberrow.custom_fields', $field_data);
1093 5138 acydburn
                                }
1094 3625 psotfx
                        }
1095 3598 psotfx
1096 5138 acydburn
                        $i++;
1097 5138 acydburn
                        unset($id_cache[$user_id]);
1098 5138 acydburn
                }
1099 5138 acydburn
1100 5138 acydburn
                // Generate page
1101 5138 acydburn
                $template->assign_vars(array(
1102 5138 acydburn
                        'PAGINATION'         => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start),
1103 5138 acydburn
                        'PAGE_NUMBER'         => on_page($total_users, $config['topics_per_page'], $start),
1104 5138 acydburn
                        'TOTAL_USERS'        => ($total_users == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users),
1105 3598 psotfx
1106 5138 acydburn
                        'PROFILE_IMG'        => $user->img('btn_profile', $user->lang['PROFILE']),
1107 5138 acydburn
                        'PM_IMG'                => $user->img('btn_pm', $user->lang['MESSAGE']),
1108 5138 acydburn
                        'EMAIL_IMG'                => $user->img('btn_email', $user->lang['EMAIL']),
1109 5138 acydburn
                        'WWW_IMG'                => $user->img('btn_www', $user->lang['WWW']),
1110 5138 acydburn
                        'ICQ_IMG'                => $user->img('btn_icq', $user->lang['ICQ']),
1111 5138 acydburn
                        'AIM_IMG'                => $user->img('btn_aim', $user->lang['AIM']),
1112 5138 acydburn
                        'MSN_IMG'                => $user->img('btn_msnm', $user->lang['MSNM']),
1113 5138 acydburn
                        'YIM_IMG'                => $user->img('btn_yim', $user->lang['YIM']),
1114 5138 acydburn
                        'JABBER_IMG'        => $user->img('btn_jabber', $user->lang['JABBER']),
1115 5138 acydburn
                        'SEARCH_IMG'        => $user->img('btn_search', $user->lang['SEARCH']),
1116 4145 psotfx
1117 5160 acydburn
                        'U_FIND_MEMBER'                => ($config['load_search'] || $auth->acl_get('a_')) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=searchuser" : '',
1118 5160 acydburn
                        'U_HIDE_FIND_MEMBER'=> ($mode == 'searchuser') ? $u_hide_find_member : '',
1119 5138 acydburn
                        'U_SORT_USERNAME'        => $pagination_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
1120 5138 acydburn
                        'U_SORT_FROM'                => $pagination_url . '&amp;sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
1121 5138 acydburn
                        'U_SORT_JOINED'                => $pagination_url . '&amp;sk=c&amp;sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
1122 5138 acydburn
                        'U_SORT_POSTS'                => $pagination_url . '&amp;sk=d&amp;sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
1123 5138 acydburn
                        'U_SORT_EMAIL'                => $pagination_url . '&amp;sk=e&amp;sd=' . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
1124 5138 acydburn
                        'U_SORT_WEBSITE'        => $pagination_url . '&amp;sk=f&amp;sd=' . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
1125 5138 acydburn
                        'U_SORT_ICQ'                => $pagination_url . '&amp;sk=g&amp;sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
1126 5138 acydburn
                        'U_SORT_AIM'                => $pagination_url . '&amp;sk=h&amp;sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'),
1127 5138 acydburn
                        'U_SORT_MSN'                => $pagination_url . '&amp;sk=i&amp;sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'),
1128 5138 acydburn
                        'U_SORT_YIM'                => $pagination_url . '&amp;sk=j&amp;sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'),
1129 5138 acydburn
                        'U_SORT_ACTIVE'                => $pagination_url . '&amp;sk=k&amp;sd=' . (($sort_key == 'k' && $sort_dir == 'a') ? 'd' : 'a'),
1130 5138 acydburn
                        'U_SORT_RANK'                => $pagination_url . '&amp;sk=l&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a'),
1131 5160 acydburn
                        'U_LIST_CHAR'                => $pagination_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a'),
1132 3598 psotfx
1133 5138 acydburn
                        'S_SHOW_GROUP'                => ($mode == 'group') ? true : false,
1134 5138 acydburn
                        'S_MODE_SELECT'                => $s_sort_key,
1135 5138 acydburn
                        'S_ORDER_SELECT'        => $s_sort_dir,
1136 5160 acydburn
                        'S_CHAR_OPTIONS'        => $s_char_options,
1137 5138 acydburn
                        'S_MODE_ACTION'                => $pagination_url . "&amp;form=$form")
1138 5138 acydburn
                );
1139 2448 psotfx
}
1140 2448 psotfx
1141 3612 psotfx
// Output the page
1142 3969 psotfx
page_header($page_title);
1143 3612 psotfx
1144 3612 psotfx
$template->set_filenames(array(
1145 3625 psotfx
        'body' => $template_html)
1146 3612 psotfx
);
1147 3612 psotfx
make_jumpbox('viewforum.'.$phpEx);
1148 3612 psotfx
1149 3969 psotfx
page_footer();
1150 3612 psotfx
1151 5114 acydburn
/**
1152 5160 acydburn
* Get user rank title and image
1153 5114 acydburn
*/
1154 5160 acydburn
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img)
1155 3612 psotfx
{
1156 5160 acydburn
        global $ranks, $config;
1157 3612 psotfx
1158 5160 acydburn
        if (!empty($user_rank))
1159 3598 psotfx
        {
1160 5160 acydburn
                $rank_title = (isset($ranks['special'][$user_rank]['rank_title'])) ? $ranks['special'][$user_rank]['rank_title'] : '';
1161 5160 acydburn
                $rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : '';
1162 3598 psotfx
        }
1163 3598 psotfx
        else
1164 3598 psotfx
        {
1165 5082 acydburn
                if (isset($ranks['normal']))
1166 4145 psotfx
                {
1167 5076 bartvb
                        foreach ($ranks['normal'] as $rank)
1168 4145 psotfx
                        {
1169 5160 acydburn
                                if ($user_posts >= $rank['rank_min'])
1170 5076 bartvb
                                {
1171 5076 bartvb
                                        $rank_title = $rank['rank_title'];
1172 5160 acydburn
                                        $rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
1173 5076 bartvb
                                        break;
1174 5076 bartvb
                                }
1175 4145 psotfx
                        }
1176 4145 psotfx
                }
1177 3598 psotfx
        }
1178 5160 acydburn
}
1179 272 thefinn
1180 5160 acydburn
/**
1181 5160 acydburn
* Prepare profile data
1182 5160 acydburn
*/
1183 5160 acydburn
function show_profile($data)
1184 5160 acydburn
{
1185 5160 acydburn
        global $config, $auth, $template, $user, $SID, $phpEx, $phpbb_root_path;
1186 5160 acydburn
1187 5160 acydburn
        $username = $data['username'];
1188 5160 acydburn
        $user_id = $data['user_id'];
1189 5160 acydburn
1190 5160 acydburn
        $rank_title = $rank_img = '';
1191 5160 acydburn
        get_user_rank($data['user_rank'], $data['user_posts'], $rank_title, $rank_img);
1192 5160 acydburn
1193 5071 acydburn
        if (!empty($data['user_allow_viewemail']) || $auth->acl_get('a_email'))
1194 5071 acydburn
        {
1195 5071 acydburn
                $email = ($config['board_email_form'] && $config['email_enable']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=email&amp;u=$user_id" : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $data['user_email']);
1196 5071 acydburn
        }
1197 5071 acydburn
        else
1198 5071 acydburn
        {
1199 5071 acydburn
                $email = '';
1200 5071 acydburn
        }
1201 596 psotfx
1202 3625 psotfx
        $last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
1203 3625 psotfx
1204 4145 psotfx
        // Dump it out to the template
1205 4970 psotfx
        // TODO
1206 4145 psotfx
        // Add permission check for IM clients
1207 4145 psotfx
        return array(
1208 4970 psotfx
                'USERNAME'                => $username,
1209 4970 psotfx
                'USER_COLOR'        => (!empty($data['user_colour'])) ? $data['user_colour'] : '',
1210 4970 psotfx
                'RANK_TITLE'        => $rank_title,
1211 4145 psotfx
                'JOINED'                => $user->format_date($data['user_regdate'], $user->lang['DATE_FORMAT']),
1212 4145 psotfx
                'VISITED'                => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit, $user->lang['DATE_FORMAT']),
1213 4145 psotfx
                'POSTS'                        => ($data['user_posts']) ? $data['user_posts'] : 0,
1214 3612 psotfx
1215 4970 psotfx
                'ONLINE_IMG'        => (intval($data['session_time']) >= time() - ($config['load_online_time'] * 60)) ? $user->img('btn_online', $user->lang['USER_ONLINE']) : $user->img('btn_offline', $user->lang['USER_ONLINE']),
1216 3598 psotfx
                'RANK_IMG'                => $rank_img,
1217 5138 acydburn
                'ICQ_STATUS_IMG'=> (!empty($data['user_icq'])) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $data['user_icq'] . '&amp;img=5" width="18" height="18" border="0" />' : '',
1218 3628 psotfx
1219 5160 acydburn
                'U_PROFILE'                => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=$user_id",
1220 5199 acydburn
                'U_SEARCH_USER'        => ($auth->acl_get('u_search')) ? "{$phpbb_root_path}search.$phpEx$SID&amp;search_author=" . urlencode($username) . "&amp;show_results=posts" : '',
1221 5199 acydburn
                'U_PM'                        => ($auth->acl_get('u_sendpm')) ? "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=compose&amp;u=$user_id" : '',
1222 4506 psotfx
                'U_EMAIL'                => $email,
1223 4506 psotfx
                'U_WWW'                        => (!empty($data['user_website'])) ? $data['user_website'] : '',
1224 5199 acydburn
                'U_ICQ'                        => ($data['user_icq']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=contact&amp;action=icq&amp;u=$user_id" : '',
1225 5199 acydburn
                'U_AIM'                        => ($data['user_aim']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=contact&amp;action=aim&amp;u=$user_id" : '',
1226 5010 acydburn
                'U_YIM'                        => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $data['user_yim'] . '&.src=pg' : '',
1227 5199 acydburn
                'U_MSN'                        => ($data['user_msnm']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=contact&amp;action=msnm&amp;u=$user_id" : '',
1228 5199 acydburn
                'U_JABBER'                => ($data['user_jabber']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=contact&amp;action=jabber&amp;u=$user_id" : '',
1229 4080 psotfx
1230 5199 acydburn
                'S_ONLINE'        => (intval($data['session_time']) >= time() - ($config['load_online_time'] * 60)) ? true : false
1231 3598 psotfx
        );
1232 3598 psotfx
}
1233 3598 psotfx
1234 2448 psotfx
?>