|
@@ -14,8 +14,9 @@ discard block |
|
|
block discarded – undo |
|
14
|
14
|
* @version 2.1 Beta 4 |
|
15
|
15
|
*/ |
|
16
|
16
|
|
|
17
|
|
-if (!defined('SMF')) |
|
|
17
|
+if (!defined('SMF')) { |
|
18
|
18
|
die('No direct access...'); |
|
|
19
|
+} |
|
19
|
20
|
|
|
20
|
21
|
/** |
|
21
|
22
|
* Prepares the information from the moderation log for viewing. |
|
@@ -32,14 +33,16 @@ discard block |
|
|
block discarded – undo |
|
32
|
33
|
|
|
33
|
34
|
// Are we looking at the moderation log or the administration log. |
|
34
|
35
|
$context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
|
35
|
|
- if ($context['log_type'] == 3) |
|
36
|
|
- isAllowedTo('admin_forum'); |
|
|
36
|
+ if ($context['log_type'] == 3) { |
|
|
37
|
+ isAllowedTo('admin_forum'); |
|
|
38
|
+ } |
|
37
|
39
|
|
|
38
|
40
|
// These change dependant on whether we are viewing the moderation or admin log. |
|
39
|
|
- if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40
|
|
- $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41
|
|
- else |
|
42
|
|
- $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
|
41
|
+ if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
|
42
|
+ $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
|
43
|
+ } else { |
|
|
44
|
+ $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
|
45
|
+ } |
|
43
|
46
|
|
|
44
|
47
|
$context['can_delete'] = allowedTo('admin_forum'); |
|
45
|
48
|
|
|
@@ -67,8 +70,7 @@ discard block |
|
|
block discarded – undo |
|
67
|
70
|
$log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
|
68
|
71
|
logAction('clearlog_' . $log_type, array(), $log_type); |
|
69
|
72
|
|
|
70
|
|
- } |
|
71
|
|
- elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
|
73
|
+ } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72
|
74
|
{ |
|
73
|
75
|
checkSession(); |
|
74
|
76
|
validateToken('mod-ml'); |
|
@@ -114,15 +116,17 @@ discard block |
|
|
block discarded – undo |
|
114
|
116
|
'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
|
115
|
117
|
); |
|
116
|
118
|
|
|
117
|
|
- if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118
|
|
- $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119
|
|
- else |
|
120
|
|
- $search_params_string = $search_params['string']; |
|
|
119
|
+ if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
|
120
|
+ $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
|
121
|
+ } else { |
|
|
122
|
+ $search_params_string = $search_params['string']; |
|
|
123
|
+ } |
|
121
|
124
|
|
|
122
|
|
- if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123
|
|
- $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124
|
|
- else |
|
125
|
|
- $search_params_type = $search_params['type']; |
|
|
125
|
+ if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
|
126
|
+ $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
|
127
|
+ } else { |
|
|
128
|
+ $search_params_type = $search_params['type']; |
|
|
129
|
+ } |
|
126
|
130
|
|
|
127
|
131
|
$search_params_column = $searchTypes[$search_params_type]['sql']; |
|
128
|
132
|
$search_params = array( |
|
@@ -301,15 +305,16 @@ discard block |
|
|
block discarded – undo |
|
301
|
305
|
$context['default_list'] = 'moderation_log_list'; |
|
302
|
306
|
|
|
303
|
307
|
// If a hook has changed this, respect it. |
|
304
|
|
- if (!empty($moderation_menu_name)) |
|
305
|
|
- $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
306
|
|
- elseif (isset($context['moderation_menu_name'])) |
|
307
|
|
- $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
|
308
|
+ if (!empty($moderation_menu_name)) { |
|
|
309
|
+ $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
|
310
|
+ } elseif (isset($context['moderation_menu_name'])) { |
|
|
311
|
+ $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308
|
312
|
'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
|
309
|
313
|
'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
|
310
|
314
|
'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
|
311
|
315
|
); |
|
312
|
|
-} |
|
|
316
|
+ } |
|
|
317
|
+ } |
|
313
|
318
|
|
|
314
|
319
|
/** |
|
315
|
320
|
* Get the number of mod log entries. |
|
@@ -413,30 +418,35 @@ discard block |
|
|
block discarded – undo |
|
413
|
418
|
// Add on some of the column stuff info |
|
414
|
419
|
if (!empty($row['id_board'])) |
|
415
|
420
|
{ |
|
416
|
|
- if ($row['action'] == 'move') |
|
417
|
|
- $row['extra']['board_to'] = $row['id_board']; |
|
418
|
|
- else |
|
419
|
|
- $row['extra']['board'] = $row['id_board']; |
|
|
421
|
+ if ($row['action'] == 'move') { |
|
|
422
|
+ $row['extra']['board_to'] = $row['id_board']; |
|
|
423
|
+ } else { |
|
|
424
|
+ $row['extra']['board'] = $row['id_board']; |
|
|
425
|
+ } |
|
420
|
426
|
} |
|
421
|
427
|
|
|
422
|
|
- if (!empty($row['id_topic'])) |
|
423
|
|
- $row['extra']['topic'] = $row['id_topic']; |
|
424
|
|
- if (!empty($row['id_msg'])) |
|
425
|
|
- $row['extra']['message'] = $row['id_msg']; |
|
|
428
|
+ if (!empty($row['id_topic'])) { |
|
|
429
|
+ $row['extra']['topic'] = $row['id_topic']; |
|
|
430
|
+ } |
|
|
431
|
+ if (!empty($row['id_msg'])) { |
|
|
432
|
+ $row['extra']['message'] = $row['id_msg']; |
|
|
433
|
+ } |
|
426
|
434
|
|
|
427
|
435
|
// Is this associated with a topic? |
|
428
|
|
- if (isset($row['extra']['topic'])) |
|
429
|
|
- $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
430
|
|
- if (isset($row['extra']['new_topic'])) |
|
431
|
|
- $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
|
436
|
+ if (isset($row['extra']['topic'])) { |
|
|
437
|
+ $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
|
438
|
+ } |
|
|
439
|
+ if (isset($row['extra']['new_topic'])) { |
|
|
440
|
+ $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
|
441
|
+ } |
|
432
|
442
|
|
|
433
|
443
|
// How about a member? |
|
434
|
444
|
if (isset($row['extra']['member'])) |
|
435
|
445
|
{ |
|
436
|
446
|
// Guests don't have names! |
|
437
|
|
- if (empty($row['extra']['member'])) |
|
438
|
|
- $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
439
|
|
- else |
|
|
447
|
+ if (empty($row['extra']['member'])) { |
|
|
448
|
+ $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
|
449
|
+ } else |
|
440
|
450
|
{ |
|
441
|
451
|
// Try to find it... |
|
442
|
452
|
$members[(int) $row['extra']['member']][] = $row['id_action']; |
|
@@ -444,35 +454,42 @@ discard block |
|
|
block discarded – undo |
|
444
|
454
|
} |
|
445
|
455
|
|
|
446
|
456
|
// Associated with a board? |
|
447
|
|
- if (isset($row['extra']['board_to'])) |
|
448
|
|
- $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
449
|
|
- if (isset($row['extra']['board_from'])) |
|
450
|
|
- $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
451
|
|
- if (isset($row['extra']['board'])) |
|
452
|
|
- $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
|
457
|
+ if (isset($row['extra']['board_to'])) { |
|
|
458
|
+ $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
|
459
|
+ } |
|
|
460
|
+ if (isset($row['extra']['board_from'])) { |
|
|
461
|
+ $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
|
462
|
+ } |
|
|
463
|
+ if (isset($row['extra']['board'])) { |
|
|
464
|
+ $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
|
465
|
+ } |
|
453
|
466
|
|
|
454
|
467
|
// A message? |
|
455
|
|
- if (isset($row['extra']['message'])) |
|
456
|
|
- $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
|
468
|
+ if (isset($row['extra']['message'])) { |
|
|
469
|
+ $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
|
470
|
+ } |
|
457
|
471
|
|
|
458
|
472
|
// IP Info? |
|
459
|
|
- if (isset($row['extra']['ip_range'])) |
|
460
|
|
- if ($seeIP) |
|
|
473
|
+ if (isset($row['extra']['ip_range'])) { |
|
|
474
|
+ if ($seeIP) |
|
461
|
475
|
$row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
|
462
|
|
- else |
|
463
|
|
- $row['extra']['ip_range'] = $txt['logged']; |
|
|
476
|
+ } else { |
|
|
477
|
+ $row['extra']['ip_range'] = $txt['logged']; |
|
|
478
|
+ } |
|
464
|
479
|
|
|
465
|
480
|
// Email? |
|
466
|
|
- if (isset($row['extra']['email'])) |
|
467
|
|
- $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
|
481
|
+ if (isset($row['extra']['email'])) { |
|
|
482
|
+ $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
|
483
|
+ } |
|
468
|
484
|
|
|
469
|
485
|
// Bans are complex. |
|
470
|
486
|
if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
|
471
|
487
|
{ |
|
472
|
488
|
$row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
|
473
|
|
- foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
474
|
|
- if (isset($row['extra'][$type])) |
|
|
489
|
+ foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
|
490
|
+ if (isset($row['extra'][$type])) |
|
475
|
491
|
$row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
|
|
492
|
+ } |
|
476
|
493
|
} |
|
477
|
494
|
|
|
478
|
495
|
// The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
|
@@ -508,12 +525,13 @@ discard block |
|
|
block discarded – undo |
|
508
|
525
|
foreach ($boards[$row['id_board']] as $action) |
|
509
|
526
|
{ |
|
510
|
527
|
// Make the board number into a link - dealing with moving too. |
|
511
|
|
- if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
512
|
|
- $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
513
|
|
- elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
514
|
|
- $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
515
|
|
- elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
516
|
|
- $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
|
528
|
+ if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
|
529
|
+ $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
|
530
|
+ } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
|
531
|
+ $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
|
532
|
+ } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
|
533
|
+ $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
|
534
|
+ } |
|
517
|
535
|
} |
|
518
|
536
|
} |
|
519
|
537
|
$smcFunc['db_free_result']($request); |
|
@@ -547,10 +565,11 @@ discard block |
|
|
block discarded – undo |
|
547
|
565
|
); |
|
548
|
566
|
|
|
549
|
567
|
// Make the topic number into a link - dealing with splitting too. |
|
550
|
|
- if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
551
|
|
- $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
552
|
|
- elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
553
|
|
- $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
|
568
|
+ if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
|
569
|
+ $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
|
570
|
+ } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
|
571
|
+ $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
|
572
|
+ } |
|
554
|
573
|
} |
|
555
|
574
|
} |
|
556
|
575
|
$smcFunc['db_free_result']($request); |
|
@@ -583,8 +602,9 @@ discard block |
|
|
block discarded – undo |
|
583
|
602
|
); |
|
584
|
603
|
|
|
585
|
604
|
// Make the message number into a link. |
|
586
|
|
- if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
587
|
|
- $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
|
605
|
+ if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
|
606
|
+ $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
|
607
|
+ } |
|
588
|
608
|
} |
|
589
|
609
|
} |
|
590
|
610
|
$smcFunc['db_free_result']($request); |
|
@@ -624,25 +644,29 @@ discard block |
|
|
block discarded – undo |
|
624
|
644
|
foreach ($entries as $k => $entry) |
|
625
|
645
|
{ |
|
626
|
646
|
// Make any message info links so its easier to go find that message. |
|
627
|
|
- if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
628
|
|
- $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
|
647
|
+ if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
|
648
|
+ $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
|
649
|
+ } |
|
629
|
650
|
|
|
630
|
651
|
// Mark up any deleted members, topics and boards. |
|
631
|
|
- foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
632
|
|
- if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
|
652
|
+ foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
|
653
|
+ if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
633
|
654
|
$entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
|
|
655
|
+ } |
|
634
|
656
|
|
|
635
|
657
|
if (isset($entry['extra']['report'])) |
|
636
|
658
|
{ |
|
637
|
659
|
// Member profile reports go in a different area |
|
638
|
|
- if (stristr($entry['action'], 'user_report')) |
|
639
|
|
- $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
640
|
|
- else |
|
641
|
|
- $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
|
660
|
+ if (stristr($entry['action'], 'user_report')) { |
|
|
661
|
+ $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
|
662
|
+ } else { |
|
|
663
|
+ $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
|
664
|
+ } |
|
642
|
665
|
} |
|
643
|
666
|
|
|
644
|
|
- if (empty($entries[$k]['action_text'])) |
|
645
|
|
- $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
|
667
|
+ if (empty($entries[$k]['action_text'])) { |
|
|
668
|
+ $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
|
669
|
+ } |
|
646
|
670
|
$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
|
647
|
671
|
function ($matches) use ($entries, $k) |
|
648
|
672
|
{ |