mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 22:08:54 +00:00
Initial implementation of a log viewer into the MCP
git-svn-id: file:///svn/phpbb/trunk@5460 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
49b29c03ce
commit
c3edbfa6f0
7 changed files with 264 additions and 2 deletions
|
@ -2008,7 +2008,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
|
|||
foreach ($log as $key => $row)
|
||||
{
|
||||
$log[$key]['viewtopic'] = (isset($is_auth[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "viewtopic.$phpEx$SID&f=" . $is_auth[$row['topic_id']] . '&t=' . $row['topic_id'] : '';
|
||||
$log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "mcp.$phpEx$SID&mode=topic_view&action=viewlogs&t=" . $row['topic_id'] : '';
|
||||
$log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "mcp.$phpEx$SID&mode=logs&action=topic_logs&t=" . $row['topic_id'] : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
184
phpBB/includes/mcp/mcp_logs.php
Executable file
184
phpBB/includes/mcp/mcp_logs.php
Executable file
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package mcp
|
||||
* @version $Id$
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package mcp
|
||||
* mcp_logs
|
||||
* Handling warning the users
|
||||
*/
|
||||
class mcp_logs
|
||||
{
|
||||
|
||||
var $p_master;
|
||||
|
||||
function mcp_main(&$p_master)
|
||||
{
|
||||
$this->p_master = &$p_master;
|
||||
}
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $auth, $db, $user, $template;
|
||||
global $config, $phpbb_root_path, $phpEx, $SID;
|
||||
|
||||
$action = request_var('action', array('' => ''));
|
||||
|
||||
if (is_array($action))
|
||||
{
|
||||
list($action, ) = each($action);
|
||||
}
|
||||
|
||||
// Set up general vars
|
||||
$action = request_var('action', '');
|
||||
$start = request_var('start', 0);
|
||||
$deletemark = (isset($_POST['del_marked'])) ? true : false;
|
||||
$deleteall = (isset($_POST['del_all'])) ? true : false;
|
||||
$marked = request_var('mark', array(0));
|
||||
|
||||
// Sort keys
|
||||
$sort_days = request_var('st', 0);
|
||||
$sort_key = request_var('sk', 't');
|
||||
$sort_dir = request_var('sd', 'd');
|
||||
|
||||
$this->tpl_name = 'mcp_logs';
|
||||
|
||||
$forum_id = $topic_id = 0;
|
||||
switch ($mode)
|
||||
{
|
||||
case 'front':
|
||||
$where_sql = '';
|
||||
break;
|
||||
case 'forum_view':
|
||||
$forum_id = request_var('f', 0);
|
||||
$where_sql = " AND forum_id = $forum_id";
|
||||
break;
|
||||
case 'topic_view':
|
||||
$topic_id = request_vat('t', 0);
|
||||
$where_sql = " AND topic_id = $topic_id";
|
||||
break;
|
||||
}
|
||||
|
||||
// Delete entries if requested and able
|
||||
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
|
||||
{
|
||||
if ($deletemark && $marked)
|
||||
{
|
||||
$sql_in = array();
|
||||
foreach ($marked as $mark)
|
||||
{
|
||||
$sql_in[] = $mark;
|
||||
}
|
||||
$where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')';
|
||||
unset($sql_in);
|
||||
}
|
||||
|
||||
if ($where_sql || $deleteall)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . LOG_TABLE . '
|
||||
WHERE log_type = ' . LOD_MOD . "
|
||||
$where_sql";
|
||||
$db->sql_query($sql);
|
||||
|
||||
add_log('admin', 'LOG_CLEAR_MOD');
|
||||
}
|
||||
}
|
||||
|
||||
// Sorting
|
||||
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
|
||||
$sort_by_sql = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
|
||||
|
||||
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
||||
|
||||
// Define where and sort sql for use in displaying logs
|
||||
$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
|
||||
$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
||||
|
||||
// Grab log data
|
||||
$log_data = array();
|
||||
$log_count = 0;
|
||||
|
||||
view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, $topic_id, 0, $sql_where, $sql_sort);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start),
|
||||
'TOTAL_LOGS' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count),
|
||||
'PAGINATION' => generate_pagination($u_action . "&$u_sort_param", $log_count, $config['topics_per_page'], $start, true),
|
||||
|
||||
'U_POST_ACTION' => "mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id",
|
||||
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||
'S_SELECT_SORT_DAYS'=> $s_limit_days,
|
||||
'S_LOGS' => ($log_count > 0),
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($log_data as $row)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$checks = array('viewtopic', 'viewforum');
|
||||
foreach ($checks as $check)
|
||||
{
|
||||
if (isset($row[$check]) && $row[$check])
|
||||
{
|
||||
$data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_block_vars('log', array(
|
||||
'USERNAME' => $row['username'],
|
||||
'IP' => $row['ip'],
|
||||
'DATE' => $user->format_date($row['time']),
|
||||
'ACTION' => $row['action'],
|
||||
'DATA' => (sizeof($data)) ? implode(' | ', $data) : '',
|
||||
'ID' => $row['id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @package module_install
|
||||
*/
|
||||
class mcp_logs_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_logs',
|
||||
'title' => 'MCP_LOGS',
|
||||
'version' => '1.0.0',
|
||||
'modes' => array(
|
||||
'front' => array('title' => 'MCP_LOGS_FRONT', 'auth' => ''),
|
||||
'forum_logs' => array('title' => 'MCP_LOGS_FORUM_VIEW', 'auth' => 'acl_m_,$id'),
|
||||
'topic_logs' => array('title' => 'MCP_LOGS_TOPIC_VIEW', 'auth' => 'acl_m_,$id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Functions
|
||||
//
|
||||
|
||||
?>
|
|
@ -405,6 +405,8 @@ $lang = array_merge($lang, array(
|
|||
'TOPIC_TITLE' => 'Topic Title',
|
||||
'TOPIC_UNAPPROVED' => 'This topic has not been approved',
|
||||
'TOTAL_ATTACHMENTS' => 'Attachment(s)',
|
||||
'TOTAL_LOG' => '1 log',
|
||||
'TOTAL_LOGS' => '%d logs',
|
||||
'TOTAL_NO_PM' => '0 private messages in total',
|
||||
'TOTAL_PM' => '1 private messages in total',
|
||||
'TOTAL_PMS' => '$d private messages in total',
|
||||
|
|
|
@ -119,6 +119,12 @@ $lang = array_merge($lang, array(
|
|||
'LOOKUP_IP' => 'Look up IP',
|
||||
|
||||
'MCP_ADD' => 'Add a warning',
|
||||
|
||||
'MCP_LOGS' => 'Moderator Logs',
|
||||
'MCP_LOGS_FRONT' => 'Front Page',
|
||||
'MCP_LOGS_FORUM_VIEW' => 'Forum Logs',
|
||||
'MCP_LOGS_TOPIC_VIEW' => 'Topic Logs',
|
||||
|
||||
'MCP_MAIN' => 'Main',
|
||||
'MCP_MAIN_FORUM_VIEW' => 'View Forum',
|
||||
'MCP_MAIN_FRONT' => 'Front Page',
|
||||
|
|
|
@ -78,6 +78,12 @@ if ($action == 'merge_select')
|
|||
$mode = 'forum_view';
|
||||
}
|
||||
|
||||
if ($mode == 'topic_logs')
|
||||
{
|
||||
$id = 'logs';
|
||||
$quickmod = false;
|
||||
}
|
||||
|
||||
// Topic view modes
|
||||
if (in_array($mode, array('split', 'split_all', 'split_beyond', 'merge', 'merge_posts')))
|
||||
{
|
||||
|
@ -163,10 +169,12 @@ if (!$quickmod)
|
|||
if (!$topic_id)
|
||||
{
|
||||
$module->set_display('topic_view', false);
|
||||
$module->set_display('topic_logs', false);
|
||||
}
|
||||
if (!$forum_id)
|
||||
{
|
||||
$module->set_display('forum_view', false);
|
||||
$module->set_display('forum_logs', false);
|
||||
}
|
||||
if (!$user_id && $username == '')
|
||||
{
|
||||
|
@ -235,6 +243,16 @@ function _module_main_post_details_url()
|
|||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_logs_forum_view_url()
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_logs_topic_view_url()
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function extra_url()
|
||||
{
|
||||
global $forum_id, $topic_id, $post_id;
|
||||
|
|
52
phpBB/styles/subSilver/template/mcp_logs.html
Executable file
52
phpBB/styles/subSilver/template/mcp_logs.html
Executable file
|
@ -0,0 +1,52 @@
|
|||
<!-- INCLUDE mcp_header.html -->
|
||||
|
||||
<!-- $Id$ -->
|
||||
|
||||
<form method="post" name="mcp" action="{U_POST_ACTION}">
|
||||
|
||||
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="tablebg">
|
||||
<tr>
|
||||
<th>{L_USERNAME}</th>
|
||||
<th>{L_IP}</th>
|
||||
<th>{L_TIME}</th>
|
||||
<th>{L_ACTION}</th>
|
||||
<!-- IF S_CLEAR_ALLOWED --><th>{L_MARK}</th><!-- ENDIF -->
|
||||
</tr>
|
||||
<!-- IF S_LOGS -->
|
||||
<!-- BEGIN log -->
|
||||
<!-- IF log.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
|
||||
<td class="genmed">{log.USERNAME}</td>
|
||||
<td class="genmed" style="text-align: center;">{log.IP}</td>
|
||||
<td class="genmed" style="text-align: center;">{log.DATE}</td>
|
||||
<td class="genmed">{log.ACTION}<br />{log.DATA}</td>
|
||||
<!-- IF S_CLEAR_ALLOWED --><td width="5%" align="center"><input type="checkbox" name="mark[]" value="{log.ID}" /></td><!-- ENDIF -->
|
||||
</tr>
|
||||
<!-- END log -->
|
||||
<tr align="center">
|
||||
<td class="row3" colspan="<!-- IF S_CLEAR_ALLOWED -->5<!-- ELSE -->4<!-- ENDIF -->"><span class="gensmall">{L_DISPLAY_LOG}:</span> {S_SELECT_SORT_DAYS} <span class="gensmall">{L_SORT_BY}</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" value="{L_GO}" name="sort" /></td>
|
||||
</tr>
|
||||
<!-- IF S_CLEAR_ALLOWED -->
|
||||
<tr>
|
||||
<td class="cat" colspan="5" align="center"><input class="btnlite" type="submit" name="action[del_marked]" value="{L_DELETE_MARKED}" /> <input class="btnlite" type="submit" name="action[del_all]" value="{L_DELETE_ALL}" /></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- ELSE -->
|
||||
<tr>
|
||||
<td class="row1" colspan="<!-- IF S_CLEAR_ALLOWED -->5<!-- ELSE -->4<!-- ENDIF -->" align="center"><span class="gen">{L_NO_ENTRIES}</span></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
</table>
|
||||
|
||||
<table width="100%" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td class="pagination">{S_ON_PAGE} [ {TOTAL_LOGS} ]</td>
|
||||
<td align="right"><span class="pagination"><!-- IF PAGINATION --><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a> <!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE --> <a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --><!-- ENDIF --></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<br clear="all" /><br />
|
||||
|
||||
<!-- INCLUDE mcp_footer.html -->
|
|
@ -431,7 +431,7 @@ $topic_mod .= ($auth->acl_get('m_', $forum_id) && $topic_data['topic_type'] != P
|
|||
$topic_mod .= ($auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : '';
|
||||
$topic_mod .= ($auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '<option value="make_announce">' . $user->lang['MAKE_ANNOUNCE'] . '</option>' : '';
|
||||
$topic_mod .= ($auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '<option value="make_global">' . $user->lang['MAKE_GLOBAL'] . '</option>' : '';
|
||||
$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="viewlogs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
|
||||
$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
|
||||
|
||||
// If we've got a hightlight set pass it on to pagination.
|
||||
$pagination = generate_pagination("{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&$u_sort_param" . (($highlight_match) ? "&hilit=$highlight" : ''), $total_posts, $config['posts_per_page'], $start);
|
||||
|
|
Loading…
Add table
Reference in a new issue