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
|
Chris@76
|
12 */
|
Chris@76
|
13
|
Chris@76
|
14 if (!defined('SMF'))
|
Chris@76
|
15 die('Hacking attempt...');
|
Chris@76
|
16
|
Chris@76
|
17 /*
|
Chris@76
|
18
|
Chris@76
|
19 void summary(int id_member)
|
Chris@76
|
20 // !!!
|
Chris@76
|
21
|
Chris@76
|
22 void showPosts(int id_member)
|
Chris@76
|
23 // !!!
|
Chris@76
|
24
|
Chris@76
|
25 void showAttachments(int id_member)
|
Chris@76
|
26 // !!!
|
Chris@76
|
27
|
Chris@76
|
28 void statPanel(int id_member)
|
Chris@76
|
29 // !!!
|
Chris@76
|
30
|
Chris@76
|
31 void tracking(int id_member)
|
Chris@76
|
32 // !!!
|
Chris@76
|
33
|
Chris@76
|
34 void trackUser(int id_member)
|
Chris@76
|
35 // !!!
|
Chris@76
|
36
|
Chris@76
|
37 int list_getUserErrorCount(string where)
|
Chris@76
|
38 // !!!
|
Chris@76
|
39
|
Chris@76
|
40 array list_getUserErrors(int start, int items_per_page, string sort, string where, array where_vars)
|
Chris@76
|
41 // !!!
|
Chris@76
|
42
|
Chris@76
|
43 int list_getIPMessageCount(string where)
|
Chris@76
|
44 // !!!
|
Chris@76
|
45
|
Chris@76
|
46 array list_getIPMessages(int start, int items_per_page, string sort, string where, array where_vars)
|
Chris@76
|
47 // !!!
|
Chris@76
|
48
|
Chris@76
|
49 void TrackIP(int id_member = none)
|
Chris@76
|
50 // !!!
|
Chris@76
|
51
|
Chris@76
|
52 void trackEdits(int id_member)
|
Chris@76
|
53 // !!!
|
Chris@76
|
54
|
Chris@76
|
55 int list_getProfileEditCount(int id_member)
|
Chris@76
|
56 // !!!
|
Chris@76
|
57
|
Chris@76
|
58 array list_getProfileEdits(int start, int items_per_page, string sort, int id_member)
|
Chris@76
|
59 // !!!
|
Chris@76
|
60
|
Chris@76
|
61 void showPermissions(int id_member)
|
Chris@76
|
62 // !!!
|
Chris@76
|
63
|
Chris@76
|
64 void viewWarning(int id_member)
|
Chris@76
|
65 // !!!
|
Chris@76
|
66 */
|
Chris@76
|
67
|
Chris@76
|
68 // View a summary.
|
Chris@76
|
69 function summary($memID)
|
Chris@76
|
70 {
|
Chris@76
|
71 global $context, $memberContext, $txt, $modSettings, $user_info, $user_profile, $sourcedir, $scripturl, $smcFunc;
|
Chris@76
|
72
|
Chris@76
|
73 // Attempt to load the member's profile data.
|
Chris@76
|
74 if (!loadMemberContext($memID) || !isset($memberContext[$memID]))
|
Chris@76
|
75 fatal_lang_error('not_a_user', false);
|
Chris@76
|
76
|
Chris@76
|
77 // Set up the stuff and load the user.
|
Chris@76
|
78 $context += array(
|
Chris@76
|
79 'page_title' => sprintf($txt['profile_of_username'], $memberContext[$memID]['name']),
|
Chris@76
|
80 'can_send_pm' => allowedTo('pm_send'),
|
Chris@76
|
81 'can_have_buddy' => allowedTo('profile_identity_own') && !empty($modSettings['enable_buddylist']),
|
Chris@76
|
82 'can_issue_warning' => in_array('w', $context['admin_features']) && allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1,
|
Chris@76
|
83 );
|
Chris@76
|
84 $context['member'] = &$memberContext[$memID];
|
Chris@76
|
85 $context['can_view_warning'] = in_array('w', $context['admin_features']) && (allowedTo('issue_warning') && !$context['user']['is_owner']) || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $context['user']['is_owner']));
|
Chris@76
|
86
|
Chris@76
|
87 // Set a canonical URL for this page.
|
Chris@76
|
88 $context['canonical_url'] = $scripturl . '?action=profile;u=' . $memID;
|
Chris@76
|
89
|
Chris@76
|
90 // Are there things we don't show?
|
Chris@76
|
91 $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
|
Chris@76
|
92
|
Chris@76
|
93 // See if they have broken any warning levels...
|
Chris@76
|
94 list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']);
|
Chris@76
|
95 if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning'])
|
Chris@76
|
96 $context['warning_status'] = $txt['profile_warning_is_muted'];
|
Chris@76
|
97 elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning'])
|
Chris@76
|
98 $context['warning_status'] = $txt['profile_warning_is_moderation'];
|
Chris@76
|
99 elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning'])
|
Chris@76
|
100 $context['warning_status'] = $txt['profile_warning_is_watch'];
|
Chris@76
|
101
|
Chris@76
|
102 // They haven't even been registered for a full day!?
|
Chris@76
|
103 $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24));
|
Chris@76
|
104 if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1)
|
Chris@76
|
105 $context['member']['posts_per_day'] = $txt['not_applicable'];
|
Chris@76
|
106 else
|
Chris@76
|
107 $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3);
|
Chris@76
|
108
|
Chris@76
|
109 // Set the age...
|
Chris@76
|
110 if (empty($context['member']['birth_date']))
|
Chris@76
|
111 {
|
Chris@76
|
112 $context['member'] += array(
|
Chris@76
|
113 'age' => $txt['not_applicable'],
|
Chris@76
|
114 'today_is_birthday' => false
|
Chris@76
|
115 );
|
Chris@76
|
116 }
|
Chris@76
|
117 else
|
Chris@76
|
118 {
|
Chris@76
|
119 list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d');
|
Chris@76
|
120 $datearray = getdate(forum_time());
|
Chris@76
|
121 $context['member'] += array(
|
Chris@76
|
122 'age' => $birth_year <= 4 ? $txt['not_applicable'] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
|
Chris@76
|
123 'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
|
Chris@76
|
124 );
|
Chris@76
|
125 }
|
Chris@76
|
126
|
Chris@76
|
127 if (allowedTo('moderate_forum'))
|
Chris@76
|
128 {
|
Chris@76
|
129 // Make sure it's a valid ip address; otherwise, don't bother...
|
Chris@76
|
130 if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup']))
|
Chris@76
|
131 $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']);
|
Chris@76
|
132 else
|
Chris@76
|
133 $context['member']['hostname'] = '';
|
Chris@76
|
134
|
Chris@76
|
135 $context['can_see_ip'] = true;
|
Chris@76
|
136 }
|
Chris@76
|
137 else
|
Chris@76
|
138 $context['can_see_ip'] = false;
|
Chris@76
|
139
|
Chris@76
|
140 if (!empty($modSettings['who_enabled']))
|
Chris@76
|
141 {
|
Chris@76
|
142 include_once($sourcedir . '/Who.php');
|
Chris@76
|
143 $action = determineActions($user_profile[$memID]['url']);
|
Chris@76
|
144
|
Chris@76
|
145 if ($action !== false)
|
Chris@76
|
146 $context['member']['action'] = $action;
|
Chris@76
|
147 }
|
Chris@76
|
148
|
Chris@76
|
149 // If the user is awaiting activation, and the viewer has permission - setup some activation context messages.
|
Chris@76
|
150 if ($context['member']['is_activated'] % 10 != 1 && allowedTo('moderate_forum'))
|
Chris@76
|
151 {
|
Chris@76
|
152 $context['activate_type'] = $context['member']['is_activated'];
|
Chris@76
|
153 // What should the link text be?
|
Chris@76
|
154 $context['activate_link_text'] = in_array($context['member']['is_activated'], array(3, 4, 5, 13, 14, 15)) ? $txt['account_approve'] : $txt['account_activate'];
|
Chris@76
|
155
|
Chris@76
|
156 // Should we show a custom message?
|
Chris@76
|
157 $context['activate_message'] = isset($txt['account_activate_method_' . $context['member']['is_activated'] % 10]) ? $txt['account_activate_method_' . $context['member']['is_activated'] % 10] : $txt['account_not_activated'];
|
Chris@76
|
158 }
|
Chris@76
|
159
|
Chris@76
|
160 // Is the signature even enabled on this forum?
|
Chris@76
|
161 $context['signature_enabled'] = substr($modSettings['signature_settings'], 0, 1) == 1;
|
Chris@76
|
162
|
Chris@76
|
163 // How about, are they banned?
|
Chris@76
|
164 $context['member']['bans'] = array();
|
Chris@76
|
165 if (allowedTo('moderate_forum'))
|
Chris@76
|
166 {
|
Chris@76
|
167 // Can they edit the ban?
|
Chris@76
|
168 $context['can_edit_ban'] = allowedTo('manage_bans');
|
Chris@76
|
169
|
Chris@76
|
170 $ban_query = array();
|
Chris@76
|
171 $ban_query_vars = array(
|
Chris@76
|
172 'time' => time(),
|
Chris@76
|
173 );
|
Chris@76
|
174 $ban_query[] = 'id_member = ' . $context['member']['id'];
|
Chris@76
|
175
|
Chris@76
|
176 // Valid IP?
|
Chris@76
|
177 if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $memberContext[$memID]['ip'], $ip_parts) == 1)
|
Chris@76
|
178 {
|
Chris@76
|
179 $ban_query[] = '((' . $ip_parts[1] . ' BETWEEN bi.ip_low1 AND bi.ip_high1)
|
Chris@76
|
180 AND (' . $ip_parts[2] . ' BETWEEN bi.ip_low2 AND bi.ip_high2)
|
Chris@76
|
181 AND (' . $ip_parts[3] . ' BETWEEN bi.ip_low3 AND bi.ip_high3)
|
Chris@76
|
182 AND (' . $ip_parts[4] . ' BETWEEN bi.ip_low4 AND bi.ip_high4))';
|
Chris@76
|
183
|
Chris@76
|
184 // Do we have a hostname already?
|
Chris@76
|
185 if (!empty($context['member']['hostname']))
|
Chris@76
|
186 {
|
Chris@76
|
187 $ban_query[] = '({string:hostname} LIKE hostname)';
|
Chris@76
|
188 $ban_query_vars['hostname'] = $context['member']['hostname'];
|
Chris@76
|
189 }
|
Chris@76
|
190 }
|
Chris@76
|
191 // Use '255.255.255.255' for 'unknown' - it's not valid anyway.
|
Chris@76
|
192 elseif ($memberContext[$memID]['ip'] == 'unknown')
|
Chris@76
|
193 $ban_query[] = '(bi.ip_low1 = 255 AND bi.ip_high1 = 255
|
Chris@76
|
194 AND bi.ip_low2 = 255 AND bi.ip_high2 = 255
|
Chris@76
|
195 AND bi.ip_low3 = 255 AND bi.ip_high3 = 255
|
Chris@76
|
196 AND bi.ip_low4 = 255 AND bi.ip_high4 = 255)';
|
Chris@76
|
197
|
Chris@76
|
198 // Check their email as well...
|
Chris@76
|
199 if (strlen($context['member']['email']) != 0)
|
Chris@76
|
200 {
|
Chris@76
|
201 $ban_query[] = '({string:email} LIKE bi.email_address)';
|
Chris@76
|
202 $ban_query_vars['email'] = $context['member']['email'];
|
Chris@76
|
203 }
|
Chris@76
|
204
|
Chris@76
|
205 // So... are they banned? Dying to know!
|
Chris@76
|
206 $request = $smcFunc['db_query']('', '
|
Chris@76
|
207 SELECT bg.id_ban_group, bg.name, bg.cannot_access, bg.cannot_post, bg.cannot_register,
|
Chris@76
|
208 bg.cannot_login, bg.reason
|
Chris@76
|
209 FROM {db_prefix}ban_items AS bi
|
Chris@76
|
210 INNER JOIN {db_prefix}ban_groups AS bg ON (bg.id_ban_group = bi.id_ban_group AND (bg.expire_time IS NULL OR bg.expire_time > {int:time}))
|
Chris@76
|
211 WHERE (' . implode(' OR ', $ban_query) . ')',
|
Chris@76
|
212 $ban_query_vars
|
Chris@76
|
213 );
|
Chris@76
|
214 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
215 {
|
Chris@76
|
216 // Work out what restrictions we actually have.
|
Chris@76
|
217 $ban_restrictions = array();
|
Chris@76
|
218 foreach (array('access', 'register', 'login', 'post') as $type)
|
Chris@76
|
219 if ($row['cannot_' . $type])
|
Chris@76
|
220 $ban_restrictions[] = $txt['ban_type_' . $type];
|
Chris@76
|
221
|
Chris@76
|
222 // No actual ban in place?
|
Chris@76
|
223 if (empty($ban_restrictions))
|
Chris@76
|
224 continue;
|
Chris@76
|
225
|
Chris@76
|
226 // Prepare the link for context.
|
Chris@76
|
227 $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>');
|
Chris@76
|
228
|
Chris@76
|
229 $context['member']['bans'][$row['id_ban_group']] = array(
|
Chris@76
|
230 'reason' => empty($row['reason']) ? '' : '<br /><br /><strong>' . $txt['ban_reason'] . ':</strong> ' . $row['reason'],
|
Chris@76
|
231 'cannot' => array(
|
Chris@76
|
232 'access' => !empty($row['cannot_access']),
|
Chris@76
|
233 'register' => !empty($row['cannot_register']),
|
Chris@76
|
234 'post' => !empty($row['cannot_post']),
|
Chris@76
|
235 'login' => !empty($row['cannot_login']),
|
Chris@76
|
236 ),
|
Chris@76
|
237 'explanation' => $ban_explanation,
|
Chris@76
|
238 );
|
Chris@76
|
239 }
|
Chris@76
|
240 $smcFunc['db_free_result']($request);
|
Chris@76
|
241 }
|
Chris@76
|
242
|
Chris@76
|
243 loadCustomFields($memID);
|
Chris@76
|
244 }
|
Chris@76
|
245
|
Chris@76
|
246 // !!! This function needs to be split up properly.
|
Chris@76
|
247 // Show all posts by the current user
|
Chris@76
|
248 function showPosts($memID)
|
Chris@76
|
249 {
|
Chris@76
|
250 global $txt, $user_info, $scripturl, $modSettings;
|
Chris@76
|
251 global $context, $user_profile, $sourcedir, $smcFunc, $board;
|
Chris@76
|
252
|
Chris@76
|
253 // Some initial context.
|
Chris@76
|
254 $context['start'] = (int) $_REQUEST['start'];
|
Chris@76
|
255 $context['current_member'] = $memID;
|
Chris@76
|
256
|
Chris@76
|
257 // Create the tabs for the template.
|
Chris@76
|
258 $context[$context['profile_menu_name']]['tab_data'] = array(
|
Chris@76
|
259 'title' => $txt['showPosts'],
|
Chris@76
|
260 'description' => $txt['showPosts_help'],
|
Chris@76
|
261 'icon' => 'profile_sm.gif',
|
Chris@76
|
262 'tabs' => array(
|
Chris@76
|
263 'messages' => array(
|
Chris@76
|
264 ),
|
Chris@76
|
265 'topics' => array(
|
Chris@76
|
266 ),
|
Chris@76
|
267 'attach' => array(
|
Chris@76
|
268 ),
|
Chris@76
|
269 ),
|
Chris@76
|
270 );
|
Chris@76
|
271
|
Chris@76
|
272 // Set the page title
|
Chris@76
|
273 $context['page_title'] = $txt['showPosts'] . ' - ' . $user_profile[$memID]['real_name'];
|
Chris@76
|
274
|
Chris@76
|
275 // Is the load average too high to allow searching just now?
|
Chris@76
|
276 if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts'])
|
Chris@76
|
277 fatal_lang_error('loadavg_show_posts_disabled', false);
|
Chris@76
|
278
|
Chris@76
|
279 // If we're specifically dealing with attachments use that function!
|
Chris@76
|
280 if (isset($_GET['sa']) && $_GET['sa'] == 'attach')
|
Chris@76
|
281 return showAttachments($memID);
|
Chris@76
|
282
|
Chris@76
|
283 // Are we just viewing topics?
|
Chris@76
|
284 $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false;
|
Chris@76
|
285
|
Chris@76
|
286 // If just deleting a message, do it and then redirect back.
|
Chris@76
|
287 if (isset($_GET['delete']) && !$context['is_topics'])
|
Chris@76
|
288 {
|
Chris@76
|
289 checkSession('get');
|
Chris@76
|
290
|
Chris@76
|
291 // We need msg info for logging.
|
Chris@76
|
292 $request = $smcFunc['db_query']('', '
|
Chris@76
|
293 SELECT subject, id_member, id_topic, id_board
|
Chris@76
|
294 FROM {db_prefix}messages
|
Chris@76
|
295 WHERE id_msg = {int:id_msg}',
|
Chris@76
|
296 array(
|
Chris@76
|
297 'id_msg' => (int) $_GET['delete'],
|
Chris@76
|
298 )
|
Chris@76
|
299 );
|
Chris@76
|
300 $info = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
301 $smcFunc['db_free_result']($request);
|
Chris@76
|
302
|
Chris@76
|
303 // Trying to remove a message that doesn't exist.
|
Chris@76
|
304 if (empty($info))
|
Chris@76
|
305 redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
|
Chris@76
|
306
|
Chris@76
|
307 // We can be lazy, since removeMessage() will check the permissions for us.
|
Chris@76
|
308 require_once($sourcedir . '/RemoveTopic.php');
|
Chris@76
|
309 removeMessage((int) $_GET['delete']);
|
Chris@76
|
310
|
Chris@76
|
311 // Add it to the mod log.
|
Chris@76
|
312 if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
|
Chris@76
|
313 logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
|
Chris@76
|
314
|
Chris@76
|
315 // Back to... where we are now ;).
|
Chris@76
|
316 redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
|
Chris@76
|
317 }
|
Chris@76
|
318
|
Chris@76
|
319 // Default to 10.
|
Chris@76
|
320 if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
|
Chris@76
|
321 $_REQUEST['viewscount'] = '10';
|
Chris@76
|
322
|
Chris@76
|
323 if ($context['is_topics'])
|
Chris@76
|
324 $request = $smcFunc['db_query']('', '
|
Chris@76
|
325 SELECT COUNT(*)
|
Chris@76
|
326 FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : '
|
Chris@76
|
327 INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . '
|
Chris@76
|
328 WHERE t.id_member_started = {int:current_member}' . (!empty($board) ? '
|
Chris@76
|
329 AND t.id_board = {int:board}' : '') . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
|
Chris@76
|
330 AND t.approved = {int:is_approved}'),
|
Chris@76
|
331 array(
|
Chris@76
|
332 'current_member' => $memID,
|
Chris@76
|
333 'is_approved' => 1,
|
Chris@76
|
334 'board' => $board,
|
Chris@76
|
335 )
|
Chris@76
|
336 );
|
Chris@76
|
337 else
|
Chris@76
|
338 $request = $smcFunc['db_query']('', '
|
Chris@76
|
339 SELECT COUNT(*)
|
Chris@76
|
340 FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : '
|
Chris@76
|
341 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . '
|
Chris@76
|
342 WHERE m.id_member = {int:current_member}' . (!empty($board) ? '
|
Chris@76
|
343 AND m.id_board = {int:board}' : '') . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
|
Chris@76
|
344 AND m.approved = {int:is_approved}'),
|
Chris@76
|
345 array(
|
Chris@76
|
346 'current_member' => $memID,
|
Chris@76
|
347 'is_approved' => 1,
|
Chris@76
|
348 'board' => $board,
|
Chris@76
|
349 )
|
Chris@76
|
350 );
|
Chris@76
|
351 list ($msgCount) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
352 $smcFunc['db_free_result']($request);
|
Chris@76
|
353
|
Chris@76
|
354 $request = $smcFunc['db_query']('', '
|
Chris@76
|
355 SELECT MIN(id_msg), MAX(id_msg)
|
Chris@76
|
356 FROM {db_prefix}messages AS m
|
Chris@76
|
357 WHERE m.id_member = {int:current_member}' . (!empty($board) ? '
|
Chris@76
|
358 AND m.id_board = {int:board}' : '') . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
|
Chris@76
|
359 AND m.approved = {int:is_approved}'),
|
Chris@76
|
360 array(
|
Chris@76
|
361 'current_member' => $memID,
|
Chris@76
|
362 'is_approved' => 1,
|
Chris@76
|
363 'board' => $board,
|
Chris@76
|
364 )
|
Chris@76
|
365 );
|
Chris@76
|
366 list ($min_msg_member, $max_msg_member) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
367 $smcFunc['db_free_result']($request);
|
Chris@76
|
368
|
Chris@76
|
369 $reverse = false;
|
Chris@76
|
370 $range_limit = '';
|
Chris@76
|
371 $maxIndex = (int) $modSettings['defaultMaxMessages'];
|
Chris@76
|
372
|
Chris@76
|
373 // Make sure the starting place makes sense and construct our friend the page index.
|
Chris@76
|
374 $context['page_index'] = constructPageIndex($scripturl . '?action=profile;u=' . $memID . ';area=showposts' . ($context['is_topics'] ? ';sa=topics' : '') . (!empty($board) ? ';board=' . $board : ''), $context['start'], $msgCount, $maxIndex);
|
Chris@76
|
375 $context['current_page'] = $context['start'] / $maxIndex;
|
Chris@76
|
376
|
Chris@76
|
377 // Reverse the query if we're past 50% of the pages for better performance.
|
Chris@76
|
378 $start = $context['start'];
|
Chris@76
|
379 $reverse = $_REQUEST['start'] > $msgCount / 2;
|
Chris@76
|
380 if ($reverse)
|
Chris@76
|
381 {
|
Chris@76
|
382 $maxIndex = $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] + 1 && $msgCount > $context['start'] ? $msgCount - $context['start'] : (int) $modSettings['defaultMaxMessages'];
|
Chris@76
|
383 $start = $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] + 1 || $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] ? 0 : $msgCount - $context['start'] - $modSettings['defaultMaxMessages'];
|
Chris@76
|
384 }
|
Chris@76
|
385
|
Chris@76
|
386 // Guess the range of messages to be shown.
|
Chris@76
|
387 if ($msgCount > 1000)
|
Chris@76
|
388 {
|
Chris@76
|
389 $margin = floor(($max_msg_member - $min_msg_member) * (($start + $modSettings['defaultMaxMessages']) / $msgCount) + .1 * ($max_msg_member - $min_msg_member));
|
Chris@76
|
390 // Make a bigger margin for topics only.
|
Chris@76
|
391 if ($context['is_topics'])
|
Chris@76
|
392 {
|
Chris@76
|
393 $margin *= 5;
|
Chris@76
|
394 $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin);
|
Chris@76
|
395 }
|
Chris@76
|
396 else
|
Chris@76
|
397 $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
|
Chris@76
|
398 }
|
Chris@76
|
399
|
Chris@76
|
400 // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks.
|
Chris@76
|
401 $looped = false;
|
Chris@76
|
402 while (true)
|
Chris@76
|
403 {
|
Chris@76
|
404 if ($context['is_topics'])
|
Chris@76
|
405 {
|
Chris@76
|
406 $request = $smcFunc['db_query']('', '
|
Chris@76
|
407 SELECT
|
Chris@76
|
408 b.id_board, b.name AS bname, c.id_cat, c.name AS cname, t.id_member_started, t.id_first_msg, t.id_last_msg,
|
Chris@76
|
409 t.approved, m.body, m.smileys_enabled, m.subject, m.poster_time, m.id_topic, m.id_msg
|
Chris@76
|
410 FROM {db_prefix}topics AS t
|
Chris@76
|
411 INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
|
Chris@76
|
412 LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
|
Chris@76
|
413 INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
|
Chris@76
|
414 WHERE t.id_member_started = {int:current_member}' . (!empty($board) ? '
|
Chris@76
|
415 AND t.id_board = {int:board}' : '') . (empty($range_limit) ? '' : '
|
Chris@76
|
416 AND ' . $range_limit) . '
|
Chris@76
|
417 AND {query_see_board}' . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
|
Chris@76
|
418 AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}') . '
|
Chris@76
|
419 ORDER BY t.id_first_msg ' . ($reverse ? 'ASC' : 'DESC') . '
|
Chris@76
|
420 LIMIT ' . $start . ', ' . $maxIndex,
|
Chris@76
|
421 array(
|
Chris@76
|
422 'current_member' => $memID,
|
Chris@76
|
423 'is_approved' => 1,
|
Chris@76
|
424 'board' => $board,
|
Chris@76
|
425 )
|
Chris@76
|
426 );
|
Chris@76
|
427 }
|
Chris@76
|
428 else
|
Chris@76
|
429 {
|
Chris@76
|
430 $request = $smcFunc['db_query']('', '
|
Chris@76
|
431 SELECT
|
Chris@76
|
432 b.id_board, b.name AS bname, c.id_cat, c.name AS cname, m.id_topic, m.id_msg,
|
Chris@76
|
433 t.id_member_started, t.id_first_msg, t.id_last_msg, m.body, m.smileys_enabled,
|
Chris@76
|
434 m.subject, m.poster_time, m.approved
|
Chris@76
|
435 FROM {db_prefix}messages AS m
|
Chris@76
|
436 INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
|
Chris@76
|
437 INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
|
Chris@76
|
438 LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
|
Chris@76
|
439 WHERE m.id_member = {int:current_member}' . (!empty($board) ? '
|
Chris@76
|
440 AND b.id_board = {int:board}' : '') . (empty($range_limit) ? '' : '
|
Chris@76
|
441 AND ' . $range_limit) . '
|
Chris@76
|
442 AND {query_see_board}' . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
|
Chris@76
|
443 AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}') . '
|
Chris@76
|
444 ORDER BY m.id_msg ' . ($reverse ? 'ASC' : 'DESC') . '
|
Chris@76
|
445 LIMIT ' . $start . ', ' . $maxIndex,
|
Chris@76
|
446 array(
|
Chris@76
|
447 'current_member' => $memID,
|
Chris@76
|
448 'is_approved' => 1,
|
Chris@76
|
449 'board' => $board,
|
Chris@76
|
450 )
|
Chris@76
|
451 );
|
Chris@76
|
452 }
|
Chris@76
|
453
|
Chris@76
|
454 // Make sure we quit this loop.
|
Chris@76
|
455 if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped)
|
Chris@76
|
456 break;
|
Chris@76
|
457 $looped = true;
|
Chris@76
|
458 $range_limit = '';
|
Chris@76
|
459 }
|
Chris@76
|
460
|
Chris@76
|
461 // Start counting at the number of the first message displayed.
|
Chris@76
|
462 $counter = $reverse ? $context['start'] + $maxIndex + 1 : $context['start'];
|
Chris@76
|
463 $context['posts'] = array();
|
Chris@76
|
464 $board_ids = array('own' => array(), 'any' => array());
|
Chris@76
|
465 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
466 {
|
Chris@76
|
467 // Censor....
|
Chris@76
|
468 censorText($row['body']);
|
Chris@76
|
469 censorText($row['subject']);
|
Chris@76
|
470
|
Chris@76
|
471 // Do the code.
|
Chris@76
|
472 $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
|
Chris@76
|
473
|
Chris@76
|
474 // And the array...
|
Chris@76
|
475 $context['posts'][$counter += $reverse ? -1 : 1] = array(
|
Chris@76
|
476 'body' => $row['body'],
|
Chris@76
|
477 'counter' => $counter,
|
Chris@76
|
478 'alternate' => $counter % 2,
|
Chris@76
|
479 'category' => array(
|
Chris@76
|
480 'name' => $row['cname'],
|
Chris@76
|
481 'id' => $row['id_cat']
|
Chris@76
|
482 ),
|
Chris@76
|
483 'board' => array(
|
Chris@76
|
484 'name' => $row['bname'],
|
Chris@76
|
485 'id' => $row['id_board']
|
Chris@76
|
486 ),
|
Chris@76
|
487 'topic' => $row['id_topic'],
|
Chris@76
|
488 'subject' => $row['subject'],
|
Chris@76
|
489 'start' => 'msg' . $row['id_msg'],
|
Chris@76
|
490 'time' => timeformat($row['poster_time']),
|
Chris@76
|
491 'timestamp' => forum_time(true, $row['poster_time']),
|
Chris@76
|
492 'id' => $row['id_msg'],
|
Chris@76
|
493 'can_reply' => false,
|
Chris@76
|
494 'can_mark_notify' => false,
|
Chris@76
|
495 'can_delete' => false,
|
Chris@76
|
496 'delete_possible' => ($row['id_first_msg'] != $row['id_msg'] || $row['id_last_msg'] == $row['id_msg']) && (empty($modSettings['edit_disable_time']) || $row['poster_time'] + $modSettings['edit_disable_time'] * 60 >= time()),
|
Chris@76
|
497 'approved' => $row['approved'],
|
Chris@76
|
498 );
|
Chris@76
|
499
|
Chris@76
|
500 if ($user_info['id'] == $row['id_member_started'])
|
Chris@76
|
501 $board_ids['own'][$row['id_board']][] = $counter;
|
Chris@76
|
502 $board_ids['any'][$row['id_board']][] = $counter;
|
Chris@76
|
503 }
|
Chris@76
|
504 $smcFunc['db_free_result']($request);
|
Chris@76
|
505
|
Chris@76
|
506 // All posts were retrieved in reverse order, get them right again.
|
Chris@76
|
507 if ($reverse)
|
Chris@76
|
508 $context['posts'] = array_reverse($context['posts'], true);
|
Chris@76
|
509
|
Chris@76
|
510 // These are all the permissions that are different from board to board..
|
Chris@76
|
511 if ($context['is_topics'])
|
Chris@76
|
512 $permissions = array(
|
Chris@76
|
513 'own' => array(
|
Chris@76
|
514 'post_reply_own' => 'can_reply',
|
Chris@76
|
515 ),
|
Chris@76
|
516 'any' => array(
|
Chris@76
|
517 'post_reply_any' => 'can_reply',
|
Chris@76
|
518 'mark_any_notify' => 'can_mark_notify',
|
Chris@76
|
519 )
|
Chris@76
|
520 );
|
Chris@76
|
521 else
|
Chris@76
|
522 $permissions = array(
|
Chris@76
|
523 'own' => array(
|
Chris@76
|
524 'post_reply_own' => 'can_reply',
|
Chris@76
|
525 'delete_own' => 'can_delete',
|
Chris@76
|
526 ),
|
Chris@76
|
527 'any' => array(
|
Chris@76
|
528 'post_reply_any' => 'can_reply',
|
Chris@76
|
529 'mark_any_notify' => 'can_mark_notify',
|
Chris@76
|
530 'delete_any' => 'can_delete',
|
Chris@76
|
531 )
|
Chris@76
|
532 );
|
Chris@76
|
533
|
Chris@76
|
534 // For every permission in the own/any lists...
|
Chris@76
|
535 foreach ($permissions as $type => $list)
|
Chris@76
|
536 {
|
Chris@76
|
537 foreach ($list as $permission => $allowed)
|
Chris@76
|
538 {
|
Chris@76
|
539 // Get the boards they can do this on...
|
Chris@76
|
540 $boards = boardsAllowedTo($permission);
|
Chris@76
|
541
|
Chris@76
|
542 // Hmm, they can do it on all boards, can they?
|
Chris@76
|
543 if (!empty($boards) && $boards[0] == 0)
|
Chris@76
|
544 $boards = array_keys($board_ids[$type]);
|
Chris@76
|
545
|
Chris@76
|
546 // Now go through each board they can do the permission on.
|
Chris@76
|
547 foreach ($boards as $board_id)
|
Chris@76
|
548 {
|
Chris@76
|
549 // There aren't any posts displayed from this board.
|
Chris@76
|
550 if (!isset($board_ids[$type][$board_id]))
|
Chris@76
|
551 continue;
|
Chris@76
|
552
|
Chris@76
|
553 // Set the permission to true ;).
|
Chris@76
|
554 foreach ($board_ids[$type][$board_id] as $counter)
|
Chris@76
|
555 $context['posts'][$counter][$allowed] = true;
|
Chris@76
|
556 }
|
Chris@76
|
557 }
|
Chris@76
|
558 }
|
Chris@76
|
559
|
Chris@76
|
560 // Clean up after posts that cannot be deleted and quoted.
|
Chris@76
|
561 $quote_enabled = empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']));
|
Chris@76
|
562 foreach ($context['posts'] as $counter => $dummy)
|
Chris@76
|
563 {
|
Chris@76
|
564 $context['posts'][$counter]['can_delete'] &= $context['posts'][$counter]['delete_possible'];
|
Chris@76
|
565 $context['posts'][$counter]['can_quote'] = $context['posts'][$counter]['can_reply'] && $quote_enabled;
|
Chris@76
|
566 }
|
Chris@76
|
567 }
|
Chris@76
|
568
|
Chris@76
|
569 // Show all the attachments of a user.
|
Chris@76
|
570 function showAttachments($memID)
|
Chris@76
|
571 {
|
Chris@76
|
572 global $txt, $user_info, $scripturl, $modSettings, $board;
|
Chris@76
|
573 global $context, $user_profile, $sourcedir, $smcFunc;
|
Chris@76
|
574
|
Chris@76
|
575 // OBEY permissions!
|
Chris@76
|
576 $boardsAllowed = boardsAllowedTo('view_attachments');
|
Chris@76
|
577 // Make sure we can't actually see anything...
|
Chris@76
|
578 if (empty($boardsAllowed))
|
Chris@76
|
579 $boardsAllowed = array(-1);
|
Chris@76
|
580
|
Chris@76
|
581 // Get the total number of attachments they have posted.
|
Chris@76
|
582 $request = $smcFunc['db_query']('', '
|
Chris@76
|
583 SELECT COUNT(*)
|
Chris@76
|
584 FROM {db_prefix}attachments AS a
|
Chris@76
|
585 INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg)
|
Chris@76
|
586 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})
|
Chris@76
|
587 WHERE a.attachment_type = {int:attachment_type}
|
Chris@76
|
588 AND a.id_msg != {int:no_message}
|
Chris@76
|
589 AND m.id_member = {int:current_member}' . (!empty($board) ? '
|
Chris@76
|
590 AND b.id_board = {int:board}' : '') . (!in_array(0, $boardsAllowed) ? '
|
Chris@76
|
591 AND b.id_board IN ({array_int:boards_list})' : '') . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
|
Chris@76
|
592 AND m.approved = {int:is_approved}'),
|
Chris@76
|
593 array(
|
Chris@76
|
594 'boards_list' => $boardsAllowed,
|
Chris@76
|
595 'attachment_type' => 0,
|
Chris@76
|
596 'no_message' => 0,
|
Chris@76
|
597 'current_member' => $memID,
|
Chris@76
|
598 'is_approved' => 1,
|
Chris@76
|
599 'board' => $board,
|
Chris@76
|
600 )
|
Chris@76
|
601 );
|
Chris@76
|
602 list ($attachCount) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
603 $smcFunc['db_free_result']($request);
|
Chris@76
|
604
|
Chris@76
|
605 $maxIndex = (int) $modSettings['defaultMaxMessages'];
|
Chris@76
|
606
|
Chris@76
|
607 // What about ordering?
|
Chris@76
|
608 $sortTypes = array(
|
Chris@76
|
609 'filename' => 'a.filename',
|
Chris@76
|
610 'downloads' => 'a.downloads',
|
Chris@76
|
611 'subject' => 'm.subject',
|
Chris@76
|
612 'posted' => 'm.poster_time',
|
Chris@76
|
613 );
|
Chris@76
|
614 $context['sort_order'] = isset($_GET['sort']) && isset($sortTypes[$_GET['sort']]) ? $_GET['sort'] : 'posted';
|
Chris@76
|
615 $context['sort_direction'] = isset($_GET['asc']) ? 'up' : 'down';
|
Chris@76
|
616
|
Chris@76
|
617 $sort = $sortTypes[$context['sort_order']];
|
Chris@76
|
618
|
Chris@76
|
619 // Let's get ourselves a lovely page index.
|
Chris@76
|
620 $context['page_index'] = constructPageIndex($scripturl . '?action=profile;u=' . $memID . ';area=showposts;sa=attach;sort=' . $context['sort_order'] . ($context['sort_direction'] == 'up' ? ';asc' : ''), $context['start'], $attachCount, $maxIndex);
|
Chris@76
|
621
|
Chris@76
|
622 // Retrieve some attachments.
|
Chris@76
|
623 $request = $smcFunc['db_query']('', '
|
Chris@76
|
624 SELECT a.id_attach, a.id_msg, a.filename, a.downloads, a.approved, m.id_msg, m.id_topic,
|
Chris@76
|
625 m.id_board, m.poster_time, m.subject, b.name
|
Chris@76
|
626 FROM {db_prefix}attachments AS a
|
Chris@76
|
627 INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg)
|
Chris@76
|
628 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})
|
Chris@76
|
629 WHERE a.attachment_type = {int:attachment_type}
|
Chris@76
|
630 AND a.id_msg != {int:no_message}
|
Chris@76
|
631 AND m.id_member = {int:current_member}' . (!empty($board) ? '
|
Chris@76
|
632 AND b.id_board = {int:board}' : '') . (!in_array(0, $boardsAllowed) ? '
|
Chris@76
|
633 AND b.id_board IN ({array_int:boards_list})' : '') . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
|
Chris@76
|
634 AND m.approved = {int:is_approved}') . '
|
Chris@76
|
635 ORDER BY {raw:sort}
|
Chris@76
|
636 LIMIT {int:offset}, {int:limit}',
|
Chris@76
|
637 array(
|
Chris@76
|
638 'boards_list' => $boardsAllowed,
|
Chris@76
|
639 'attachment_type' => 0,
|
Chris@76
|
640 'no_message' => 0,
|
Chris@76
|
641 'current_member' => $memID,
|
Chris@76
|
642 'is_approved' => 1,
|
Chris@76
|
643 'board' => $board,
|
Chris@76
|
644 'sort' => $sort . ' ' . ($context['sort_direction'] == 'down' ? 'DESC' : 'ASC'),
|
Chris@76
|
645 'offset' => $context['start'],
|
Chris@76
|
646 'limit' => $maxIndex,
|
Chris@76
|
647 )
|
Chris@76
|
648 );
|
Chris@76
|
649 $context['attachments'] = array();
|
Chris@76
|
650 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
651 {
|
Chris@76
|
652 $row['subject'] = censorText($row['subject']);
|
Chris@76
|
653
|
Chris@76
|
654 $context['attachments'][] = array(
|
Chris@76
|
655 'id' => $row['id_attach'],
|
Chris@76
|
656 'filename' => $row['filename'],
|
Chris@76
|
657 'downloads' => $row['downloads'],
|
Chris@76
|
658 'subject' => $row['subject'],
|
Chris@76
|
659 'posted' => timeformat($row['poster_time']),
|
Chris@76
|
660 'msg' => $row['id_msg'],
|
Chris@76
|
661 'topic' => $row['id_topic'],
|
Chris@76
|
662 'board' => $row['id_board'],
|
Chris@76
|
663 'board_name' => $row['name'],
|
Chris@76
|
664 'approved' => $row['approved'],
|
Chris@76
|
665 );
|
Chris@76
|
666 }
|
Chris@76
|
667 $smcFunc['db_free_result']($request);
|
Chris@76
|
668 }
|
Chris@76
|
669
|
Chris@76
|
670 function statPanel($memID)
|
Chris@76
|
671 {
|
Chris@76
|
672 global $txt, $scripturl, $context, $user_profile, $user_info, $modSettings, $smcFunc;
|
Chris@76
|
673
|
Chris@76
|
674 $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name'];
|
Chris@76
|
675
|
Chris@76
|
676 // General user statistics.
|
Chris@76
|
677 $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400);
|
Chris@76
|
678 $timeHours = floor(($user_profile[$memID]['total_time_logged_in'] % 86400) / 3600);
|
Chris@76
|
679 $context['time_logged_in'] = ($timeDays > 0 ? $timeDays . $txt['totalTimeLogged2'] : '') . ($timeHours > 0 ? $timeHours . $txt['totalTimeLogged3'] : '') . floor(($user_profile[$memID]['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged4'];
|
Chris@76
|
680 $context['num_posts'] = comma_format($user_profile[$memID]['posts']);
|
Chris@76
|
681
|
Chris@76
|
682 // Number of topics started.
|
Chris@76
|
683 $result = $smcFunc['db_query']('', '
|
Chris@76
|
684 SELECT COUNT(*)
|
Chris@76
|
685 FROM {db_prefix}topics
|
Chris@76
|
686 WHERE id_member_started = {int:current_member}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
|
Chris@76
|
687 AND id_board != {int:recycle_board}' : ''),
|
Chris@76
|
688 array(
|
Chris@76
|
689 'current_member' => $memID,
|
Chris@76
|
690 'recycle_board' => $modSettings['recycle_board'],
|
Chris@76
|
691 )
|
Chris@76
|
692 );
|
Chris@76
|
693 list ($context['num_topics']) = $smcFunc['db_fetch_row']($result);
|
Chris@76
|
694 $smcFunc['db_free_result']($result);
|
Chris@76
|
695
|
Chris@76
|
696 // Number polls started.
|
Chris@76
|
697 $result = $smcFunc['db_query']('', '
|
Chris@76
|
698 SELECT COUNT(*)
|
Chris@76
|
699 FROM {db_prefix}topics
|
Chris@76
|
700 WHERE id_member_started = {int:current_member}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
|
Chris@76
|
701 AND id_board != {int:recycle_board}' : '') . '
|
Chris@76
|
702 AND id_poll != {int:no_poll}',
|
Chris@76
|
703 array(
|
Chris@76
|
704 'current_member' => $memID,
|
Chris@76
|
705 'recycle_board' => $modSettings['recycle_board'],
|
Chris@76
|
706 'no_poll' => 0,
|
Chris@76
|
707 )
|
Chris@76
|
708 );
|
Chris@76
|
709 list ($context['num_polls']) = $smcFunc['db_fetch_row']($result);
|
Chris@76
|
710 $smcFunc['db_free_result']($result);
|
Chris@76
|
711
|
Chris@76
|
712 // Number polls voted in.
|
Chris@76
|
713 $result = $smcFunc['db_query']('distinct_poll_votes', '
|
Chris@76
|
714 SELECT COUNT(DISTINCT id_poll)
|
Chris@76
|
715 FROM {db_prefix}log_polls
|
Chris@76
|
716 WHERE id_member = {int:current_member}',
|
Chris@76
|
717 array(
|
Chris@76
|
718 'current_member' => $memID,
|
Chris@76
|
719 )
|
Chris@76
|
720 );
|
Chris@76
|
721 list ($context['num_votes']) = $smcFunc['db_fetch_row']($result);
|
Chris@76
|
722 $smcFunc['db_free_result']($result);
|
Chris@76
|
723
|
Chris@76
|
724 // Format the numbers...
|
Chris@76
|
725 $context['num_topics'] = comma_format($context['num_topics']);
|
Chris@76
|
726 $context['num_polls'] = comma_format($context['num_polls']);
|
Chris@76
|
727 $context['num_votes'] = comma_format($context['num_votes']);
|
Chris@76
|
728
|
Chris@76
|
729 // Grab the board this member posted in most often.
|
Chris@76
|
730 $result = $smcFunc['db_query']('', '
|
Chris@76
|
731 SELECT
|
Chris@76
|
732 b.id_board, MAX(b.name) AS name, MAX(b.num_posts) AS num_posts, COUNT(*) AS message_count
|
Chris@76
|
733 FROM {db_prefix}messages AS m
|
Chris@76
|
734 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
|
Chris@76
|
735 WHERE m.id_member = {int:current_member}
|
Chris@76
|
736 AND b.count_posts = {int:count_enabled}
|
Chris@76
|
737 AND {query_see_board}
|
Chris@76
|
738 GROUP BY b.id_board
|
Chris@76
|
739 ORDER BY message_count DESC
|
Chris@76
|
740 LIMIT 10',
|
Chris@76
|
741 array(
|
Chris@76
|
742 'current_member' => $memID,
|
Chris@76
|
743 'count_enabled' => 0,
|
Chris@76
|
744 )
|
Chris@76
|
745 );
|
Chris@76
|
746 $context['popular_boards'] = array();
|
Chris@76
|
747 while ($row = $smcFunc['db_fetch_assoc']($result))
|
Chris@76
|
748 {
|
Chris@76
|
749 $context['popular_boards'][$row['id_board']] = array(
|
Chris@76
|
750 'id' => $row['id_board'],
|
Chris@76
|
751 'posts' => $row['message_count'],
|
Chris@76
|
752 'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
|
Chris@76
|
753 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>',
|
Chris@76
|
754 'posts_percent' => $user_profile[$memID]['posts'] == 0 ? 0 : ($row['message_count'] * 100) / $user_profile[$memID]['posts'],
|
Chris@76
|
755 'total_posts' => $row['num_posts'],
|
Chris@76
|
756 'total_posts_member' => $user_profile[$memID]['posts'],
|
Chris@76
|
757 );
|
Chris@76
|
758 }
|
Chris@76
|
759 $smcFunc['db_free_result']($result);
|
Chris@76
|
760
|
Chris@76
|
761 // Now get the 10 boards this user has most often participated in.
|
Chris@76
|
762 $result = $smcFunc['db_query']('profile_board_stats', '
|
Chris@76
|
763 SELECT
|
Chris@76
|
764 b.id_board, MAX(b.name) AS name, b.num_posts, COUNT(*) AS message_count,
|
Chris@76
|
765 CASE WHEN COUNT(*) > MAX(b.num_posts) THEN 1 ELSE COUNT(*) / MAX(b.num_posts) END * 100 AS percentage
|
Chris@76
|
766 FROM {db_prefix}messages AS m
|
Chris@76
|
767 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
|
Chris@76
|
768 WHERE m.id_member = {int:current_member}
|
Chris@76
|
769 AND {query_see_board}
|
Chris@76
|
770 GROUP BY b.id_board, b.num_posts
|
Chris@76
|
771 ORDER BY percentage DESC
|
Chris@76
|
772 LIMIT 10',
|
Chris@76
|
773 array(
|
Chris@76
|
774 'current_member' => $memID,
|
Chris@76
|
775 )
|
Chris@76
|
776 );
|
Chris@76
|
777 $context['board_activity'] = array();
|
Chris@76
|
778 while ($row = $smcFunc['db_fetch_assoc']($result))
|
Chris@76
|
779 {
|
Chris@76
|
780 $context['board_activity'][$row['id_board']] = array(
|
Chris@76
|
781 'id' => $row['id_board'],
|
Chris@76
|
782 'posts' => $row['message_count'],
|
Chris@76
|
783 'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
|
Chris@76
|
784 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>',
|
Chris@76
|
785 'percent' => comma_format((float) $row['percentage'], 2),
|
Chris@76
|
786 'posts_percent' => (float) $row['percentage'],
|
Chris@76
|
787 'total_posts' => $row['num_posts'],
|
Chris@76
|
788 );
|
Chris@76
|
789 }
|
Chris@76
|
790 $smcFunc['db_free_result']($result);
|
Chris@76
|
791
|
Chris@76
|
792 // Posting activity by time.
|
Chris@76
|
793 $result = $smcFunc['db_query']('user_activity_by_time', '
|
Chris@76
|
794 SELECT
|
Chris@76
|
795 HOUR(FROM_UNIXTIME(poster_time + {int:time_offset})) AS hour,
|
Chris@76
|
796 COUNT(*) AS post_count
|
Chris@76
|
797 FROM {db_prefix}messages
|
Chris@76
|
798 WHERE id_member = {int:current_member}' . ($modSettings['totalMessages'] > 100000 ? '
|
Chris@76
|
799 AND id_topic > {int:top_ten_thousand_topics}' : '') . '
|
Chris@76
|
800 GROUP BY hour',
|
Chris@76
|
801 array(
|
Chris@76
|
802 'current_member' => $memID,
|
Chris@76
|
803 'top_ten_thousand_topics' => $modSettings['totalTopics'] - 10000,
|
Chris@76
|
804 'time_offset' => (($user_info['time_offset'] + $modSettings['time_offset']) * 3600),
|
Chris@76
|
805 )
|
Chris@76
|
806 );
|
Chris@76
|
807 $maxPosts = $realPosts = 0;
|
Chris@76
|
808 $context['posts_by_time'] = array();
|
Chris@76
|
809 while ($row = $smcFunc['db_fetch_assoc']($result))
|
Chris@76
|
810 {
|
Chris@76
|
811 // Cast as an integer to remove the leading 0.
|
Chris@76
|
812 $row['hour'] = (int) $row['hour'];
|
Chris@76
|
813
|
Chris@76
|
814 $maxPosts = max($row['post_count'], $maxPosts);
|
Chris@76
|
815 $realPosts += $row['post_count'];
|
Chris@76
|
816
|
Chris@76
|
817 $context['posts_by_time'][$row['hour']] = array(
|
Chris@76
|
818 'hour' => $row['hour'],
|
Chris@76
|
819 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $row['hour'] : date('g a', mktime($row['hour'])),
|
Chris@76
|
820 'posts' => $row['post_count'],
|
Chris@76
|
821 'posts_percent' => 0,
|
Chris@76
|
822 'is_last' => $row['hour'] == 23,
|
Chris@76
|
823 );
|
Chris@76
|
824 }
|
Chris@76
|
825 $smcFunc['db_free_result']($result);
|
Chris@76
|
826
|
Chris@76
|
827 if ($maxPosts > 0)
|
Chris@76
|
828 for ($hour = 0; $hour < 24; $hour++)
|
Chris@76
|
829 {
|
Chris@76
|
830 if (!isset($context['posts_by_time'][$hour]))
|
Chris@76
|
831 $context['posts_by_time'][$hour] = array(
|
Chris@76
|
832 'hour' => $hour,
|
Chris@76
|
833 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)),
|
Chris@76
|
834 'posts' => 0,
|
Chris@76
|
835 'posts_percent' => 0,
|
Chris@76
|
836 'relative_percent' => 0,
|
Chris@76
|
837 'is_last' => $hour == 23,
|
Chris@76
|
838 );
|
Chris@76
|
839 else
|
Chris@76
|
840 {
|
Chris@76
|
841 $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts);
|
Chris@76
|
842 $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts);
|
Chris@76
|
843 }
|
Chris@76
|
844 }
|
Chris@76
|
845
|
Chris@76
|
846 // Put it in the right order.
|
Chris@76
|
847 ksort($context['posts_by_time']);
|
Chris@76
|
848 }
|
Chris@76
|
849
|
Chris@76
|
850 function tracking($memID)
|
Chris@76
|
851 {
|
Chris@76
|
852 global $sourcedir, $context, $txt, $scripturl, $modSettings, $user_profile;
|
Chris@76
|
853
|
Chris@76
|
854 $subActions = array(
|
Chris@76
|
855 'activity' => array('trackActivity', $txt['trackActivity']),
|
Chris@76
|
856 'ip' => array('TrackIP', $txt['trackIP']),
|
Chris@76
|
857 'edits' => array('trackEdits', $txt['trackEdits']),
|
Chris@76
|
858 );
|
Chris@76
|
859
|
Chris@76
|
860 $context['tracking_area'] = isset($_GET['sa']) && isset($subActions[$_GET['sa']]) ? $_GET['sa'] : 'activity';
|
Chris@76
|
861
|
Chris@76
|
862 if (isset($types[$context['tracking_area']][1]))
|
Chris@76
|
863 require_once($sourcedir . '/' . $types[$context['tracking_area']][1]);
|
Chris@76
|
864
|
Chris@76
|
865 // Create the tabs for the template.
|
Chris@76
|
866 $context[$context['profile_menu_name']]['tab_data'] = array(
|
Chris@76
|
867 'title' => $txt['tracking'],
|
Chris@76
|
868 'description' => $txt['tracking_description'],
|
Chris@76
|
869 'icon' => 'profile_sm.gif',
|
Chris@76
|
870 'tabs' => array(
|
Chris@76
|
871 'activity' => array(),
|
Chris@76
|
872 'ip' => array(),
|
Chris@76
|
873 'edits' => array(),
|
Chris@76
|
874 ),
|
Chris@76
|
875 );
|
Chris@76
|
876
|
Chris@76
|
877 // Moderation must be on to track edits.
|
Chris@76
|
878 if (empty($modSettings['modlog_enabled']))
|
Chris@76
|
879 unset($context[$context['profile_menu_name']]['tab_data']['edits']);
|
Chris@76
|
880
|
Chris@76
|
881 // Set a page title.
|
Chris@76
|
882 $context['page_title'] = $txt['trackUser'] . ' - ' . $subActions[$context['tracking_area']][1] . ' - ' . $user_profile[$memID]['real_name'];
|
Chris@76
|
883
|
Chris@76
|
884 // Pass on to the actual function.
|
Chris@76
|
885 $context['sub_template'] = $subActions[$context['tracking_area']][0];
|
Chris@76
|
886 $subActions[$context['tracking_area']][0]($memID);
|
Chris@76
|
887 }
|
Chris@76
|
888
|
Chris@76
|
889 function trackActivity($memID)
|
Chris@76
|
890 {
|
Chris@76
|
891 global $scripturl, $txt, $modSettings, $sourcedir;
|
Chris@76
|
892 global $user_profile, $context, $smcFunc;
|
Chris@76
|
893
|
Chris@76
|
894 // Verify if the user has sufficient permissions.
|
Chris@76
|
895 isAllowedTo('moderate_forum');
|
Chris@76
|
896
|
Chris@76
|
897 $context['last_ip'] = $user_profile[$memID]['member_ip'];
|
Chris@76
|
898 if ($context['last_ip'] != $user_profile[$memID]['member_ip2'])
|
Chris@76
|
899 $context['last_ip2'] = $user_profile[$memID]['member_ip2'];
|
Chris@76
|
900 $context['member']['name'] = $user_profile[$memID]['real_name'];
|
Chris@76
|
901
|
Chris@76
|
902 // Set the options for the list component.
|
Chris@76
|
903 $listOptions = array(
|
Chris@76
|
904 'id' => 'track_user_list',
|
Chris@76
|
905 'title' => $txt['errors_by'] . ' ' . $context['member']['name'],
|
Chris@76
|
906 'items_per_page' => $modSettings['defaultMaxMessages'],
|
Chris@76
|
907 'no_items_label' => $txt['no_errors_from_user'],
|
Chris@76
|
908 'base_href' => $scripturl . '?action=profile;area=tracking;sa=user;u=' . $memID,
|
Chris@76
|
909 'default_sort_col' => 'date',
|
Chris@76
|
910 'get_items' => array(
|
Chris@76
|
911 'function' => 'list_getUserErrors',
|
Chris@76
|
912 'params' => array(
|
Chris@76
|
913 'le.id_member = {int:current_member}',
|
Chris@76
|
914 array('current_member' => $memID),
|
Chris@76
|
915 ),
|
Chris@76
|
916 ),
|
Chris@76
|
917 'get_count' => array(
|
Chris@76
|
918 'function' => 'list_getUserErrorCount',
|
Chris@76
|
919 'params' => array(
|
Chris@76
|
920 'id_member = {int:current_member}',
|
Chris@76
|
921 array('current_member' => $memID),
|
Chris@76
|
922 ),
|
Chris@76
|
923 ),
|
Chris@76
|
924 'columns' => array(
|
Chris@76
|
925 'ip_address' => array(
|
Chris@76
|
926 'header' => array(
|
Chris@76
|
927 'value' => $txt['ip_address'],
|
Chris@76
|
928 ),
|
Chris@76
|
929 'data' => array(
|
Chris@76
|
930 'sprintf' => array(
|
Chris@76
|
931 'format' => '<a href="' . $scripturl . '?action=profile;area=tracking;sa=ip;searchip=%1$s;u=' . $memID. '">%1$s</a>',
|
Chris@76
|
932 'params' => array(
|
Chris@76
|
933 'ip' => false,
|
Chris@76
|
934 ),
|
Chris@76
|
935 ),
|
Chris@76
|
936 ),
|
Chris@76
|
937 'sort' => array(
|
Chris@76
|
938 'default' => 'le.ip',
|
Chris@76
|
939 'reverse' => 'le.ip DESC',
|
Chris@76
|
940 ),
|
Chris@76
|
941 ),
|
Chris@76
|
942 'message' => array(
|
Chris@76
|
943 'header' => array(
|
Chris@76
|
944 'value' => $txt['message'],
|
Chris@76
|
945 ),
|
Chris@76
|
946 'data' => array(
|
Chris@76
|
947 'sprintf' => array(
|
Chris@76
|
948 'format' => '%1$s<br /><a href="%2$s">%2$s</a>',
|
Chris@76
|
949 'params' => array(
|
Chris@76
|
950 'message' => false,
|
Chris@76
|
951 'url' => false,
|
Chris@76
|
952 ),
|
Chris@76
|
953 ),
|
Chris@76
|
954 ),
|
Chris@76
|
955 ),
|
Chris@76
|
956 'date' => array(
|
Chris@76
|
957 'header' => array(
|
Chris@76
|
958 'value' => $txt['date'],
|
Chris@76
|
959 ),
|
Chris@76
|
960 'data' => array(
|
Chris@76
|
961 'db' => 'time',
|
Chris@76
|
962 ),
|
Chris@76
|
963 'sort' => array(
|
Chris@76
|
964 'default' => 'le.id_error DESC',
|
Chris@76
|
965 'reverse' => 'le.id_error',
|
Chris@76
|
966 ),
|
Chris@76
|
967 ),
|
Chris@76
|
968 ),
|
Chris@76
|
969 'additional_rows' => array(
|
Chris@76
|
970 array(
|
Chris@76
|
971 'position' => 'after_title',
|
Chris@76
|
972 'value' => $txt['errors_desc'],
|
Chris@76
|
973 'class' => 'smalltext',
|
Chris@76
|
974 'style' => 'padding: 2ex;',
|
Chris@76
|
975 ),
|
Chris@76
|
976 ),
|
Chris@76
|
977 );
|
Chris@76
|
978
|
Chris@76
|
979 // Create the list for viewing.
|
Chris@76
|
980 require_once($sourcedir . '/Subs-List.php');
|
Chris@76
|
981 createList($listOptions);
|
Chris@76
|
982
|
Chris@76
|
983 // If this is a big forum, or a large posting user, let's limit the search.
|
Chris@76
|
984 if ($modSettings['totalMessages'] > 50000 && $user_profile[$memID]['posts'] > 500)
|
Chris@76
|
985 {
|
Chris@76
|
986 $request = $smcFunc['db_query']('', '
|
Chris@76
|
987 SELECT MAX(id_msg)
|
Chris@76
|
988 FROM {db_prefix}messages AS m
|
Chris@76
|
989 WHERE m.id_member = {int:current_member}',
|
Chris@76
|
990 array(
|
Chris@76
|
991 'current_member' => $memID,
|
Chris@76
|
992 )
|
Chris@76
|
993 );
|
Chris@76
|
994 list ($max_msg_member) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
995 $smcFunc['db_free_result']($request);
|
Chris@76
|
996
|
Chris@76
|
997 // There's no point worrying ourselves with messages made yonks ago, just get recent ones!
|
Chris@76
|
998 $min_msg_member = max(0, $max_msg_member - $user_profile[$memID]['posts'] * 3);
|
Chris@76
|
999 }
|
Chris@76
|
1000
|
Chris@76
|
1001 // Default to at least the ones we know about.
|
Chris@76
|
1002 $ips = array(
|
Chris@76
|
1003 $user_profile[$memID]['member_ip'],
|
Chris@76
|
1004 $user_profile[$memID]['member_ip2'],
|
Chris@76
|
1005 );
|
Chris@76
|
1006
|
Chris@76
|
1007 // Get all IP addresses this user has used for his messages.
|
Chris@76
|
1008 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1009 SELECT poster_ip
|
Chris@76
|
1010 FROM {db_prefix}messages
|
Chris@76
|
1011 WHERE id_member = {int:current_member}
|
Chris@76
|
1012 ' . (isset($min_msg_member) ? '
|
Chris@76
|
1013 AND id_msg >= {int:min_msg_member} AND id_msg <= {int:max_msg_member}' : '') . '
|
Chris@76
|
1014 GROUP BY poster_ip',
|
Chris@76
|
1015 array(
|
Chris@76
|
1016 'current_member' => $memID,
|
Chris@76
|
1017 'min_msg_member' => !empty($min_msg_member) ? $min_msg_member : 0,
|
Chris@76
|
1018 'max_msg_member' => !empty($max_msg_member) ? $max_msg_member : 0,
|
Chris@76
|
1019 )
|
Chris@76
|
1020 );
|
Chris@76
|
1021 $context['ips'] = array();
|
Chris@76
|
1022 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1023 {
|
Chris@76
|
1024 $context['ips'][] = '<a href="' . $scripturl . '?action=profile;area=tracking;sa=ip;searchip=' . $row['poster_ip'] . ';u=' . $memID . '">' . $row['poster_ip'] . '</a>';
|
Chris@76
|
1025 $ips[] = $row['poster_ip'];
|
Chris@76
|
1026 }
|
Chris@76
|
1027 $smcFunc['db_free_result']($request);
|
Chris@76
|
1028
|
Chris@76
|
1029 // Now also get the IP addresses from the error messages.
|
Chris@76
|
1030 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1031 SELECT COUNT(*) AS error_count, ip
|
Chris@76
|
1032 FROM {db_prefix}log_errors
|
Chris@76
|
1033 WHERE id_member = {int:current_member}
|
Chris@76
|
1034 GROUP BY ip',
|
Chris@76
|
1035 array(
|
Chris@76
|
1036 'current_member' => $memID,
|
Chris@76
|
1037 )
|
Chris@76
|
1038 );
|
Chris@76
|
1039 $context['error_ips'] = array();
|
Chris@76
|
1040 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1041 {
|
Chris@76
|
1042 $context['error_ips'][] = '<a href="' . $scripturl . '?action=profile;area=tracking;sa=ip;searchip=' . $row['ip'] . ';u=' . $memID . '">' . $row['ip'] . '</a>';
|
Chris@76
|
1043 $ips[] = $row['ip'];
|
Chris@76
|
1044 }
|
Chris@76
|
1045 $smcFunc['db_free_result']($request);
|
Chris@76
|
1046
|
Chris@76
|
1047 // Find other users that might use the same IP.
|
Chris@76
|
1048 $ips = array_unique($ips);
|
Chris@76
|
1049 $context['members_in_range'] = array();
|
Chris@76
|
1050 if (!empty($ips))
|
Chris@76
|
1051 {
|
Chris@76
|
1052 // Get member ID's which are in messages...
|
Chris@76
|
1053 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1054 SELECT mem.id_member
|
Chris@76
|
1055 FROM {db_prefix}messages AS m
|
Chris@76
|
1056 INNER JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
|
Chris@76
|
1057 WHERE m.poster_ip IN ({array_string:ip_list})
|
Chris@76
|
1058 GROUP BY mem.id_member
|
Chris@76
|
1059 HAVING mem.id_member != {int:current_member}',
|
Chris@76
|
1060 array(
|
Chris@76
|
1061 'current_member' => $memID,
|
Chris@76
|
1062 'ip_list' => $ips,
|
Chris@76
|
1063 )
|
Chris@76
|
1064 );
|
Chris@76
|
1065 $message_members = array();
|
Chris@76
|
1066 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1067 $message_members[] = $row['id_member'];
|
Chris@76
|
1068 $smcFunc['db_free_result']($request);
|
Chris@76
|
1069
|
Chris@76
|
1070 // Fetch their names, cause of the GROUP BY doesn't like giving us that normally.
|
Chris@76
|
1071 if (!empty($message_members))
|
Chris@76
|
1072 {
|
Chris@76
|
1073 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1074 SELECT id_member, real_name
|
Chris@76
|
1075 FROM {db_prefix}members
|
Chris@76
|
1076 WHERE id_member IN ({array_int:message_members})',
|
Chris@76
|
1077 array(
|
Chris@76
|
1078 'message_members' => $message_members,
|
Chris@76
|
1079 'ip_list' => $ips,
|
Chris@76
|
1080 )
|
Chris@76
|
1081 );
|
Chris@76
|
1082 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1083 $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
|
Chris@76
|
1084 $smcFunc['db_free_result']($request);
|
Chris@76
|
1085 }
|
Chris@76
|
1086
|
Chris@76
|
1087 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1088 SELECT id_member, real_name
|
Chris@76
|
1089 FROM {db_prefix}members
|
Chris@76
|
1090 WHERE id_member != {int:current_member}
|
Chris@76
|
1091 AND member_ip IN ({array_string:ip_list})',
|
Chris@76
|
1092 array(
|
Chris@76
|
1093 'current_member' => $memID,
|
Chris@76
|
1094 'ip_list' => $ips,
|
Chris@76
|
1095 )
|
Chris@76
|
1096 );
|
Chris@76
|
1097 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1098 $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
|
Chris@76
|
1099 $smcFunc['db_free_result']($request);
|
Chris@76
|
1100 }
|
Chris@76
|
1101 }
|
Chris@76
|
1102
|
Chris@76
|
1103 function list_getUserErrorCount($where, $where_vars = array())
|
Chris@76
|
1104 {
|
Chris@76
|
1105 global $smcFunc;
|
Chris@76
|
1106
|
Chris@76
|
1107 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1108 SELECT COUNT(*) AS error_count
|
Chris@76
|
1109 FROM {db_prefix}log_errors
|
Chris@76
|
1110 WHERE ' . $where,
|
Chris@76
|
1111 $where_vars
|
Chris@76
|
1112 );
|
Chris@76
|
1113 list ($count) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
1114 $smcFunc['db_free_result']($request);
|
Chris@76
|
1115
|
Chris@76
|
1116 return $count;
|
Chris@76
|
1117 }
|
Chris@76
|
1118
|
Chris@76
|
1119 function list_getUserErrors($start, $items_per_page, $sort, $where, $where_vars = array())
|
Chris@76
|
1120 {
|
Chris@76
|
1121 global $smcFunc, $txt, $scripturl;
|
Chris@76
|
1122
|
Chris@76
|
1123 // Get a list of error messages from this ip (range).
|
Chris@76
|
1124 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1125 SELECT
|
Chris@76
|
1126 le.log_time, le.ip, le.url, le.message, IFNULL(mem.id_member, 0) AS id_member,
|
Chris@76
|
1127 IFNULL(mem.real_name, {string:guest_title}) AS display_name, mem.member_name
|
Chris@76
|
1128 FROM {db_prefix}log_errors AS le
|
Chris@76
|
1129 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = le.id_member)
|
Chris@76
|
1130 WHERE ' . $where . '
|
Chris@76
|
1131 ORDER BY ' . $sort . '
|
Chris@76
|
1132 LIMIT ' . $start . ', ' . $items_per_page,
|
Chris@76
|
1133 array_merge($where_vars, array(
|
Chris@76
|
1134 'guest_title' => $txt['guest_title'],
|
Chris@76
|
1135 ))
|
Chris@76
|
1136 );
|
Chris@76
|
1137 $error_messages = array();
|
Chris@76
|
1138 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1139 $error_messages[] = array(
|
Chris@76
|
1140 'ip' => $row['ip'],
|
Chris@76
|
1141 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'],
|
Chris@76
|
1142 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')),
|
Chris@76
|
1143 'url' => $row['url'],
|
Chris@76
|
1144 'time' => timeformat($row['log_time']),
|
Chris@76
|
1145 'timestamp' => forum_time(true, $row['log_time']),
|
Chris@76
|
1146 );
|
Chris@76
|
1147 $smcFunc['db_free_result']($request);
|
Chris@76
|
1148
|
Chris@76
|
1149 return $error_messages;
|
Chris@76
|
1150 }
|
Chris@76
|
1151
|
Chris@76
|
1152 function list_getIPMessageCount($where, $where_vars = array())
|
Chris@76
|
1153 {
|
Chris@76
|
1154 global $smcFunc;
|
Chris@76
|
1155
|
Chris@76
|
1156 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1157 SELECT COUNT(*) AS message_count
|
Chris@76
|
1158 FROM {db_prefix}messages AS m
|
Chris@76
|
1159 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
|
Chris@76
|
1160 WHERE {query_see_board} AND ' . $where,
|
Chris@76
|
1161 $where_vars
|
Chris@76
|
1162 );
|
Chris@76
|
1163 list ($count) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
1164 $smcFunc['db_free_result']($request);
|
Chris@76
|
1165
|
Chris@76
|
1166 return $count;
|
Chris@76
|
1167 }
|
Chris@76
|
1168
|
Chris@76
|
1169 function list_getIPMessages($start, $items_per_page, $sort, $where, $where_vars = array())
|
Chris@76
|
1170 {
|
Chris@76
|
1171 global $smcFunc, $txt, $scripturl;
|
Chris@76
|
1172
|
Chris@76
|
1173 // Get all the messages fitting this where clause.
|
Chris@76
|
1174 // !!!SLOW This query is using a filesort.
|
Chris@76
|
1175 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1176 SELECT
|
Chris@76
|
1177 m.id_msg, m.poster_ip, IFNULL(mem.real_name, m.poster_name) AS display_name, mem.id_member,
|
Chris@76
|
1178 m.subject, m.poster_time, m.id_topic, m.id_board
|
Chris@76
|
1179 FROM {db_prefix}messages AS m
|
Chris@76
|
1180 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
|
Chris@76
|
1181 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
|
Chris@76
|
1182 WHERE {query_see_board} AND ' . $where . '
|
Chris@76
|
1183 ORDER BY ' . $sort . '
|
Chris@76
|
1184 LIMIT ' . $start . ', ' . $items_per_page,
|
Chris@76
|
1185 array_merge($where_vars, array(
|
Chris@76
|
1186 ))
|
Chris@76
|
1187 );
|
Chris@76
|
1188 $messages = array();
|
Chris@76
|
1189 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1190 $messages[] = array(
|
Chris@76
|
1191 'ip' => $row['poster_ip'],
|
Chris@76
|
1192 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>',
|
Chris@76
|
1193 'board' => array(
|
Chris@76
|
1194 'id' => $row['id_board'],
|
Chris@76
|
1195 'href' => $scripturl . '?board=' . $row['id_board']
|
Chris@76
|
1196 ),
|
Chris@76
|
1197 'topic' => $row['id_topic'],
|
Chris@76
|
1198 'id' => $row['id_msg'],
|
Chris@76
|
1199 'subject' => $row['subject'],
|
Chris@76
|
1200 'time' => timeformat($row['poster_time']),
|
Chris@76
|
1201 'timestamp' => forum_time(true, $row['poster_time'])
|
Chris@76
|
1202 );
|
Chris@76
|
1203 $smcFunc['db_free_result']($request);
|
Chris@76
|
1204
|
Chris@76
|
1205 return $messages;
|
Chris@76
|
1206 }
|
Chris@76
|
1207
|
Chris@76
|
1208 function TrackIP($memID = 0)
|
Chris@76
|
1209 {
|
Chris@76
|
1210 global $user_profile, $scripturl, $txt, $user_info, $modSettings, $sourcedir;
|
Chris@76
|
1211 global $context, $smcFunc;
|
Chris@76
|
1212
|
Chris@76
|
1213 // Can the user do this?
|
Chris@76
|
1214 isAllowedTo('moderate_forum');
|
Chris@76
|
1215
|
Chris@76
|
1216 if ($memID == 0)
|
Chris@76
|
1217 {
|
Chris@76
|
1218 $context['ip'] = $user_info['ip'];
|
Chris@76
|
1219 loadTemplate('Profile');
|
Chris@76
|
1220 loadLanguage('Profile');
|
Chris@76
|
1221 $context['sub_template'] = 'trackIP';
|
Chris@76
|
1222 $context['page_title'] = $txt['profile'];
|
Chris@76
|
1223 $context['base_url'] = $scripturl . '?action=trackip';
|
Chris@76
|
1224 }
|
Chris@76
|
1225 else
|
Chris@76
|
1226 {
|
Chris@76
|
1227 $context['ip'] = $user_profile[$memID]['member_ip'];
|
Chris@76
|
1228 $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
|
Chris@76
|
1229 }
|
Chris@76
|
1230
|
Chris@76
|
1231 // Searching?
|
Chris@76
|
1232 if (isset($_REQUEST['searchip']))
|
Chris@76
|
1233 $context['ip'] = trim($_REQUEST['searchip']);
|
Chris@76
|
1234
|
Chris@76
|
1235 if (preg_match('/^\d{1,3}\.(\d{1,3}|\*)\.(\d{1,3}|\*)\.(\d{1,3}|\*)$/', $context['ip']) == 0)
|
Chris@76
|
1236 fatal_lang_error('invalid_tracking_ip', false);
|
Chris@76
|
1237
|
Chris@76
|
1238 $ip_var = str_replace('*', '%', $context['ip']);
|
Chris@76
|
1239 $ip_string = strpos($ip_var, '%') === false ? '= {string:ip_address}' : 'LIKE {string:ip_address}';
|
Chris@76
|
1240
|
Chris@76
|
1241 if (empty($context['tracking_area']))
|
Chris@76
|
1242 $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
|
Chris@76
|
1243
|
Chris@76
|
1244 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1245 SELECT id_member, real_name AS display_name, member_ip
|
Chris@76
|
1246 FROM {db_prefix}members
|
Chris@76
|
1247 WHERE member_ip ' . $ip_string,
|
Chris@76
|
1248 array(
|
Chris@76
|
1249 'ip_address' => $ip_var,
|
Chris@76
|
1250 )
|
Chris@76
|
1251 );
|
Chris@76
|
1252 $context['ips'] = array();
|
Chris@76
|
1253 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1254 $context['ips'][$row['member_ip']][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
|
Chris@76
|
1255 $smcFunc['db_free_result']($request);
|
Chris@76
|
1256
|
Chris@76
|
1257 ksort($context['ips']);
|
Chris@76
|
1258
|
Chris@76
|
1259 // Gonna want this for the list.
|
Chris@76
|
1260 require_once($sourcedir . '/Subs-List.php');
|
Chris@76
|
1261
|
Chris@76
|
1262 // Start with the user messages.
|
Chris@76
|
1263 $listOptions = array(
|
Chris@76
|
1264 'id' => 'track_message_list',
|
Chris@76
|
1265 'title' => $txt['messages_from_ip'] . ' ' . $context['ip'],
|
Chris@76
|
1266 'start_var_name' => 'messageStart',
|
Chris@76
|
1267 'items_per_page' => $modSettings['defaultMaxMessages'],
|
Chris@76
|
1268 'no_items_label' => $txt['no_messages_from_ip'],
|
Chris@76
|
1269 'base_href' => $context['base_url'] . ';searchip=' . $context['ip'],
|
Chris@76
|
1270 'default_sort_col' => 'date',
|
Chris@76
|
1271 'get_items' => array(
|
Chris@76
|
1272 'function' => 'list_getIPMessages',
|
Chris@76
|
1273 'params' => array(
|
Chris@76
|
1274 'm.poster_ip ' . $ip_string,
|
Chris@76
|
1275 array('ip_address' => $ip_var),
|
Chris@76
|
1276 ),
|
Chris@76
|
1277 ),
|
Chris@76
|
1278 'get_count' => array(
|
Chris@76
|
1279 'function' => 'list_getIPMessageCount',
|
Chris@76
|
1280 'params' => array(
|
Chris@76
|
1281 'm.poster_ip ' . $ip_string,
|
Chris@76
|
1282 array('ip_address' => $ip_var),
|
Chris@76
|
1283 ),
|
Chris@76
|
1284 ),
|
Chris@76
|
1285 'columns' => array(
|
Chris@76
|
1286 'ip_address' => array(
|
Chris@76
|
1287 'header' => array(
|
Chris@76
|
1288 'value' => $txt['ip_address'],
|
Chris@76
|
1289 ),
|
Chris@76
|
1290 'data' => array(
|
Chris@76
|
1291 'sprintf' => array(
|
Chris@76
|
1292 'format' => '<a href="' . $context['base_url'] . ';searchip=%1$s">%1$s</a>',
|
Chris@76
|
1293 'params' => array(
|
Chris@76
|
1294 'ip' => false,
|
Chris@76
|
1295 ),
|
Chris@76
|
1296 ),
|
Chris@76
|
1297 ),
|
Chris@76
|
1298 'sort' => array(
|
Chris@76
|
1299 'default' => 'INET_ATON(m.poster_ip)',
|
Chris@76
|
1300 'reverse' => 'INET_ATON(m.poster_ip) DESC',
|
Chris@76
|
1301 ),
|
Chris@76
|
1302 ),
|
Chris@76
|
1303 'poster' => array(
|
Chris@76
|
1304 'header' => array(
|
Chris@76
|
1305 'value' => $txt['poster'],
|
Chris@76
|
1306 ),
|
Chris@76
|
1307 'data' => array(
|
Chris@76
|
1308 'db' => 'member_link',
|
Chris@76
|
1309 ),
|
Chris@76
|
1310 ),
|
Chris@76
|
1311 'subject' => array(
|
Chris@76
|
1312 'header' => array(
|
Chris@76
|
1313 'value' => $txt['subject'],
|
Chris@76
|
1314 ),
|
Chris@76
|
1315 'data' => array(
|
Chris@76
|
1316 'sprintf' => array(
|
Chris@76
|
1317 'format' => '<a href="' . $scripturl . '?topic=%1$s.msg%2$s#msg%2$s" rel="nofollow">%3$s</a>',
|
Chris@76
|
1318 'params' => array(
|
Chris@76
|
1319 'topic' => false,
|
Chris@76
|
1320 'id' => false,
|
Chris@76
|
1321 'subject' => false,
|
Chris@76
|
1322 ),
|
Chris@76
|
1323 ),
|
Chris@76
|
1324 ),
|
Chris@76
|
1325 ),
|
Chris@76
|
1326 'date' => array(
|
Chris@76
|
1327 'header' => array(
|
Chris@76
|
1328 'value' => $txt['date'],
|
Chris@76
|
1329 ),
|
Chris@76
|
1330 'data' => array(
|
Chris@76
|
1331 'db' => 'time',
|
Chris@76
|
1332 ),
|
Chris@76
|
1333 'sort' => array(
|
Chris@76
|
1334 'default' => 'm.id_msg DESC',
|
Chris@76
|
1335 'reverse' => 'm.id_msg',
|
Chris@76
|
1336 ),
|
Chris@76
|
1337 ),
|
Chris@76
|
1338 ),
|
Chris@76
|
1339 'additional_rows' => array(
|
Chris@76
|
1340 array(
|
Chris@76
|
1341 'position' => 'after_title',
|
Chris@76
|
1342 'value' => $txt['messages_from_ip_desc'],
|
Chris@76
|
1343 'class' => 'smalltext',
|
Chris@76
|
1344 'style' => 'padding: 2ex;',
|
Chris@76
|
1345 ),
|
Chris@76
|
1346 ),
|
Chris@76
|
1347 );
|
Chris@76
|
1348
|
Chris@76
|
1349 // Create the messages list.
|
Chris@76
|
1350 createList($listOptions);
|
Chris@76
|
1351
|
Chris@76
|
1352 // Set the options for the error lists.
|
Chris@76
|
1353 $listOptions = array(
|
Chris@76
|
1354 'id' => 'track_user_list',
|
Chris@76
|
1355 'title' => $txt['errors_from_ip'] . ' ' . $context['ip'],
|
Chris@76
|
1356 'start_var_name' => 'errorStart',
|
Chris@76
|
1357 'items_per_page' => $modSettings['defaultMaxMessages'],
|
Chris@76
|
1358 'no_items_label' => $txt['no_errors_from_ip'],
|
Chris@76
|
1359 'base_href' => $context['base_url'] . ';searchip=' . $context['ip'],
|
Chris@76
|
1360 'default_sort_col' => 'date2',
|
Chris@76
|
1361 'get_items' => array(
|
Chris@76
|
1362 'function' => 'list_getUserErrors',
|
Chris@76
|
1363 'params' => array(
|
Chris@76
|
1364 'le.ip ' . $ip_string,
|
Chris@76
|
1365 array('ip_address' => $ip_var),
|
Chris@76
|
1366 ),
|
Chris@76
|
1367 ),
|
Chris@76
|
1368 'get_count' => array(
|
Chris@76
|
1369 'function' => 'list_getUserErrorCount',
|
Chris@76
|
1370 'params' => array(
|
Chris@76
|
1371 'ip ' . $ip_string,
|
Chris@76
|
1372 array('ip_address' => $ip_var),
|
Chris@76
|
1373 ),
|
Chris@76
|
1374 ),
|
Chris@76
|
1375 'columns' => array(
|
Chris@76
|
1376 'ip_address2' => array(
|
Chris@76
|
1377 'header' => array(
|
Chris@76
|
1378 'value' => $txt['ip_address'],
|
Chris@76
|
1379 ),
|
Chris@76
|
1380 'data' => array(
|
Chris@76
|
1381 'sprintf' => array(
|
Chris@76
|
1382 'format' => '<a href="' . $context['base_url'] . ';searchip=%1$s">%1$s</a>',
|
Chris@76
|
1383 'params' => array(
|
Chris@76
|
1384 'ip' => false,
|
Chris@76
|
1385 ),
|
Chris@76
|
1386 ),
|
Chris@76
|
1387 ),
|
Chris@76
|
1388 'sort' => array(
|
Chris@76
|
1389 'default' => 'INET_ATON(le.ip)',
|
Chris@76
|
1390 'reverse' => 'INET_ATON(le.ip) DESC',
|
Chris@76
|
1391 ),
|
Chris@76
|
1392 ),
|
Chris@76
|
1393 'display_name' => array(
|
Chris@76
|
1394 'header' => array(
|
Chris@76
|
1395 'value' => $txt['display_name'],
|
Chris@76
|
1396 ),
|
Chris@76
|
1397 'data' => array(
|
Chris@76
|
1398 'db' => 'member_link',
|
Chris@76
|
1399 ),
|
Chris@76
|
1400 ),
|
Chris@76
|
1401 'message' => array(
|
Chris@76
|
1402 'header' => array(
|
Chris@76
|
1403 'value' => $txt['message'],
|
Chris@76
|
1404 ),
|
Chris@76
|
1405 'data' => array(
|
Chris@76
|
1406 'sprintf' => array(
|
Chris@76
|
1407 'format' => '%1$s<br /><a href="%2$s">%2$s</a>',
|
Chris@76
|
1408 'params' => array(
|
Chris@76
|
1409 'message' => false,
|
Chris@76
|
1410 'url' => false,
|
Chris@76
|
1411 ),
|
Chris@76
|
1412 ),
|
Chris@76
|
1413 ),
|
Chris@76
|
1414 ),
|
Chris@76
|
1415 'date2' => array(
|
Chris@76
|
1416 'header' => array(
|
Chris@76
|
1417 'value' => $txt['date'],
|
Chris@76
|
1418 ),
|
Chris@76
|
1419 'data' => array(
|
Chris@76
|
1420 'db' => 'time',
|
Chris@76
|
1421 ),
|
Chris@76
|
1422 'sort' => array(
|
Chris@76
|
1423 'default' => 'le.id_error DESC',
|
Chris@76
|
1424 'reverse' => 'le.id_error',
|
Chris@76
|
1425 ),
|
Chris@76
|
1426 ),
|
Chris@76
|
1427 ),
|
Chris@76
|
1428 'additional_rows' => array(
|
Chris@76
|
1429 array(
|
Chris@76
|
1430 'position' => 'after_title',
|
Chris@76
|
1431 'value' => $txt['errors_from_ip_desc'],
|
Chris@76
|
1432 'class' => 'smalltext',
|
Chris@76
|
1433 'style' => 'padding: 2ex;',
|
Chris@76
|
1434 ),
|
Chris@76
|
1435 ),
|
Chris@76
|
1436 );
|
Chris@76
|
1437
|
Chris@76
|
1438 // Create the error list.
|
Chris@76
|
1439 createList($listOptions);
|
Chris@76
|
1440
|
Chris@76
|
1441 $context['single_ip'] = strpos($context['ip'], '*') === false;
|
Chris@76
|
1442 if ($context['single_ip'])
|
Chris@76
|
1443 {
|
Chris@76
|
1444 $context['whois_servers'] = array(
|
Chris@76
|
1445 'afrinic' => array(
|
Chris@76
|
1446 'name' => $txt['whois_afrinic'],
|
Chris@76
|
1447 'url' => 'http://www.afrinic.net/cgi-bin/whois?searchtext=' . $context['ip'],
|
Chris@76
|
1448 'range' => array(41, 154, 196),
|
Chris@76
|
1449 ),
|
Chris@76
|
1450 'apnic' => array(
|
Chris@76
|
1451 'name' => $txt['whois_apnic'],
|
Chris@76
|
1452 'url' => 'http://wq.apnic.net/apnic-bin/whois.pl?searchtext=' . $context['ip'],
|
Chris@76
|
1453 'range' => array(58, 59, 60, 61, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
|
Chris@76
|
1454 125, 126, 133, 150, 153, 163, 171, 202, 203, 210, 211, 218, 219, 220, 221, 222),
|
Chris@76
|
1455 ),
|
Chris@76
|
1456 'arin' => array(
|
Chris@76
|
1457 'name' => $txt['whois_arin'],
|
Chris@76
|
1458 'url' => 'http://whois.arin.net/rest/ip/' . $context['ip'],
|
Chris@76
|
1459 'range' => array(7, 24, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 96, 97, 98, 99,
|
Chris@76
|
1460 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 142, 143, 144, 146, 147, 148, 149,
|
Chris@76
|
1461 152, 155, 156, 157, 158, 159, 160, 161, 162, 164, 165, 166, 167, 168, 169, 170, 172, 173, 174,
|
Chris@76
|
1462 192, 198, 199, 204, 205, 206, 207, 208, 209, 216),
|
Chris@76
|
1463 ),
|
Chris@76
|
1464 'lacnic' => array(
|
Chris@76
|
1465 'name' => $txt['whois_lacnic'],
|
Chris@76
|
1466 'url' => 'http://lacnic.net/cgi-bin/lacnic/whois?query=' . $context['ip'],
|
Chris@76
|
1467 'range' => array(186, 187, 189, 190, 191, 200, 201),
|
Chris@76
|
1468 ),
|
Chris@76
|
1469 'ripe' => array(
|
Chris@76
|
1470 'name' => $txt['whois_ripe'],
|
Chris@76
|
1471 'url' => 'http://www.db.ripe.net/whois?searchtext=' . $context['ip'],
|
Chris@76
|
1472 'range' => array(62, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
|
Chris@76
|
1473 141, 145, 151, 188, 193, 194, 195, 212, 213, 217),
|
Chris@76
|
1474 ),
|
Chris@76
|
1475 );
|
Chris@76
|
1476
|
Chris@76
|
1477 foreach ($context['whois_servers'] as $whois)
|
Chris@76
|
1478 {
|
Chris@76
|
1479 // Strip off the "decimal point" and anything following...
|
Chris@76
|
1480 if (in_array((int) $context['ip'], $whois['range']))
|
Chris@76
|
1481 $context['auto_whois_server'] = $whois;
|
Chris@76
|
1482 }
|
Chris@76
|
1483 }
|
Chris@76
|
1484 }
|
Chris@76
|
1485
|
Chris@76
|
1486 function trackEdits($memID)
|
Chris@76
|
1487 {
|
Chris@76
|
1488 global $scripturl, $txt, $modSettings, $sourcedir, $context, $smcFunc;
|
Chris@76
|
1489
|
Chris@76
|
1490 require_once($sourcedir . '/Subs-List.php');
|
Chris@76
|
1491
|
Chris@76
|
1492 // Get the names of any custom fields.
|
Chris@76
|
1493 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1494 SELECT col_name, field_name, bbc
|
Chris@76
|
1495 FROM {db_prefix}custom_fields',
|
Chris@76
|
1496 array(
|
Chris@76
|
1497 )
|
Chris@76
|
1498 );
|
Chris@76
|
1499 $context['custom_field_titles'] = array();
|
Chris@76
|
1500 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1501 $context['custom_field_titles']['customfield_' . $row['col_name']] = array(
|
Chris@76
|
1502 'title' => $row['field_name'],
|
Chris@76
|
1503 'parse_bbc' => $row['bbc'],
|
Chris@76
|
1504 );
|
Chris@76
|
1505 $smcFunc['db_free_result']($request);
|
Chris@76
|
1506
|
Chris@76
|
1507 // Set the options for the error lists.
|
Chris@76
|
1508 $listOptions = array(
|
Chris@76
|
1509 'id' => 'edit_list',
|
Chris@76
|
1510 'title' => $txt['trackEdits'],
|
Chris@76
|
1511 'items_per_page' => $modSettings['defaultMaxMessages'],
|
Chris@76
|
1512 'no_items_label' => $txt['trackEdit_no_edits'],
|
Chris@76
|
1513 'base_href' => $scripturl . '?action=profile;area=tracking;sa=edits;u=' . $memID,
|
Chris@76
|
1514 'default_sort_col' => 'time',
|
Chris@76
|
1515 'get_items' => array(
|
Chris@76
|
1516 'function' => 'list_getProfileEdits',
|
Chris@76
|
1517 'params' => array(
|
Chris@76
|
1518 $memID,
|
Chris@76
|
1519 ),
|
Chris@76
|
1520 ),
|
Chris@76
|
1521 'get_count' => array(
|
Chris@76
|
1522 'function' => 'list_getProfileEditCount',
|
Chris@76
|
1523 'params' => array(
|
Chris@76
|
1524 $memID,
|
Chris@76
|
1525 ),
|
Chris@76
|
1526 ),
|
Chris@76
|
1527 'columns' => array(
|
Chris@76
|
1528 'action' => array(
|
Chris@76
|
1529 'header' => array(
|
Chris@76
|
1530 'value' => $txt['trackEdit_action'],
|
Chris@76
|
1531 ),
|
Chris@76
|
1532 'data' => array(
|
Chris@76
|
1533 'db' => 'action_text',
|
Chris@76
|
1534 ),
|
Chris@76
|
1535 ),
|
Chris@76
|
1536 'before' => array(
|
Chris@76
|
1537 'header' => array(
|
Chris@76
|
1538 'value' => $txt['trackEdit_before'],
|
Chris@76
|
1539 ),
|
Chris@76
|
1540 'data' => array(
|
Chris@76
|
1541 'db' => 'before',
|
Chris@76
|
1542 ),
|
Chris@76
|
1543 ),
|
Chris@76
|
1544 'after' => array(
|
Chris@76
|
1545 'header' => array(
|
Chris@76
|
1546 'value' => $txt['trackEdit_after'],
|
Chris@76
|
1547 ),
|
Chris@76
|
1548 'data' => array(
|
Chris@76
|
1549 'db' => 'after',
|
Chris@76
|
1550 ),
|
Chris@76
|
1551 ),
|
Chris@76
|
1552 'time' => array(
|
Chris@76
|
1553 'header' => array(
|
Chris@76
|
1554 'value' => $txt['date'],
|
Chris@76
|
1555 ),
|
Chris@76
|
1556 'data' => array(
|
Chris@76
|
1557 'db' => 'time',
|
Chris@76
|
1558 ),
|
Chris@76
|
1559 'sort' => array(
|
Chris@76
|
1560 'default' => 'id_action DESC',
|
Chris@76
|
1561 'reverse' => 'id_action',
|
Chris@76
|
1562 ),
|
Chris@76
|
1563 ),
|
Chris@76
|
1564 'applicator' => array(
|
Chris@76
|
1565 'header' => array(
|
Chris@76
|
1566 'value' => $txt['trackEdit_applicator'],
|
Chris@76
|
1567 ),
|
Chris@76
|
1568 'data' => array(
|
Chris@76
|
1569 'db' => 'member_link',
|
Chris@76
|
1570 ),
|
Chris@76
|
1571 ),
|
Chris@76
|
1572 ),
|
Chris@76
|
1573 );
|
Chris@76
|
1574
|
Chris@76
|
1575 // Create the error list.
|
Chris@76
|
1576 createList($listOptions);
|
Chris@76
|
1577
|
Chris@76
|
1578 $context['sub_template'] = 'show_list';
|
Chris@76
|
1579 $context['default_list'] = 'edit_list';
|
Chris@76
|
1580 }
|
Chris@76
|
1581
|
Chris@76
|
1582 // How many edits?
|
Chris@76
|
1583 function list_getProfileEditCount($memID)
|
Chris@76
|
1584 {
|
Chris@76
|
1585 global $smcFunc;
|
Chris@76
|
1586
|
Chris@76
|
1587 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1588 SELECT COUNT(*) AS edit_count
|
Chris@76
|
1589 FROM {db_prefix}log_actions
|
Chris@76
|
1590 WHERE id_log = {int:log_type}
|
Chris@76
|
1591 AND id_member = {int:owner}',
|
Chris@76
|
1592 array(
|
Chris@76
|
1593 'log_type' => 2,
|
Chris@76
|
1594 'owner' => $memID,
|
Chris@76
|
1595 )
|
Chris@76
|
1596 );
|
Chris@76
|
1597 list ($edit_count) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
1598 $smcFunc['db_free_result']($request);
|
Chris@76
|
1599
|
Chris@76
|
1600 return $edit_count;
|
Chris@76
|
1601 }
|
Chris@76
|
1602
|
Chris@76
|
1603 function list_getProfileEdits($start, $items_per_page, $sort, $memID)
|
Chris@76
|
1604 {
|
Chris@76
|
1605 global $smcFunc, $txt, $scripturl, $context;
|
Chris@76
|
1606
|
Chris@76
|
1607 // Get a list of error messages from this ip (range).
|
Chris@76
|
1608 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1609 SELECT
|
Chris@76
|
1610 id_action, id_member, ip, log_time, action, extra
|
Chris@76
|
1611 FROM {db_prefix}log_actions
|
Chris@76
|
1612 WHERE id_log = {int:log_type}
|
Chris@76
|
1613 AND id_member = {int:owner}
|
Chris@76
|
1614 ORDER BY ' . $sort . '
|
Chris@76
|
1615 LIMIT ' . $start . ', ' . $items_per_page,
|
Chris@76
|
1616 array(
|
Chris@76
|
1617 'log_type' => 2,
|
Chris@76
|
1618 'owner' => $memID,
|
Chris@76
|
1619 )
|
Chris@76
|
1620 );
|
Chris@76
|
1621 $edits = array();
|
Chris@76
|
1622 $members = array();
|
Chris@76
|
1623 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1624 {
|
Chris@76
|
1625 $extra = @unserialize($row['extra']);
|
Chris@76
|
1626 if (!empty($extra['applicator']))
|
Chris@76
|
1627 $members[] = $extra['applicator'];
|
Chris@76
|
1628
|
Chris@76
|
1629 // Work out what the name of the action is.
|
Chris@76
|
1630 if (isset($txt['trackEdit_action_' . $row['action']]))
|
Chris@76
|
1631 $action_text = $txt['trackEdit_action_' . $row['action']];
|
Chris@76
|
1632 elseif (isset($txt[$row['action']]))
|
Chris@76
|
1633 $action_text = $txt[$row['action']];
|
Chris@76
|
1634 // Custom field?
|
Chris@76
|
1635 elseif (isset($context['custom_field_titles'][$row['action']]))
|
Chris@76
|
1636 $action_text = $context['custom_field_titles'][$row['action']]['title'];
|
Chris@76
|
1637 else
|
Chris@76
|
1638 $action_text = $row['action'];
|
Chris@76
|
1639
|
Chris@76
|
1640 // Parse BBC?
|
Chris@76
|
1641 $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false;
|
Chris@76
|
1642
|
Chris@76
|
1643 $edits[] = array(
|
Chris@76
|
1644 'id' => $row['id_action'],
|
Chris@76
|
1645 'ip' => $row['ip'],
|
Chris@76
|
1646 'id_member' => !empty($extra['applicator']) ? $extra['applicator'] : 0,
|
Chris@76
|
1647 'member_link' => $txt['trackEdit_deleted_member'],
|
Chris@76
|
1648 'action' => $row['action'],
|
Chris@76
|
1649 'action_text' => $action_text,
|
Chris@76
|
1650 'before' => !empty($extra['previous']) ? ($parse_bbc ? parse_bbc($extra['previous']) : $extra['previous']) : '',
|
Chris@76
|
1651 'after' => !empty($extra['new']) ? ($parse_bbc ? parse_bbc($extra['new']) : $extra['new']) : '',
|
Chris@76
|
1652 'time' => timeformat($row['log_time']),
|
Chris@76
|
1653 );
|
Chris@76
|
1654 }
|
Chris@76
|
1655 $smcFunc['db_free_result']($request);
|
Chris@76
|
1656
|
Chris@76
|
1657 // Get any member names.
|
Chris@76
|
1658 if (!empty($members))
|
Chris@76
|
1659 {
|
Chris@76
|
1660 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1661 SELECT
|
Chris@76
|
1662 id_member, real_name
|
Chris@76
|
1663 FROM {db_prefix}members
|
Chris@76
|
1664 WHERE id_member IN ({array_int:members})',
|
Chris@76
|
1665 array(
|
Chris@76
|
1666 'members' => $members,
|
Chris@76
|
1667 )
|
Chris@76
|
1668 );
|
Chris@76
|
1669 $members = array();
|
Chris@76
|
1670 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1671 $members[$row['id_member']] = $row['real_name'];
|
Chris@76
|
1672 $smcFunc['db_free_result']($request);
|
Chris@76
|
1673
|
Chris@76
|
1674 foreach ($edits as $key => $value)
|
Chris@76
|
1675 if (isset($members[$value['id_member']]))
|
Chris@76
|
1676 $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>';
|
Chris@76
|
1677 }
|
Chris@76
|
1678
|
Chris@76
|
1679 return $edits;
|
Chris@76
|
1680 }
|
Chris@76
|
1681
|
Chris@76
|
1682 function showPermissions($memID)
|
Chris@76
|
1683 {
|
Chris@76
|
1684 global $scripturl, $txt, $board, $modSettings;
|
Chris@76
|
1685 global $user_profile, $context, $user_info, $sourcedir, $smcFunc;
|
Chris@76
|
1686
|
Chris@76
|
1687 // Verify if the user has sufficient permissions.
|
Chris@76
|
1688 isAllowedTo('manage_permissions');
|
Chris@76
|
1689
|
Chris@76
|
1690 loadLanguage('ManagePermissions');
|
Chris@76
|
1691 loadLanguage('Admin');
|
Chris@76
|
1692 loadTemplate('ManageMembers');
|
Chris@76
|
1693
|
Chris@76
|
1694 // Load all the permission profiles.
|
Chris@76
|
1695 require_once($sourcedir . '/ManagePermissions.php');
|
Chris@76
|
1696 loadPermissionProfiles();
|
Chris@76
|
1697
|
Chris@76
|
1698 $context['member']['id'] = $memID;
|
Chris@76
|
1699 $context['member']['name'] = $user_profile[$memID]['real_name'];
|
Chris@76
|
1700
|
Chris@76
|
1701 $context['page_title'] = $txt['showPermissions'];
|
Chris@76
|
1702 $board = empty($board) ? 0 : (int) $board;
|
Chris@76
|
1703 $context['board'] = $board;
|
Chris@76
|
1704
|
Chris@76
|
1705 // Determine which groups this user is in.
|
Chris@76
|
1706 if (empty($user_profile[$memID]['additional_groups']))
|
Chris@76
|
1707 $curGroups = array();
|
Chris@76
|
1708 else
|
Chris@76
|
1709 $curGroups = explode(',', $user_profile[$memID]['additional_groups']);
|
Chris@76
|
1710 $curGroups[] = $user_profile[$memID]['id_group'];
|
Chris@76
|
1711 $curGroups[] = $user_profile[$memID]['id_post_group'];
|
Chris@76
|
1712
|
Chris@76
|
1713 // Load a list of boards for the jump box - except the defaults.
|
Chris@76
|
1714 $request = $smcFunc['db_query']('order_by_board_order', '
|
Chris@76
|
1715 SELECT b.id_board, b.name, b.id_profile, b.member_groups, IFNULL(mods.id_member, 0) AS is_mod
|
Chris@76
|
1716 FROM {db_prefix}boards AS b
|
Chris@76
|
1717 LEFT JOIN {db_prefix}moderators AS mods ON (mods.id_board = b.id_board AND mods.id_member = {int:current_member})
|
Chris@76
|
1718 WHERE {query_see_board}',
|
Chris@76
|
1719 array(
|
Chris@76
|
1720 'current_member' => $memID,
|
Chris@76
|
1721 )
|
Chris@76
|
1722 );
|
Chris@76
|
1723 $context['boards'] = array();
|
Chris@76
|
1724 $context['no_access_boards'] = array();
|
Chris@76
|
1725 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1726 {
|
Chris@76
|
1727 if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod'])
|
Chris@76
|
1728 $context['no_access_boards'][] = array(
|
Chris@76
|
1729 'id' => $row['id_board'],
|
Chris@76
|
1730 'name' => $row['name'],
|
Chris@76
|
1731 'is_last' => false,
|
Chris@76
|
1732 );
|
Chris@76
|
1733 elseif ($row['id_profile'] != 1 || $row['is_mod'])
|
Chris@76
|
1734 $context['boards'][$row['id_board']] = array(
|
Chris@76
|
1735 'id' => $row['id_board'],
|
Chris@76
|
1736 'name' => $row['name'],
|
Chris@76
|
1737 'selected' => $board == $row['id_board'],
|
Chris@76
|
1738 'profile' => $row['id_profile'],
|
Chris@76
|
1739 'profile_name' => $context['profiles'][$row['id_profile']]['name'],
|
Chris@76
|
1740 );
|
Chris@76
|
1741 }
|
Chris@76
|
1742 $smcFunc['db_free_result']($request);
|
Chris@76
|
1743
|
Chris@76
|
1744 if (!empty($context['no_access_boards']))
|
Chris@76
|
1745 $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
|
Chris@76
|
1746
|
Chris@76
|
1747 $context['member']['permissions'] = array(
|
Chris@76
|
1748 'general' => array(),
|
Chris@76
|
1749 'board' => array()
|
Chris@76
|
1750 );
|
Chris@76
|
1751
|
Chris@76
|
1752 // If you're an admin we know you can do everything, we might as well leave.
|
Chris@76
|
1753 $context['member']['has_all_permissions'] = in_array(1, $curGroups);
|
Chris@76
|
1754 if ($context['member']['has_all_permissions'])
|
Chris@76
|
1755 return;
|
Chris@76
|
1756
|
Chris@76
|
1757 $denied = array();
|
Chris@76
|
1758
|
Chris@76
|
1759 // Get all general permissions.
|
Chris@76
|
1760 $result = $smcFunc['db_query']('', '
|
Chris@76
|
1761 SELECT p.permission, p.add_deny, mg.group_name, p.id_group
|
Chris@76
|
1762 FROM {db_prefix}permissions AS p
|
Chris@76
|
1763 LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = p.id_group)
|
Chris@76
|
1764 WHERE p.id_group IN ({array_int:group_list})
|
Chris@76
|
1765 ORDER BY p.add_deny DESC, p.permission, mg.min_posts, CASE WHEN mg.id_group < {int:newbie_group} THEN mg.id_group ELSE 4 END, mg.group_name',
|
Chris@76
|
1766 array(
|
Chris@76
|
1767 'group_list' => $curGroups,
|
Chris@76
|
1768 'newbie_group' => 4,
|
Chris@76
|
1769 )
|
Chris@76
|
1770 );
|
Chris@76
|
1771 while ($row = $smcFunc['db_fetch_assoc']($result))
|
Chris@76
|
1772 {
|
Chris@76
|
1773 // We don't know about this permission, it doesn't exist :P.
|
Chris@76
|
1774 if (!isset($txt['permissionname_' . $row['permission']]))
|
Chris@76
|
1775 continue;
|
Chris@76
|
1776
|
Chris@76
|
1777 if (empty($row['add_deny']))
|
Chris@76
|
1778 $denied[] = $row['permission'];
|
Chris@76
|
1779
|
Chris@76
|
1780 // Permissions that end with _own or _any consist of two parts.
|
Chris@76
|
1781 if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
|
Chris@76
|
1782 $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
|
Chris@76
|
1783 else
|
Chris@76
|
1784 $name = $txt['permissionname_' . $row['permission']];
|
Chris@76
|
1785
|
Chris@76
|
1786 // Add this permission if it doesn't exist yet.
|
Chris@76
|
1787 if (!isset($context['member']['permissions']['general'][$row['permission']]))
|
Chris@76
|
1788 $context['member']['permissions']['general'][$row['permission']] = array(
|
Chris@76
|
1789 'id' => $row['permission'],
|
Chris@76
|
1790 'groups' => array(
|
Chris@76
|
1791 'allowed' => array(),
|
Chris@76
|
1792 'denied' => array()
|
Chris@76
|
1793 ),
|
Chris@76
|
1794 'name' => $name,
|
Chris@76
|
1795 'is_denied' => false,
|
Chris@76
|
1796 'is_global' => true,
|
Chris@76
|
1797 );
|
Chris@76
|
1798
|
Chris@76
|
1799 // Add the membergroup to either the denied or the allowed groups.
|
Chris@76
|
1800 $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
|
Chris@76
|
1801
|
Chris@76
|
1802 // Once denied is always denied.
|
Chris@76
|
1803 $context['member']['permissions']['general'][$row['permission']]['is_denied'] |= empty($row['add_deny']);
|
Chris@76
|
1804 }
|
Chris@76
|
1805 $smcFunc['db_free_result']($result);
|
Chris@76
|
1806
|
Chris@76
|
1807 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1808 SELECT
|
Chris@76
|
1809 bp.add_deny, bp.permission, bp.id_group, mg.group_name' . (empty($board) ? '' : ',
|
Chris@76
|
1810 b.id_profile, CASE WHEN mods.id_member IS NULL THEN 0 ELSE 1 END AS is_moderator') . '
|
Chris@76
|
1811 FROM {db_prefix}board_permissions AS bp' . (empty($board) ? '' : '
|
Chris@76
|
1812 INNER JOIN {db_prefix}boards AS b ON (b.id_board = {int:current_board})
|
Chris@76
|
1813 LEFT JOIN {db_prefix}moderators AS mods ON (mods.id_board = b.id_board AND mods.id_member = {int:current_member})') . '
|
Chris@76
|
1814 LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = bp.id_group)
|
Chris@76
|
1815 WHERE bp.id_profile = {raw:current_profile}
|
Chris@76
|
1816 AND bp.id_group IN ({array_int:group_list}' . (empty($board) ? ')' : ', {int:moderator_group})
|
Chris@76
|
1817 AND (mods.id_member IS NOT NULL OR bp.id_group != {int:moderator_group})'),
|
Chris@76
|
1818 array(
|
Chris@76
|
1819 'current_board' => $board,
|
Chris@76
|
1820 'group_list' => $curGroups,
|
Chris@76
|
1821 'current_member' => $memID,
|
Chris@76
|
1822 'current_profile' => empty($board) ? '1' : 'b.id_profile',
|
Chris@76
|
1823 'moderator_group' => 3,
|
Chris@76
|
1824 )
|
Chris@76
|
1825 );
|
Chris@76
|
1826
|
Chris@76
|
1827 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
1828 {
|
Chris@76
|
1829 // We don't know about this permission, it doesn't exist :P.
|
Chris@76
|
1830 if (!isset($txt['permissionname_' . $row['permission']]))
|
Chris@76
|
1831 continue;
|
Chris@76
|
1832
|
Chris@76
|
1833 // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'.
|
Chris@76
|
1834 if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
|
Chris@76
|
1835 $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
|
Chris@76
|
1836 else
|
Chris@76
|
1837 $name = $txt['permissionname_' . $row['permission']];
|
Chris@76
|
1838
|
Chris@76
|
1839 // Create the structure for this permission.
|
Chris@76
|
1840 if (!isset($context['member']['permissions']['board'][$row['permission']]))
|
Chris@76
|
1841 $context['member']['permissions']['board'][$row['permission']] = array(
|
Chris@76
|
1842 'id' => $row['permission'],
|
Chris@76
|
1843 'groups' => array(
|
Chris@76
|
1844 'allowed' => array(),
|
Chris@76
|
1845 'denied' => array()
|
Chris@76
|
1846 ),
|
Chris@76
|
1847 'name' => $name,
|
Chris@76
|
1848 'is_denied' => false,
|
Chris@76
|
1849 'is_global' => empty($board),
|
Chris@76
|
1850 );
|
Chris@76
|
1851
|
Chris@76
|
1852 $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
|
Chris@76
|
1853
|
Chris@76
|
1854 $context['member']['permissions']['board'][$row['permission']]['is_denied'] |= empty($row['add_deny']);
|
Chris@76
|
1855 }
|
Chris@76
|
1856 $smcFunc['db_free_result']($request);
|
Chris@76
|
1857 }
|
Chris@76
|
1858
|
Chris@76
|
1859 // View a members warnings?
|
Chris@76
|
1860 function viewWarning($memID)
|
Chris@76
|
1861 {
|
Chris@76
|
1862 global $modSettings, $context, $sourcedir, $txt, $scripturl;
|
Chris@76
|
1863
|
Chris@76
|
1864 // Firstly, can we actually even be here?
|
Chris@76
|
1865 if (!allowedTo('issue_warning') && (empty($modSettings['warning_show']) || ($modSettings['warning_show'] == 1 && !$context['user']['is_owner'])))
|
Chris@76
|
1866 fatal_lang_error('no_access', false);
|
Chris@76
|
1867
|
Chris@76
|
1868 // Make sure things which are disabled stay disabled.
|
Chris@76
|
1869 $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110;
|
Chris@76
|
1870 $modSettings['warning_moderate'] = !empty($modSettings['warning_moderate']) && !empty($modSettings['postmod_active']) ? $modSettings['warning_moderate'] : 110;
|
Chris@76
|
1871 $modSettings['warning_mute'] = !empty($modSettings['warning_mute']) ? $modSettings['warning_mute'] : 110;
|
Chris@76
|
1872
|
Chris@76
|
1873 // Let's use a generic list to get all the current warnings, and use the issue warnings grab-a-granny thing.
|
Chris@76
|
1874 require_once($sourcedir . '/Subs-List.php');
|
Chris@76
|
1875 require_once($sourcedir . '/Profile-Actions.php');
|
Chris@76
|
1876
|
Chris@76
|
1877 $listOptions = array(
|
Chris@76
|
1878 'id' => 'view_warnings',
|
Chris@76
|
1879 'title' => $txt['profile_viewwarning_previous_warnings'],
|
Chris@76
|
1880 'items_per_page' => $modSettings['defaultMaxMessages'],
|
Chris@76
|
1881 'no_items_label' => $txt['profile_viewwarning_no_warnings'],
|
Chris@76
|
1882 'base_href' => $scripturl . '?action=profile;area=viewwarning;sa=user;u=' . $memID,
|
Chris@76
|
1883 'default_sort_col' => 'log_time',
|
Chris@76
|
1884 'get_items' => array(
|
Chris@76
|
1885 'function' => 'list_getUserWarnings',
|
Chris@76
|
1886 'params' => array(
|
Chris@76
|
1887 $memID,
|
Chris@76
|
1888 ),
|
Chris@76
|
1889 ),
|
Chris@76
|
1890 'get_count' => array(
|
Chris@76
|
1891 'function' => 'list_getUserWarningCount',
|
Chris@76
|
1892 'params' => array(
|
Chris@76
|
1893 $memID,
|
Chris@76
|
1894 ),
|
Chris@76
|
1895 ),
|
Chris@76
|
1896 'columns' => array(
|
Chris@76
|
1897 'log_time' => array(
|
Chris@76
|
1898 'header' => array(
|
Chris@76
|
1899 'value' => $txt['profile_warning_previous_time'],
|
Chris@76
|
1900 ),
|
Chris@76
|
1901 'data' => array(
|
Chris@76
|
1902 'db' => 'time',
|
Chris@76
|
1903 ),
|
Chris@76
|
1904 'sort' => array(
|
Chris@76
|
1905 'default' => 'lc.log_time DESC',
|
Chris@76
|
1906 'reverse' => 'lc.log_time',
|
Chris@76
|
1907 ),
|
Chris@76
|
1908 ),
|
Chris@76
|
1909 'reason' => array(
|
Chris@76
|
1910 'header' => array(
|
Chris@76
|
1911 'value' => $txt['profile_warning_previous_reason'],
|
Chris@76
|
1912 'style' => 'width: 50%',
|
Chris@76
|
1913 ),
|
Chris@76
|
1914 'data' => array(
|
Chris@76
|
1915 'db' => 'reason',
|
Chris@76
|
1916 ),
|
Chris@76
|
1917 ),
|
Chris@76
|
1918 'level' => array(
|
Chris@76
|
1919 'header' => array(
|
Chris@76
|
1920 'value' => $txt['profile_warning_previous_level'],
|
Chris@76
|
1921 ),
|
Chris@76
|
1922 'data' => array(
|
Chris@76
|
1923 'db' => 'counter',
|
Chris@76
|
1924 ),
|
Chris@76
|
1925 'sort' => array(
|
Chris@76
|
1926 'default' => 'lc.counter DESC',
|
Chris@76
|
1927 'reverse' => 'lc.counter',
|
Chris@76
|
1928 ),
|
Chris@76
|
1929 ),
|
Chris@76
|
1930 ),
|
Chris@76
|
1931 'additional_rows' => array(
|
Chris@76
|
1932 array(
|
Chris@76
|
1933 'position' => 'after_title',
|
Chris@76
|
1934 'value' => $txt['profile_viewwarning_desc'],
|
Chris@76
|
1935 'class' => 'smalltext',
|
Chris@76
|
1936 'style' => 'padding: 2ex;',
|
Chris@76
|
1937 ),
|
Chris@76
|
1938 ),
|
Chris@76
|
1939 );
|
Chris@76
|
1940
|
Chris@76
|
1941 // Create the list for viewing.
|
Chris@76
|
1942 require_once($sourcedir . '/Subs-List.php');
|
Chris@76
|
1943 createList($listOptions);
|
Chris@76
|
1944
|
Chris@76
|
1945 // Create some common text bits for the template.
|
Chris@76
|
1946 $context['level_effects'] = array(
|
Chris@76
|
1947 0 => '',
|
Chris@76
|
1948 $modSettings['warning_watch'] => $txt['profile_warning_effect_own_watched'],
|
Chris@76
|
1949 $modSettings['warning_moderate'] => $txt['profile_warning_effect_own_moderated'],
|
Chris@76
|
1950 $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'],
|
Chris@76
|
1951 );
|
Chris@76
|
1952 $context['current_level'] = 0;
|
Chris@76
|
1953 foreach ($context['level_effects'] as $limit => $dummy)
|
Chris@76
|
1954 if ($context['member']['warning'] >= $limit)
|
Chris@76
|
1955 $context['current_level'] = $limit;
|
Chris@76
|
1956 }
|
Chris@76
|
1957
|
Chris@76
|
1958 ?> |