2004-07-08 23:03:03 +00:00
|
|
|
<?php
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package mcp
|
|
|
|
* @version $Id$
|
|
|
|
* @copyright (c) 2005 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
|
*
|
|
|
|
*/
|
2004-07-08 23:03:03 +00:00
|
|
|
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
* Handling actions in post details screen
|
|
|
|
*/
|
2006-02-05 01:40:45 +00:00
|
|
|
function mcp_post_details($id, $mode, $action)
|
2004-07-08 23:03:03 +00:00
|
|
|
{
|
|
|
|
global $SID, $phpEx, $phpbb_root_path, $config;
|
|
|
|
global $template, $db, $user, $auth;
|
|
|
|
|
|
|
|
$user->add_lang('posting');
|
|
|
|
|
|
|
|
$post_id = request_var('p', 0);
|
|
|
|
$start = request_var('start', 0);
|
|
|
|
|
|
|
|
// Get post data
|
|
|
|
$post_info = get_post_data(array($post_id));
|
|
|
|
|
|
|
|
if (!sizeof($post_info))
|
|
|
|
{
|
|
|
|
trigger_error($user->lang['POST_NOT_EXIST']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$post_info = $post_info[$post_id];
|
2006-02-05 01:40:45 +00:00
|
|
|
$url = "{$phpbb_root_path}mcp.$phpEx$SID" . extra_url();
|
2004-07-08 23:03:03 +00:00
|
|
|
|
|
|
|
switch ($action)
|
|
|
|
{
|
2006-02-05 01:40:45 +00:00
|
|
|
case 'chgposter':
|
|
|
|
|
2004-07-08 23:03:03 +00:00
|
|
|
$username = request_var('username', '');
|
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
$sql = 'SELECT user_id
|
|
|
|
FROM ' . USERS_TABLE . '
|
|
|
|
WHERE username = \'' . $db->sql_escape($username) . '\'';
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
if (!($row = $db->sql_fetchrow($result)))
|
2004-07-08 23:03:03 +00:00
|
|
|
{
|
2006-02-05 01:40:45 +00:00
|
|
|
trigger_error($user->lang['NO_USER']);
|
2004-07-08 23:03:03 +00:00
|
|
|
}
|
2006-02-05 01:40:45 +00:00
|
|
|
$new_user = $row['user_id'];
|
2004-07-08 23:03:03 +00:00
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
if ($auth->acl_get('m_', $post_info['forum_id']))
|
2004-07-08 23:03:03 +00:00
|
|
|
{
|
2006-02-05 01:40:45 +00:00
|
|
|
change_poster($post_info, $new_user);
|
2004-07-08 23:03:03 +00:00
|
|
|
}
|
2006-02-05 01:40:45 +00:00
|
|
|
break;
|
2004-07-08 23:03:03 +00:00
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
case 'chgposter_ip':
|
2004-07-09 12:31:33 +00:00
|
|
|
|
|
|
|
$new_user = request_var('u', 0);
|
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
$sql = 'SELECT user_id
|
|
|
|
FROM ' . USERS_TABLE . '
|
|
|
|
WHERE user_id = ' . $new_user;
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
if (!($row = $db->sql_fetchrow($result)))
|
2004-08-22 13:16:00 +00:00
|
|
|
{
|
2006-02-05 01:40:45 +00:00
|
|
|
trigger_error($user->lang['NO_USER']);
|
2004-08-22 13:16:00 +00:00
|
|
|
}
|
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
if ($auth->acl_get('m_', $post_info['forum_id']))
|
2004-08-22 13:16:00 +00:00
|
|
|
{
|
2006-02-05 01:40:45 +00:00
|
|
|
change_poster($post_info, $new_user);
|
2004-08-22 13:16:00 +00:00
|
|
|
}
|
2006-02-05 01:40:45 +00:00
|
|
|
break;
|
2004-07-08 23:03:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set some vars
|
|
|
|
$users_ary = array();
|
2006-02-05 01:40:45 +00:00
|
|
|
$post_id = $post_info['post_id'];
|
2004-07-08 23:03:03 +00:00
|
|
|
$poster = ($post_info['user_colour']) ? '<span style="color:#' . $post_info['user_colour'] . '">' . $post_info['username'] . '</span>' : $post_info['username'];
|
|
|
|
|
|
|
|
// Process message, leave it uncensored
|
|
|
|
$message = $post_info['post_text'];
|
|
|
|
if ($post_info['bbcode_bitfield'])
|
|
|
|
{
|
|
|
|
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
|
|
|
$bbcode = new bbcode($post_info['bbcode_bitfield']);
|
|
|
|
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
|
|
|
|
}
|
2005-03-21 23:10:11 +00:00
|
|
|
$message = smiley_text($message);
|
2004-07-08 23:03:03 +00:00
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2004-08-22 13:16:00 +00:00
|
|
|
'U_MCP_ACTION' => "$url&i=main&quickmod=1", // Use this for mode paramaters
|
|
|
|
'U_POST_ACTION' => "$url&i=$id&mode=post_details", // Use this for action parameters
|
|
|
|
'U_APPROVE_ACTION' => "{$phpbb_root_path}mcp.$phpEx$SID&i=queue&p=$post_id",
|
2004-07-08 23:03:03 +00:00
|
|
|
|
2006-02-22 21:42:26 +00:00
|
|
|
'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
|
2004-07-08 23:03:03 +00:00
|
|
|
'S_CAN_CHGPOSTER' => $auth->acl_get('m_', $post_info['forum_id']),
|
|
|
|
'S_CAN_LOCK_POST' => $auth->acl_get('m_lock', $post_info['forum_id']),
|
|
|
|
'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']),
|
|
|
|
|
|
|
|
'S_POST_REPORTED' => $post_info['post_reported'],
|
|
|
|
'S_POST_UNAPPROVED' => !$post_info['post_approved'],
|
|
|
|
'S_POST_LOCKED' => $post_info['post_edit_locked'],
|
2006-02-05 01:40:45 +00:00
|
|
|
'S_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? true : false,
|
2004-08-22 13:16:00 +00:00
|
|
|
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
2004-07-08 23:03:03 +00:00
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
'U_FIND_MEMBER' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=searchuser&form=mcp_chgposter&field=username",
|
|
|
|
'U_VIEW_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $post_info['user_id'],
|
2006-02-25 12:46:31 +00:00
|
|
|
'U_MCP_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? "{$phpbb_root_path}mcp.$phpEx$SID&i=notes&mode=user_notes&u=" . $post_info['user_id'] : '',
|
2006-02-05 01:40:45 +00:00
|
|
|
'U_MCP_WARN_USER' => "{$phpbb_root_path}mcp.$phpEx$SID&i=warn&mode=warn_user&u=" . $post_info['user_id'],
|
2004-07-19 20:13:18 +00:00
|
|
|
'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? "{$phpbb_root_path}posting.$phpEx$SID&mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}" : '',
|
2004-07-08 23:03:03 +00:00
|
|
|
|
2006-02-25 12:46:31 +00:00
|
|
|
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "<a href=\"{$phpbb_root_path}viewtopic.$phpEx$SID&p=$post_id#p$post_id\">", '</a>'),
|
2006-02-05 01:40:45 +00:00
|
|
|
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "<a href=\"{$phpbb_root_path}viewforum.$phpEx$SID&f={$post_info['forum_id']}&start={$start}\">", '</a>'),
|
2004-07-08 23:03:03 +00:00
|
|
|
'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']),
|
|
|
|
'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']),
|
2004-07-19 20:13:18 +00:00
|
|
|
'EDIT_IMG' => $user->img('btn_edit', $user->lang['EDIT_POST']),
|
2004-07-08 23:03:03 +00:00
|
|
|
|
|
|
|
'POSTER_NAME' => $poster,
|
|
|
|
'POST_PREVIEW' => $message,
|
|
|
|
'POST_SUBJECT' => $post_info['post_subject'],
|
|
|
|
'POST_DATE' => $user->format_date($post_info['post_time']),
|
|
|
|
'POST_IP' => $post_info['poster_ip'],
|
2004-07-19 20:13:18 +00:00
|
|
|
'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']),
|
|
|
|
'POST_ID' => $post_info['post_id'])
|
2004-07-08 23:03:03 +00:00
|
|
|
);
|
|
|
|
|
2004-08-22 13:16:00 +00:00
|
|
|
// Get User Notes
|
|
|
|
$log_data = array();
|
|
|
|
$log_count = 0;
|
|
|
|
view_log('user', $log_data, $log_count, $config['posts_per_page'], 0, 0, 0, $post_info['user_id']);
|
|
|
|
|
|
|
|
if ($log_count)
|
|
|
|
{
|
|
|
|
$template->assign_var('S_USER_NOTES', true);
|
|
|
|
|
|
|
|
foreach ($log_data as $row)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('usernotes', array(
|
|
|
|
'REPORT_BY' => $row['username'],
|
|
|
|
'REPORT_AT' => $user->format_date($row['time']),
|
|
|
|
'ACTION' => $row['action'],
|
|
|
|
'ID' => $row['id'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-10 22:47:43 +00:00
|
|
|
// Get Reports
|
|
|
|
if ($auth->acl_get('m_', $post_info['forum_id']))
|
|
|
|
{
|
2006-02-05 01:40:45 +00:00
|
|
|
$sql = 'SELECT r.*, re.*, u.user_id, u.username
|
2004-07-10 22:47:43 +00:00
|
|
|
FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u, ' . REASONS_TABLE . " re
|
|
|
|
WHERE r.post_id = $post_id
|
|
|
|
AND r.reason_id = re.reason_id
|
|
|
|
AND u.user_id = r.user_id
|
|
|
|
ORDER BY r.report_time DESC";
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
if ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
$template->assign_var('S_SHOW_REPORTS', true);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2006-03-12 23:19:55 +00:00
|
|
|
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
|
|
|
|
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
|
|
|
|
{
|
|
|
|
$row['reson_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])];
|
|
|
|
$row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])];
|
|
|
|
}
|
|
|
|
|
2004-07-10 22:47:43 +00:00
|
|
|
$template->assign_block_vars('reports', array(
|
|
|
|
'REPORT_ID' => $row['report_id'],
|
2006-03-12 23:19:55 +00:00
|
|
|
'REASON_TITLE' => $row['reason_title'],
|
|
|
|
'REASON_DESC' => $row['reason_description'],
|
2004-07-10 22:47:43 +00:00
|
|
|
'REPORTER' => ($row['user_id'] != ANONYMOUS) ? $row['username'] : $user->lang['GUEST'],
|
2006-02-05 01:40:45 +00:00
|
|
|
'U_REPORTER' => ($row['user_id'] != ANONYMOUS) ? "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u={$row['user_id']}" : '',
|
2004-07-10 22:47:43 +00:00
|
|
|
'USER_NOTIFY' => ($row['user_notify']) ? true : false,
|
|
|
|
'REPORT_TIME' => $user->format_date($row['report_time']),
|
|
|
|
'REPORT_TEXT' => str_replace("\n", '<br />', trim($row['report_text'])))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
while ($row = $db->sql_fetchrow($result));
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
}
|
2006-02-05 01:40:45 +00:00
|
|
|
|
2004-07-08 23:03:03 +00:00
|
|
|
// Get IP
|
2006-02-22 21:42:26 +00:00
|
|
|
if ($auth->acl_get('m_info', $post_info['forum_id']))
|
2004-07-08 23:03:03 +00:00
|
|
|
{
|
|
|
|
$rdns_ip_num = request_var('rdns', '');
|
|
|
|
|
|
|
|
if ($rdns_ip_num != 'all')
|
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'U_LOOKUP_ALL' => "$url&i=main&mode=post_details&rdns=all")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get other users who've posted under this IP
|
|
|
|
$sql = 'SELECT u.user_id, u.username, COUNT(*) as postings
|
|
|
|
FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . " p
|
|
|
|
WHERE p.poster_id = u.user_id
|
|
|
|
AND p.poster_ip = '{$post_info['poster_ip']}'
|
|
|
|
AND p.poster_id <> {$post_info['user_id']}
|
|
|
|
GROUP BY u.user_id
|
|
|
|
ORDER BY postings DESC";
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
// Fill the user select list with users who have posted
|
|
|
|
// under this IP
|
|
|
|
if ($row['user_id'] != $post_info['poster_id'])
|
|
|
|
{
|
|
|
|
$users_ary[strtolower($row['username'])] = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_block_vars('userrow', array(
|
|
|
|
'USERNAME' => ($row['user_id'] == ANONYMOUS) ? $user->lang['GUEST'] : $row['username'],
|
2006-02-05 01:40:45 +00:00
|
|
|
'NUM_POSTS' => $row['postings'],
|
2004-07-08 23:03:03 +00:00
|
|
|
'L_POST_S' => ($row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS'],
|
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
'U_PROFILE' => ($row['user_id'] == ANONYMOUS) ? '' : "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'],
|
|
|
|
'U_SEARCHPOSTS' => "{$phpbb_root_path}search.$phpEx$SID&author=" . urlencode($row['username']) . "&sr=topics")
|
2004-07-08 23:03:03 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
// Get other IP's this user has posted under
|
|
|
|
$sql = 'SELECT poster_ip, COUNT(*) AS postings
|
|
|
|
FROM ' . POSTS_TABLE . '
|
|
|
|
WHERE poster_id = ' . $post_info['poster_id'] . '
|
|
|
|
GROUP BY poster_ip
|
|
|
|
ORDER BY postings DESC';
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
$hostname = (($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') && $row['poster_ip']) ? @gethostbyaddr($row['poster_ip']) : '';
|
|
|
|
|
|
|
|
$template->assign_block_vars('iprow', array(
|
|
|
|
'IP' => $row['poster_ip'],
|
|
|
|
'HOSTNAME' => $hostname,
|
2006-02-05 01:40:45 +00:00
|
|
|
'NUM_POSTS' => $row['postings'],
|
2004-07-08 23:03:03 +00:00
|
|
|
'L_POST_S' => ($row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS'],
|
|
|
|
|
|
|
|
'U_LOOKUP_IP' => ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? '' : "$url&i=$id&mode=post_details&rdns={$row['poster_ip']}#ip",
|
2006-02-05 01:40:45 +00:00
|
|
|
'U_WHOIS' => "{$phpbb_root_path}mcp.$phpEx$SID&i=$id&mode=whois&ip={$row['poster_ip']}")
|
2004-07-08 23:03:03 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
$user_select = '';
|
|
|
|
ksort($users_ary);
|
|
|
|
foreach ($users_ary as $row)
|
2004-07-08 23:03:03 +00:00
|
|
|
{
|
2006-02-05 01:40:45 +00:00
|
|
|
$user_select .= '<option value="' . $row['user_id'] . '">' . $row['username'] . "</option>\n";
|
2004-07-08 23:03:03 +00:00
|
|
|
}
|
2006-02-05 01:40:45 +00:00
|
|
|
$template->assign_var('S_USER_SELECT', $user_select);
|
2004-07-08 23:03:03 +00:00
|
|
|
}
|
|
|
|
|
2004-07-09 12:31:33 +00:00
|
|
|
}
|
|
|
|
|
2006-02-05 01:40:45 +00:00
|
|
|
/**
|
|
|
|
* Changes a post's poster_id
|
|
|
|
*/
|
|
|
|
function change_poster(&$post_info, $new_user)
|
|
|
|
{
|
|
|
|
global $auth, $db;
|
|
|
|
|
|
|
|
if ($new_user && $new_user != $post_info['user_id'])
|
|
|
|
{
|
|
|
|
$post_id = $post_info['post_id'];
|
|
|
|
|
|
|
|
$sql = 'UPDATE ' . POSTS_TABLE . "
|
|
|
|
SET poster_id = $new_user
|
|
|
|
WHERE post_id = " . $post_id;
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
|
|
|
if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id)
|
|
|
|
{
|
|
|
|
sync('topic', 'topic_id', $post_info['topic_id'], false, false);
|
|
|
|
sync('forum', 'forum_id', $post_info['forum_id'], false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Renew post info
|
|
|
|
$post_info = get_post_data(array($post_id));
|
|
|
|
|
|
|
|
if (!sizeof($post_info))
|
|
|
|
{
|
|
|
|
trigger_error($user->lang['POST_NOT_EXIST']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$post_info = $post_info[$post_id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-09 12:31:33 +00:00
|
|
|
?>
|