Chris@76
|
1 <?php
|
Chris@76
|
2
|
Chris@76
|
3 /**
|
Chris@76
|
4 * Simple Machines Forum (SMF)
|
Chris@76
|
5 *
|
Chris@76
|
6 * @package SMF
|
Chris@76
|
7 * @author Simple Machines http://www.simplemachines.org
|
Chris@76
|
8 * @copyright 2011 Simple Machines
|
Chris@76
|
9 * @license http://www.simplemachines.org/about/smf/license.php BSD
|
Chris@76
|
10 *
|
Chris@76
|
11 * @version 2.0.2
|
Chris@76
|
12 */
|
Chris@76
|
13
|
Chris@76
|
14 if (!defined('SMF'))
|
Chris@76
|
15 die('Hacking attempt...');
|
Chris@76
|
16
|
Chris@76
|
17 /* This file is mainly concerned, or that is to say only concerned, with the
|
Chris@76
|
18 Who's Online list. It contains only the following functions:
|
Chris@76
|
19
|
Chris@76
|
20 void Who()
|
Chris@76
|
21 - prepares the who's online data for the Who template.
|
Chris@76
|
22 - uses the Who template (main sub template.) and language file.
|
Chris@76
|
23 - requires the who_view permission.
|
Chris@76
|
24 - is enabled with the who_enabled setting.
|
Chris@76
|
25 - is accessed via ?action=who.
|
Chris@76
|
26
|
Chris@76
|
27 array determineActions(array urls, string preferred_prefix = false)
|
Chris@76
|
28 - determine the actions of the members passed in urls.
|
Chris@76
|
29 - urls should be a single url (string) or an array of arrays, each
|
Chris@76
|
30 inner array being (serialized request data, id_member).
|
Chris@76
|
31 - returns an array of descriptions if you passed an array, otherwise
|
Chris@76
|
32 the string describing their current location.
|
Chris@76
|
33
|
Chris@76
|
34 void Credits(bool in_admin)
|
Chris@76
|
35 - prepares credit and copyright information for the credits page or the admin page
|
Chris@76
|
36 - if parameter is true the it will not load the sub template nor the template file
|
Chris@76
|
37
|
Chris@76
|
38 Adding actions to the Who's Online list:
|
Chris@76
|
39 ---------------------------------------------------------------------------
|
Chris@76
|
40 Adding actions to this list is actually relatively easy....
|
Chris@76
|
41 - for actions anyone should be able to see, just add a string named
|
Chris@76
|
42 whoall_ACTION. (where ACTION is the action used in index.php.)
|
Chris@76
|
43 - for actions that have a subaction which should be represented
|
Chris@76
|
44 differently, use whoall_ACTION_SUBACTION.
|
Chris@76
|
45 - for actions that include a topic, and should be restricted, use
|
Chris@76
|
46 whotopic_ACTION.
|
Chris@76
|
47 - for actions that use a message, by msg or quote, use whopost_ACTION.
|
Chris@76
|
48 - for administrator-only actions, use whoadmin_ACTION.
|
Chris@76
|
49 - for actions that should be viewable only with certain permissions,
|
Chris@76
|
50 use whoallow_ACTION and add a list of possible permissions to the
|
Chris@76
|
51 $allowedActions array, using ACTION as the key.
|
Chris@76
|
52 */
|
Chris@76
|
53
|
Chris@76
|
54 // Who's online, and what are they doing?
|
Chris@76
|
55 function Who()
|
Chris@76
|
56 {
|
Chris@76
|
57 global $context, $scripturl, $user_info, $txt, $modSettings, $memberContext, $smcFunc;
|
Chris@76
|
58
|
Chris@76
|
59 // Permissions, permissions, permissions.
|
Chris@76
|
60 isAllowedTo('who_view');
|
Chris@76
|
61
|
Chris@76
|
62 // You can't do anything if this is off.
|
Chris@76
|
63 if (empty($modSettings['who_enabled']))
|
Chris@76
|
64 fatal_lang_error('who_off', false);
|
Chris@76
|
65
|
Chris@76
|
66 // Load the 'Who' template.
|
Chris@76
|
67 loadTemplate('Who');
|
Chris@76
|
68 loadLanguage('Who');
|
Chris@76
|
69
|
Chris@76
|
70 // Sort out... the column sorting.
|
Chris@76
|
71 $sort_methods = array(
|
Chris@76
|
72 'user' => 'mem.real_name',
|
Chris@76
|
73 'time' => 'lo.log_time'
|
Chris@76
|
74 );
|
Chris@76
|
75
|
Chris@76
|
76 $show_methods = array(
|
Chris@76
|
77 'members' => '(lo.id_member != 0)',
|
Chris@76
|
78 'guests' => '(lo.id_member = 0)',
|
Chris@76
|
79 'all' => '1=1',
|
Chris@76
|
80 );
|
Chris@76
|
81
|
Chris@76
|
82 // Store the sort methods and the show types for use in the template.
|
Chris@76
|
83 $context['sort_methods'] = array(
|
Chris@76
|
84 'user' => $txt['who_user'],
|
Chris@76
|
85 'time' => $txt['who_time'],
|
Chris@76
|
86 );
|
Chris@76
|
87 $context['show_methods'] = array(
|
Chris@76
|
88 'all' => $txt['who_show_all'],
|
Chris@76
|
89 'members' => $txt['who_show_members_only'],
|
Chris@76
|
90 'guests' => $txt['who_show_guests_only'],
|
Chris@76
|
91 );
|
Chris@76
|
92
|
Chris@76
|
93 // Can they see spiders too?
|
Chris@76
|
94 if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
|
Chris@76
|
95 {
|
Chris@76
|
96 $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
|
Chris@76
|
97 $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
|
Chris@76
|
98 $context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
|
Chris@76
|
99 }
|
Chris@76
|
100 elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders')
|
Chris@76
|
101 unset($_SESSION['who_online_filter']);
|
Chris@76
|
102
|
Chris@76
|
103 // Does the user prefer a different sort direction?
|
Chris@76
|
104 if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']]))
|
Chris@76
|
105 {
|
Chris@76
|
106 $context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort'];
|
Chris@76
|
107 $sort_method = $sort_methods[$_REQUEST['sort']];
|
Chris@76
|
108 }
|
Chris@76
|
109 // Did we set a preferred sort order earlier in the session?
|
Chris@76
|
110 elseif (isset($_SESSION['who_online_sort_by']))
|
Chris@76
|
111 {
|
Chris@76
|
112 $context['sort_by'] = $_SESSION['who_online_sort_by'];
|
Chris@76
|
113 $sort_method = $sort_methods[$_SESSION['who_online_sort_by']];
|
Chris@76
|
114 }
|
Chris@76
|
115 // Default to last time online.
|
Chris@76
|
116 else
|
Chris@76
|
117 {
|
Chris@76
|
118 $context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time';
|
Chris@76
|
119 $sort_method = 'lo.log_time';
|
Chris@76
|
120 }
|
Chris@76
|
121
|
Chris@76
|
122 $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down';
|
Chris@76
|
123
|
Chris@76
|
124 $conditions = array();
|
Chris@76
|
125 if (!allowedTo('moderate_forum'))
|
Chris@76
|
126 $conditions[] = '(IFNULL(mem.show_online, 1) = 1)';
|
Chris@76
|
127
|
Chris@76
|
128 // Fallback to top filter?
|
Chris@76
|
129 if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
|
Chris@76
|
130 $_REQUEST['show'] = $_REQUEST['show_top'];
|
Chris@76
|
131 // Does the user wish to apply a filter?
|
Chris@76
|
132 if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
|
Chris@76
|
133 {
|
Chris@76
|
134 $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
|
Chris@76
|
135 $conditions[] = $show_methods[$_REQUEST['show']];
|
Chris@76
|
136 }
|
Chris@76
|
137 // Perhaps we saved a filter earlier in the session?
|
Chris@76
|
138 elseif (isset($_SESSION['who_online_filter']))
|
Chris@76
|
139 {
|
Chris@76
|
140 $context['show_by'] = $_SESSION['who_online_filter'];
|
Chris@76
|
141 $conditions[] = $show_methods[$_SESSION['who_online_filter']];
|
Chris@76
|
142 }
|
Chris@76
|
143 else
|
Chris@76
|
144 $context['show_by'] = $_SESSION['who_online_filter'] = 'all';
|
Chris@76
|
145
|
Chris@76
|
146 // Get the total amount of members online.
|
Chris@76
|
147 $request = $smcFunc['db_query']('', '
|
Chris@76
|
148 SELECT COUNT(*)
|
Chris@76
|
149 FROM {db_prefix}log_online AS lo
|
Chris@76
|
150 LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)' . (!empty($conditions) ? '
|
Chris@76
|
151 WHERE ' . implode(' AND ', $conditions) : ''),
|
Chris@76
|
152 array(
|
Chris@76
|
153 )
|
Chris@76
|
154 );
|
Chris@76
|
155 list ($totalMembers) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
156 $smcFunc['db_free_result']($request);
|
Chris@76
|
157
|
Chris@76
|
158 // Prepare some page index variables.
|
Chris@76
|
159 $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';asc' : '') . ';show=' . $context['show_by'], $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']);
|
Chris@76
|
160 $context['start'] = $_REQUEST['start'];
|
Chris@76
|
161
|
Chris@76
|
162 // Look for people online, provided they don't mind if you see they are.
|
Chris@76
|
163 $request = $smcFunc['db_query']('', '
|
Chris@76
|
164 SELECT
|
Chris@76
|
165 lo.log_time, lo.id_member, lo.url, INET_NTOA(lo.ip) AS ip, mem.real_name,
|
Chris@76
|
166 lo.session, mg.online_color, IFNULL(mem.show_online, 1) AS show_online,
|
Chris@76
|
167 lo.id_spider
|
Chris@76
|
168 FROM {db_prefix}log_online AS lo
|
Chris@76
|
169 LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)
|
Chris@76
|
170 LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:regular_member} THEN mem.id_post_group ELSE mem.id_group END)' . (!empty($conditions) ? '
|
Chris@76
|
171 WHERE ' . implode(' AND ', $conditions) : '') . '
|
Chris@76
|
172 ORDER BY {raw:sort_method} {raw:sort_direction}
|
Chris@76
|
173 LIMIT {int:offset}, {int:limit}',
|
Chris@76
|
174 array(
|
Chris@76
|
175 'regular_member' => 0,
|
Chris@76
|
176 'sort_method' => $sort_method,
|
Chris@76
|
177 'sort_direction' => $context['sort_direction'] == 'up' ? 'ASC' : 'DESC',
|
Chris@76
|
178 'offset' => $context['start'],
|
Chris@76
|
179 'limit' => $modSettings['defaultMaxMembers'],
|
Chris@76
|
180 )
|
Chris@76
|
181 );
|
Chris@76
|
182 $context['members'] = array();
|
Chris@76
|
183 $member_ids = array();
|
Chris@76
|
184 $url_data = array();
|
Chris@76
|
185 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
186 {
|
Chris@76
|
187 $actions = @unserialize($row['url']);
|
Chris@76
|
188 if ($actions === false)
|
Chris@76
|
189 continue;
|
Chris@76
|
190
|
Chris@76
|
191 // Send the information to the template.
|
Chris@76
|
192 $context['members'][$row['session']] = array(
|
Chris@76
|
193 'id' => $row['id_member'],
|
Chris@76
|
194 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '',
|
Chris@76
|
195 // It is *going* to be today or yesterday, so why keep that information in there?
|
Chris@76
|
196 'time' => strtr(timeformat($row['log_time']), array($txt['today'] => '', $txt['yesterday'] => '')),
|
Chris@76
|
197 'timestamp' => forum_time(true, $row['log_time']),
|
Chris@76
|
198 'query' => $actions,
|
Chris@76
|
199 'is_hidden' => $row['show_online'] == 0,
|
Chris@76
|
200 'id_spider' => $row['id_spider'],
|
Chris@76
|
201 'color' => empty($row['online_color']) ? '' : $row['online_color']
|
Chris@76
|
202 );
|
Chris@76
|
203
|
Chris@76
|
204 $url_data[$row['session']] = array($row['url'], $row['id_member']);
|
Chris@76
|
205 $member_ids[] = $row['id_member'];
|
Chris@76
|
206 }
|
Chris@76
|
207 $smcFunc['db_free_result']($request);
|
Chris@76
|
208
|
Chris@76
|
209 // Load the user data for these members.
|
Chris@76
|
210 loadMemberData($member_ids);
|
Chris@76
|
211
|
Chris@76
|
212 // Load up the guest user.
|
Chris@76
|
213 $memberContext[0] = array(
|
Chris@76
|
214 'id' => 0,
|
Chris@76
|
215 'name' => $txt['guest_title'],
|
Chris@76
|
216 'group' => $txt['guest_title'],
|
Chris@76
|
217 'href' => '',
|
Chris@76
|
218 'link' => $txt['guest_title'],
|
Chris@76
|
219 'email' => $txt['guest_title'],
|
Chris@76
|
220 'is_guest' => true
|
Chris@76
|
221 );
|
Chris@76
|
222
|
Chris@76
|
223 // Are we showing spiders?
|
Chris@76
|
224 $spiderContext = array();
|
Chris@76
|
225 if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
|
Chris@76
|
226 {
|
Chris@76
|
227 foreach (unserialize($modSettings['spider_name_cache']) as $id => $name)
|
Chris@76
|
228 $spiderContext[$id] = array(
|
Chris@76
|
229 'id' => 0,
|
Chris@76
|
230 'name' => $name,
|
Chris@76
|
231 'group' => $txt['spiders'],
|
Chris@76
|
232 'href' => '',
|
Chris@76
|
233 'link' => $name,
|
Chris@76
|
234 'email' => $name,
|
Chris@76
|
235 'is_guest' => true
|
Chris@76
|
236 );
|
Chris@76
|
237 }
|
Chris@76
|
238
|
Chris@76
|
239 $url_data = determineActions($url_data);
|
Chris@76
|
240
|
Chris@76
|
241 // Setup the linktree and page title (do it down here because the language files are now loaded..)
|
Chris@76
|
242 $context['page_title'] = $txt['who_title'];
|
Chris@76
|
243 $context['linktree'][] = array(
|
Chris@76
|
244 'url' => $scripturl . '?action=who',
|
Chris@76
|
245 'name' => $txt['who_title']
|
Chris@76
|
246 );
|
Chris@76
|
247
|
Chris@76
|
248 // Put it in the context variables.
|
Chris@76
|
249 foreach ($context['members'] as $i => $member)
|
Chris@76
|
250 {
|
Chris@76
|
251 if ($member['id'] != 0)
|
Chris@76
|
252 $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
|
Chris@76
|
253
|
Chris@76
|
254 // Keep the IP that came from the database.
|
Chris@76
|
255 $memberContext[$member['id']]['ip'] = $member['ip'];
|
Chris@76
|
256 $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden'];
|
Chris@76
|
257 if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']]))
|
Chris@76
|
258 $context['members'][$i] += $spiderContext[$member['id_spider']];
|
Chris@76
|
259 else
|
Chris@76
|
260 $context['members'][$i] += $memberContext[$member['id']];
|
Chris@76
|
261 }
|
Chris@76
|
262
|
Chris@76
|
263 // Some people can't send personal messages...
|
Chris@76
|
264 $context['can_send_pm'] = allowedTo('pm_send');
|
Chris@76
|
265
|
Chris@76
|
266 // any profile fields disabled?
|
Chris@76
|
267 $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
|
Chris@76
|
268
|
Chris@76
|
269 }
|
Chris@76
|
270
|
Chris@76
|
271 function determineActions($urls, $preferred_prefix = false)
|
Chris@76
|
272 {
|
Chris@76
|
273 global $txt, $user_info, $modSettings, $smcFunc, $context;
|
Chris@76
|
274
|
Chris@76
|
275 if (!allowedTo('who_view'))
|
Chris@76
|
276 return array();
|
Chris@76
|
277 loadLanguage('Who');
|
Chris@76
|
278
|
Chris@76
|
279 // Actions that require a specific permission level.
|
Chris@76
|
280 $allowedActions = array(
|
Chris@76
|
281 'admin' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'admin_forum', 'manage_permissions', 'send_mail', 'manage_attachments', 'manage_smileys', 'manage_boards', 'edit_news'),
|
Chris@76
|
282 'ban' => array('manage_bans'),
|
Chris@76
|
283 'boardrecount' => array('admin_forum'),
|
Chris@76
|
284 'calendar' => array('calendar_view'),
|
Chris@76
|
285 'editnews' => array('edit_news'),
|
Chris@76
|
286 'mailing' => array('send_mail'),
|
Chris@76
|
287 'maintain' => array('admin_forum'),
|
Chris@76
|
288 'manageattachments' => array('manage_attachments'),
|
Chris@76
|
289 'manageboards' => array('manage_boards'),
|
Chris@76
|
290 'mlist' => array('view_mlist'),
|
Chris@76
|
291 'moderate' => array('access_mod_center', 'moderate_forum', 'manage_membergroups'),
|
Chris@76
|
292 'optimizetables' => array('admin_forum'),
|
Chris@76
|
293 'repairboards' => array('admin_forum'),
|
Chris@76
|
294 'search' => array('search_posts'),
|
Chris@76
|
295 'search2' => array('search_posts'),
|
Chris@76
|
296 'setcensor' => array('moderate_forum'),
|
Chris@76
|
297 'setreserve' => array('moderate_forum'),
|
Chris@76
|
298 'stats' => array('view_stats'),
|
Chris@76
|
299 'viewErrorLog' => array('admin_forum'),
|
Chris@76
|
300 'viewmembers' => array('moderate_forum'),
|
Chris@76
|
301 );
|
Chris@76
|
302
|
Chris@76
|
303 if (!is_array($urls))
|
Chris@76
|
304 $url_list = array(array($urls, $user_info['id']));
|
Chris@76
|
305 else
|
Chris@76
|
306 $url_list = $urls;
|
Chris@76
|
307
|
Chris@76
|
308 // These are done to later query these in large chunks. (instead of one by one.)
|
Chris@76
|
309 $topic_ids = array();
|
Chris@76
|
310 $profile_ids = array();
|
Chris@76
|
311 $board_ids = array();
|
Chris@76
|
312
|
Chris@76
|
313 $data = array();
|
Chris@76
|
314 foreach ($url_list as $k => $url)
|
Chris@76
|
315 {
|
Chris@76
|
316 // Get the request parameters..
|
Chris@76
|
317 $actions = @unserialize($url[0]);
|
Chris@76
|
318 if ($actions === false)
|
Chris@76
|
319 continue;
|
Chris@76
|
320
|
Chris@76
|
321 // If it's the admin or moderation center, and there is an area set, use that instead.
|
Chris@76
|
322 if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area']))
|
Chris@76
|
323 $actions['action'] = $actions['area'];
|
Chris@76
|
324
|
Chris@76
|
325 // Check if there was no action or the action is display.
|
Chris@76
|
326 if (!isset($actions['action']) || $actions['action'] == 'display')
|
Chris@76
|
327 {
|
Chris@76
|
328 // It's a topic! Must be!
|
Chris@76
|
329 if (isset($actions['topic']))
|
Chris@76
|
330 {
|
Chris@76
|
331 // Assume they can't view it, and queue it up for later.
|
Chris@76
|
332 $data[$k] = $txt['who_hidden'];
|
Chris@76
|
333 $topic_ids[(int) $actions['topic']][$k] = $txt['who_topic'];
|
Chris@76
|
334 }
|
Chris@76
|
335 // It's a board!
|
Chris@76
|
336 elseif (isset($actions['board']))
|
Chris@76
|
337 {
|
Chris@76
|
338 // Hide first, show later.
|
Chris@76
|
339 $data[$k] = $txt['who_hidden'];
|
Chris@76
|
340 $board_ids[$actions['board']][$k] = $txt['who_board'];
|
Chris@76
|
341 }
|
Chris@76
|
342 // It's the board index!! It must be!
|
Chris@76
|
343 else
|
Chris@76
|
344 $data[$k] = $txt['who_index'];
|
Chris@76
|
345 }
|
Chris@76
|
346 // Probably an error or some goon?
|
Chris@76
|
347 elseif ($actions['action'] == '')
|
Chris@76
|
348 $data[$k] = $txt['who_index'];
|
Chris@76
|
349 // Some other normal action...?
|
Chris@76
|
350 else
|
Chris@76
|
351 {
|
Chris@76
|
352 // Viewing/editing a profile.
|
Chris@76
|
353 if ($actions['action'] == 'profile')
|
Chris@76
|
354 {
|
Chris@76
|
355 // Whose? Their own?
|
Chris@76
|
356 if (empty($actions['u']))
|
Chris@76
|
357 $actions['u'] = $url[1];
|
Chris@76
|
358
|
Chris@76
|
359 $data[$k] = $txt['who_hidden'];
|
Chris@76
|
360 $profile_ids[(int) $actions['u']][$k] = $actions['action'] == 'profile' ? $txt['who_viewprofile'] : $txt['who_profile'];
|
Chris@76
|
361 }
|
Chris@76
|
362 elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
|
Chris@76
|
363 {
|
Chris@76
|
364 $data[$k] = $txt['who_hidden'];
|
Chris@76
|
365 $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post'];
|
Chris@76
|
366 }
|
Chris@76
|
367 // A subaction anyone can view... if the language string is there, show it.
|
Chris@76
|
368 elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']]))
|
Chris@76
|
369 $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
|
Chris@76
|
370 // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
|
Chris@76
|
371 elseif (isset($txt['whoall_' . $actions['action']]))
|
Chris@76
|
372 $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
|
Chris@76
|
373 // Viewable if and only if they can see the board...
|
Chris@76
|
374 elseif (isset($txt['whotopic_' . $actions['action']]))
|
Chris@76
|
375 {
|
Chris@76
|
376 // Find out what topic they are accessing.
|
Chris@76
|
377 $topic = (int) (isset($actions['topic']) ? $actions['topic'] : (isset($actions['from']) ? $actions['from'] : 0));
|
Chris@76
|
378
|
Chris@76
|
379 $data[$k] = $txt['who_hidden'];
|
Chris@76
|
380 $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']];
|
Chris@76
|
381 }
|
Chris@76
|
382 elseif (isset($txt['whopost_' . $actions['action']]))
|
Chris@76
|
383 {
|
Chris@76
|
384 // Find out what message they are accessing.
|
Chris@76
|
385 $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0));
|
Chris@76
|
386
|
Chris@76
|
387 $result = $smcFunc['db_query']('', '
|
Chris@76
|
388 SELECT m.id_topic, m.subject
|
Chris@76
|
389 FROM {db_prefix}messages AS m
|
Chris@76
|
390 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
|
Chris@76
|
391 INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '') . ')
|
Chris@76
|
392 WHERE m.id_msg = {int:id_msg}
|
Chris@76
|
393 AND {query_see_board}' . ($modSettings['postmod_active'] ? '
|
Chris@76
|
394 AND m.approved = {int:is_approved}' : '') . '
|
Chris@76
|
395 LIMIT 1',
|
Chris@76
|
396 array(
|
Chris@76
|
397 'is_approved' => 1,
|
Chris@76
|
398 'id_msg' => $msgid,
|
Chris@76
|
399 )
|
Chris@76
|
400 );
|
Chris@76
|
401 list ($id_topic, $subject) = $smcFunc['db_fetch_row']($result);
|
Chris@76
|
402 $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject);
|
Chris@76
|
403 $smcFunc['db_free_result']($result);
|
Chris@76
|
404
|
Chris@76
|
405 if (empty($id_topic))
|
Chris@76
|
406 $data[$k] = $txt['who_hidden'];
|
Chris@76
|
407 }
|
Chris@76
|
408 // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!)
|
Chris@76
|
409 elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']]))
|
Chris@76
|
410 $data[$k] = $txt['whoadmin_' . $actions['action']];
|
Chris@76
|
411 // Viewable by permission level.
|
Chris@76
|
412 elseif (isset($allowedActions[$actions['action']]))
|
Chris@76
|
413 {
|
Chris@76
|
414 if (allowedTo($allowedActions[$actions['action']]))
|
Chris@76
|
415 $data[$k] = $txt['whoallow_' . $actions['action']];
|
Chris@76
|
416 else
|
Chris@76
|
417 $data[$k] = $txt['who_hidden'];
|
Chris@76
|
418 }
|
Chris@76
|
419 // Unlisted or unknown action.
|
Chris@76
|
420 else
|
Chris@76
|
421 $data[$k] = $txt['who_unknown'];
|
Chris@76
|
422 }
|
Chris@76
|
423
|
Chris@76
|
424 // Maybe the action is integrated into another system?
|
Chris@76
|
425 if (count($integrate_actions = call_integration_hook('integrate_whos_online', array($actions))) > 0)
|
Chris@76
|
426 {
|
Chris@76
|
427 foreach ($integrate_actions as $integrate_action)
|
Chris@76
|
428 {
|
Chris@76
|
429 if (!empty($integrate_action))
|
Chris@76
|
430 {
|
Chris@76
|
431 $data[$k] = $integrate_action;
|
Chris@76
|
432 break;
|
Chris@76
|
433 }
|
Chris@76
|
434 }
|
Chris@76
|
435 }
|
Chris@76
|
436 }
|
Chris@76
|
437
|
Chris@76
|
438 // Load topic names.
|
Chris@76
|
439 if (!empty($topic_ids))
|
Chris@76
|
440 {
|
Chris@76
|
441 $result = $smcFunc['db_query']('', '
|
Chris@76
|
442 SELECT t.id_topic, m.subject
|
Chris@76
|
443 FROM {db_prefix}topics AS t
|
Chris@76
|
444 INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
|
Chris@76
|
445 INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
|
Chris@76
|
446 WHERE {query_see_board}
|
Chris@76
|
447 AND t.id_topic IN ({array_int:topic_list})' . ($modSettings['postmod_active'] ? '
|
Chris@76
|
448 AND t.approved = {int:is_approved}' : '') . '
|
Chris@76
|
449 LIMIT {int:limit}',
|
Chris@76
|
450 array(
|
Chris@76
|
451 'topic_list' => array_keys($topic_ids),
|
Chris@76
|
452 'is_approved' => 1,
|
Chris@76
|
453 'limit' => count($topic_ids),
|
Chris@76
|
454 )
|
Chris@76
|
455 );
|
Chris@76
|
456 while ($row = $smcFunc['db_fetch_assoc']($result))
|
Chris@76
|
457 {
|
Chris@76
|
458 // Show the topic's subject for each of the actions.
|
Chris@76
|
459 foreach ($topic_ids[$row['id_topic']] as $k => $session_text)
|
Chris@76
|
460 $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
|
Chris@76
|
461 }
|
Chris@76
|
462 $smcFunc['db_free_result']($result);
|
Chris@76
|
463 }
|
Chris@76
|
464
|
Chris@76
|
465 // Load board names.
|
Chris@76
|
466 if (!empty($board_ids))
|
Chris@76
|
467 {
|
Chris@76
|
468 $result = $smcFunc['db_query']('', '
|
Chris@76
|
469 SELECT b.id_board, b.name
|
Chris@76
|
470 FROM {db_prefix}boards AS b
|
Chris@76
|
471 WHERE {query_see_board}
|
Chris@76
|
472 AND b.id_board IN ({array_int:board_list})
|
Chris@76
|
473 LIMIT ' . count($board_ids),
|
Chris@76
|
474 array(
|
Chris@76
|
475 'board_list' => array_keys($board_ids),
|
Chris@76
|
476 )
|
Chris@76
|
477 );
|
Chris@76
|
478 while ($row = $smcFunc['db_fetch_assoc']($result))
|
Chris@76
|
479 {
|
Chris@76
|
480 // Put the board name into the string for each member...
|
Chris@76
|
481 foreach ($board_ids[$row['id_board']] as $k => $session_text)
|
Chris@76
|
482 $data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
|
Chris@76
|
483 }
|
Chris@76
|
484 $smcFunc['db_free_result']($result);
|
Chris@76
|
485 }
|
Chris@76
|
486
|
Chris@76
|
487 // Load member names for the profile.
|
Chris@76
|
488 if (!empty($profile_ids) && (allowedTo('profile_view_any') || allowedTo('profile_view_own')))
|
Chris@76
|
489 {
|
Chris@76
|
490 $result = $smcFunc['db_query']('', '
|
Chris@76
|
491 SELECT id_member, real_name
|
Chris@76
|
492 FROM {db_prefix}members
|
Chris@76
|
493 WHERE id_member IN ({array_int:member_list})
|
Chris@76
|
494 LIMIT ' . count($profile_ids),
|
Chris@76
|
495 array(
|
Chris@76
|
496 'member_list' => array_keys($profile_ids),
|
Chris@76
|
497 )
|
Chris@76
|
498 );
|
Chris@76
|
499 while ($row = $smcFunc['db_fetch_assoc']($result))
|
Chris@76
|
500 {
|
Chris@76
|
501 // If they aren't allowed to view this person's profile, skip it.
|
Chris@76
|
502 if (!allowedTo('profile_view_any') && $user_info['id'] != $row['id_member'])
|
Chris@76
|
503 continue;
|
Chris@76
|
504
|
Chris@76
|
505 // Set their action on each - session/text to sprintf.
|
Chris@76
|
506 foreach ($profile_ids[$row['id_member']] as $k => $session_text)
|
Chris@76
|
507 $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
|
Chris@76
|
508 }
|
Chris@76
|
509 $smcFunc['db_free_result']($result);
|
Chris@76
|
510 }
|
Chris@76
|
511
|
Chris@76
|
512 if (!is_array($urls))
|
Chris@76
|
513 return isset($data[0]) ? $data[0] : false;
|
Chris@76
|
514 else
|
Chris@76
|
515 return $data;
|
Chris@76
|
516 }
|
Chris@76
|
517
|
Chris@76
|
518 function Credits($in_admin = false)
|
Chris@76
|
519 {
|
Chris@76
|
520 global $context, $modSettings, $forum_copyright, $forum_version, $boardurl, $txt, $user_info;
|
Chris@76
|
521
|
Chris@76
|
522 // Don't blink. Don't even blink. Blink and you're dead.
|
Chris@76
|
523 loadLanguage('Who');
|
Chris@76
|
524
|
Chris@76
|
525 $context['credits'] = array(
|
Chris@76
|
526 array(
|
Chris@76
|
527 'pretext' => $txt['credits_intro'],
|
Chris@76
|
528 'title' => $txt['credits_team'],
|
Chris@76
|
529 'groups' => array(
|
Chris@76
|
530 array(
|
Chris@76
|
531 'title' => $txt['credits_groups_ps'],
|
Chris@76
|
532 'members' => array(
|
Chris@76
|
533 'Michael "Oldiesmann" Eshom',
|
Chris@76
|
534 'Amacythe',
|
Chris@76
|
535 'Jeremy "SleePy" Darwood',
|
Chris@76
|
536 'Justin "metallica48423" O\'Leary',
|
Chris@76
|
537 ),
|
Chris@76
|
538 ),
|
Chris@76
|
539 array(
|
Chris@76
|
540 'title' => $txt['credits_groups_dev'],
|
Chris@76
|
541 'members' => array(
|
Chris@76
|
542 'Norv',
|
Chris@76
|
543 'Aaron van Geffen',
|
Chris@76
|
544 'Antechinus',
|
Chris@76
|
545 'Bjoern "Bloc" Kristiansen',
|
Chris@76
|
546 'Hendrik Jan "Compuart" Visser',
|
Chris@76
|
547 'Juan "JayBachatero" Hernandez',
|
Chris@76
|
548 'Karl "RegularExpression" Benson',
|
Chris@76
|
549 $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge',
|
Chris@76
|
550 'Michael "Thantos" Miller',
|
Chris@76
|
551 'Selman "[SiNaN]" Eser',
|
Chris@76
|
552 'Theodore "Orstio" Hildebrandt',
|
Chris@76
|
553 'Thorsten "TE" Eurich',
|
Chris@76
|
554 'winrules',
|
Chris@76
|
555 ),
|
Chris@76
|
556 ),
|
Chris@76
|
557 array(
|
Chris@76
|
558 'title' => $txt['credits_groups_support'],
|
Chris@76
|
559 'members' => array(
|
Chris@76
|
560 'JimM',
|
Chris@76
|
561 'Adish "(F.L.A.M.E.R)" Patel',
|
Chris@76
|
562 'Aleksi "Lex" Kilpinen',
|
Chris@76
|
563 'Ben Scott',
|
Chris@76
|
564 'Bigguy',
|
Chris@76
|
565 'CapadY',
|
Chris@76
|
566 'Chas Large',
|
Chris@76
|
567 'Duncan85',
|
Chris@76
|
568 'Eliana Tamerin',
|
Chris@76
|
569 'Fiery',
|
Chris@76
|
570 'gbsothere',
|
Chris@76
|
571 'Harro',
|
Chris@76
|
572 'Huw',
|
Chris@76
|
573 'Jan-Olof "Owdy" Eriksson',
|
Chris@76
|
574 'Jeremy "jerm" Strike',
|
Chris@76
|
575 'Jessica "Miss All Sunday" Gonzales',
|
Chris@76
|
576 'K@',
|
Chris@76
|
577 'Kevin "greyknight17" Hou',
|
Chris@76
|
578 'KGIII',
|
Chris@76
|
579 'Kill Em All',
|
Chris@76
|
580 'Mattitude',
|
Chris@76
|
581 'Mashby',
|
Chris@76
|
582 'Mick G.',
|
Chris@76
|
583 'Michele "Illori" Davis',
|
Chris@76
|
584 'MrPhil',
|
Chris@76
|
585 'Nick "Fizzy" Dyer',
|
Chris@76
|
586 'Nick "Ha²"',
|
Chris@76
|
587 'Paul_Pauline',
|
Chris@76
|
588 'Piro "Sarge" Dhima',
|
Chris@76
|
589 'Rumbaar',
|
Chris@76
|
590 'Pitti',
|
Chris@76
|
591 'RedOne',
|
Chris@76
|
592 'S-Ace',
|
Chris@76
|
593 'Wade "sησω" Poulsen',
|
Chris@76
|
594 'xenovanis',
|
Chris@76
|
595 ),
|
Chris@76
|
596 ),
|
Chris@76
|
597 array(
|
Chris@76
|
598 'title' => $txt['credits_groups_customize'],
|
Chris@76
|
599 'members' => array(
|
Chris@76
|
600 'Brad "IchBin™" Grow',
|
Chris@76
|
601 'ディン1031',
|
Chris@76
|
602 'Brannon "B" Hall',
|
Chris@76
|
603 'Bryan "Runic" Deakin',
|
Chris@76
|
604 'Bulakbol',
|
Chris@76
|
605 'Colin "Shadow82x" Blaber',
|
Chris@76
|
606 'Daniel15',
|
Chris@76
|
607 'Eren Yasarkurt',
|
Chris@76
|
608 'Gary M. Gadsdon',
|
Chris@76
|
609 'Jason "JBlaze" Clemons',
|
Chris@76
|
610 'Jerry',
|
Chris@76
|
611 'Jonathan "vbgamer45" Valentin',
|
Chris@76
|
612 'Kays',
|
Chris@76
|
613 'Killer Possum',
|
Chris@76
|
614 'Kirby',
|
Chris@76
|
615 'Matt "SlammedDime" Zuba',
|
Chris@76
|
616 'Matthew "Labradoodle-360" Kerle',
|
Chris@76
|
617 'Nibogo',
|
Chris@76
|
618 'Niko',
|
Chris@76
|
619 'Peter "Arantor" Spicer',
|
Chris@76
|
620 'snork13',
|
Chris@76
|
621 'Spuds',
|
Chris@76
|
622 'Steven "Fustrate" Hoffman',
|
Chris@76
|
623 'Joey "Tyrsson" Smith',
|
Chris@76
|
624 ),
|
Chris@76
|
625 ),
|
Chris@76
|
626 array(
|
Chris@76
|
627 'title' => $txt['credits_groups_docs'],
|
Chris@76
|
628 'members' => array(
|
Chris@76
|
629 'Joshua "groundup" Dickerson',
|
Chris@76
|
630 'AngellinaBelle',
|
Chris@76
|
631 'Daniel Diehl',
|
Chris@76
|
632 'Dannii Willis',
|
Chris@76
|
633 'emanuele',
|
Chris@76
|
634 'Graeme Spence',
|
Chris@76
|
635 'Jack "akabugeyes" Thorsen',
|
Chris@76
|
636 'Jade Elizabeth Trainor',
|
Chris@76
|
637 'Peter Duggan',
|
Chris@76
|
638 ),
|
Chris@76
|
639 ),
|
Chris@76
|
640 array(
|
Chris@76
|
641 'title' => $txt['credits_groups_marketing'],
|
Chris@76
|
642 'members' => array(
|
Chris@76
|
643 'Kindred',
|
Chris@76
|
644 'Marcus "cσσкιє мσηѕтєя" Forsberg',
|
Chris@76
|
645 'Ralph "[n3rve]" Otowo',
|
Chris@76
|
646 'rickC',
|
Chris@76
|
647 'Tony Reid',
|
Chris@76
|
648 ),
|
Chris@76
|
649 ),
|
Chris@76
|
650 array(
|
Chris@76
|
651 'title' => $txt['credits_groups_internationalizers'],
|
Chris@76
|
652 'members' => array(
|
Chris@76
|
653 'Relyana',
|
Chris@76
|
654 'Akyhne',
|
Chris@76
|
655 'GravuTrad',
|
Chris@76
|
656 ),
|
Chris@76
|
657 ),
|
Chris@76
|
658 array(
|
Chris@76
|
659 'title' => $txt['credits_groups_servers'],
|
Chris@76
|
660 'members' => array(
|
Chris@76
|
661 'Derek Schwab',
|
Chris@76
|
662 'Liroy "CoreISP" van Hoewijk',
|
Chris@76
|
663 ),
|
Chris@76
|
664 ),
|
Chris@76
|
665 ),
|
Chris@76
|
666 ),
|
Chris@76
|
667 );
|
Chris@76
|
668
|
Chris@76
|
669 // Give the translators some credit for their hard work.
|
Chris@76
|
670 if (!empty($txt['translation_credits']))
|
Chris@76
|
671 $context['credits'][] = array(
|
Chris@76
|
672 'title' => $txt['credits_groups_translation'],
|
Chris@76
|
673 'groups' => array(
|
Chris@76
|
674 array(
|
Chris@76
|
675 'title' => $txt['credits_groups_translation'],
|
Chris@76
|
676 'members' => $txt['translation_credits'],
|
Chris@76
|
677 ),
|
Chris@76
|
678 ),
|
Chris@76
|
679 );
|
Chris@76
|
680
|
Chris@76
|
681 $context['credits'][] = array(
|
Chris@76
|
682 'title' => $txt['credits_special'],
|
Chris@76
|
683 'posttext' => $txt['credits_anyone'],
|
Chris@76
|
684 'groups' => array(
|
Chris@76
|
685 array(
|
Chris@76
|
686 'title' => $txt['credits_groups_consultants'],
|
Chris@76
|
687 'members' => array(
|
Chris@76
|
688 'Brett Flannigan',
|
Chris@76
|
689 'Mark Rose',
|
Chris@76
|
690 'René-Gilles "Nao 尚" Deberdt',
|
Chris@76
|
691 ),
|
Chris@76
|
692 ),
|
Chris@76
|
693 array(
|
Chris@76
|
694 'title' => $txt['credits_groups_beta'],
|
Chris@76
|
695 'members' => array(
|
Chris@76
|
696 $txt['credits_beta_message'],
|
Chris@76
|
697 ),
|
Chris@76
|
698 ),
|
Chris@76
|
699 array(
|
Chris@76
|
700 'title' => $txt['credits_groups_translators'],
|
Chris@76
|
701 'members' => array(
|
Chris@76
|
702 $txt['credits_translators_message'],
|
Chris@76
|
703 ),
|
Chris@76
|
704 ),
|
Chris@76
|
705 array(
|
Chris@76
|
706 'title' => $txt['credits_groups_founder'],
|
Chris@76
|
707 'members' => array(
|
Chris@76
|
708 'Unknown W. "[Unknown]" Brackets',
|
Chris@76
|
709 ),
|
Chris@76
|
710 ),
|
Chris@76
|
711 array(
|
Chris@76
|
712 'title' => $txt['credits_groups_orignal_pm'],
|
Chris@76
|
713 'members' => array(
|
Chris@76
|
714 'Jeff Lewis',
|
Chris@76
|
715 'Joseph Fung',
|
Chris@76
|
716 'David Recordon',
|
Chris@76
|
717 ),
|
Chris@76
|
718 ),
|
Chris@76
|
719 ),
|
Chris@76
|
720 );
|
Chris@76
|
721
|
Chris@76
|
722 $context['copyrights'] = array(
|
Chris@76
|
723 'smf' => sprintf($forum_copyright, $forum_version),
|
Chris@76
|
724
|
Chris@76
|
725 /* Modification Authors: You may add a copyright statement to this array for your mods.
|
Chris@76
|
726 Copyright statements should be in the form of a value only without a array key. I.E.:
|
Chris@76
|
727 'Some Mod by Thantos © 2010',
|
Chris@76
|
728 $txt['some_mod_copyright'],
|
Chris@76
|
729 */
|
Chris@76
|
730 'mods' => array(
|
Chris@76
|
731 ),
|
Chris@76
|
732 );
|
Chris@76
|
733
|
Chris@76
|
734 if (!$in_admin)
|
Chris@76
|
735 {
|
Chris@76
|
736 loadTemplate('Who');
|
Chris@76
|
737 $context['sub_template'] = 'credits';
|
Chris@76
|
738 $context['robot_no_index'] = true;
|
Chris@76
|
739 $context['page_title'] = $txt['credits'];
|
Chris@76
|
740 }
|
Chris@76
|
741 }
|
Chris@76
|
742
|
Chris@76
|
743 ?> |