aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGraham Eames <grahamje@users.sourceforge.net>2006-01-14 22:57:19 +0000
committerGraham Eames <grahamje@users.sourceforge.net>2006-01-14 22:57:19 +0000
commitc3edbfa6f063adc28b332f2d9df75136e65f33f1 (patch)
treeed22c801135a11b8c28445d3996819723c4b6cff
parent49b29c03ce8d00b207e91456be91a255a9730594 (diff)
downloadforums-c3edbfa6f063adc28b332f2d9df75136e65f33f1.tar
forums-c3edbfa6f063adc28b332f2d9df75136e65f33f1.tar.gz
forums-c3edbfa6f063adc28b332f2d9df75136e65f33f1.tar.bz2
forums-c3edbfa6f063adc28b332f2d9df75136e65f33f1.tar.xz
forums-c3edbfa6f063adc28b332f2d9df75136e65f33f1.zip
Initial implementation of a log viewer into the MCP
git-svn-id: file:///svn/phpbb/trunk@5460 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/includes/functions_admin.php2
-rwxr-xr-xphpBB/includes/mcp/mcp_logs.php184
-rw-r--r--phpBB/language/en/common.php2
-rw-r--r--phpBB/language/en/mcp.php6
-rw-r--r--phpBB/mcp.php18
-rwxr-xr-xphpBB/styles/subSilver/template/mcp_logs.html52
-rw-r--r--phpBB/viewtopic.php2
7 files changed, 264 insertions, 2 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index b207141b52..e38255d7d5 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -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&amp;f=" . $is_auth[$row['topic_id']] . '&amp;t=' . $row['topic_id'] : '';
- $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "mcp.$phpEx$SID&amp;mode=topic_view&amp;action=viewlogs&amp;t=" . $row['topic_id'] : '';
+ $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "mcp.$phpEx$SID&amp;mode=logs&amp;action=topic_logs&amp;t=" . $row['topic_id'] : '';
}
}
diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php
new file mode 100755
index 0000000000..21fafa5df2
--- /dev/null
+++ b/phpBB/includes/mcp/mcp_logs.php
@@ -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 . "&amp;$u_sort_param", $log_count, $config['topics_per_page'], $start, true),
+
+ 'U_POST_ACTION' => "mcp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;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
+//
+
+?> \ No newline at end of file
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index b82cdb86a7..c2df001935 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -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',
diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php
index d5dfc78a93..850dee2c23 100644
--- a/phpBB/language/en/mcp.php
+++ b/phpBB/language/en/mcp.php
@@ -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',
diff --git a/phpBB/mcp.php b/phpBB/mcp.php
index 04b4da545d..2eda2ad922 100644
--- a/phpBB/mcp.php
+++ b/phpBB/mcp.php
@@ -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;
diff --git a/phpBB/styles/subSilver/template/mcp_logs.html b/phpBB/styles/subSilver/template/mcp_logs.html
new file mode 100755
index 0000000000..3ebaaa12c7
--- /dev/null
+++ b/phpBB/styles/subSilver/template/mcp_logs.html
@@ -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}&nbsp;<span class="gensmall">{L_SORT_BY}</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR}&nbsp;<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}" />&nbsp; <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>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --><!-- ENDIF --></span></td>
+ </tr>
+ </table>
+ </table>
+
+ </form>
+
+ <br clear="all" /><br />
+
+<!-- INCLUDE mcp_footer.html --> \ No newline at end of file
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 2a4bba6f52..62d8ef9a94 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -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&amp;f=$forum_id&amp;t=$topic_id&amp;$u_sort_param" . (($highlight_match) ? "&amp;hilit=$highlight" : ''), $total_posts, $config['posts_per_page'], $start);