phpBB

Code Changes

File: includes/mcp/mcp_post.php

  Unmodified   Added   Modified   Removed
Line 24Line 24
*/
function mcp_post_details($id, $mode, $action)
{

*/
function mcp_post_details($id, $mode, $action)
{

	global $phpEx, $phpbb_root_path, $config;
global $template, $db, $user, $auth, $cache;


	global $phpEx, $phpbb_root_path, $config, $request;
global $template, $db, $user, $auth, $cache, $phpbb_container;
global $phpbb_dispatcher;


$user->add_lang('posting');



$user->add_lang('posting');


Line 52Line 53
			if ($auth->acl_get('m_info', $post_info['forum_id']))
{
$ip = request_var('ip', '');

			if ($auth->acl_get('m_info', $post_info['forum_id']))
{
$ip = request_var('ip', '');

 
				if (!function_exists('user_ipwhois'))
{

				include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

				include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

 
				}


$template->assign_vars(array(
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;mode=$mode&amp;p=$post_id") . '">', '</a>'),


$template->assign_vars(array(
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;mode=$mode&amp;p=$post_id") . '">', '</a>'),

Line 104Line 108
					trigger_error('FORM_INVALID');
}
}

					trigger_error('FORM_INVALID');
}
}

 

break;

default:

/**
* This event allows you to handle custom post moderation options
*
* @event core.mcp_post_additional_options
* @var string action Post moderation action name
* @var array post_info Information on the affected post
* @since 3.1.5-RC1
*/
$vars = array('action', 'post_info');
extract($phpbb_dispatcher->trigger_event('core.mcp_post_additional_options', compact($vars)));


break;
}


break;
}

Line 197Line 216
		$l_deleted_by = '';
}


		$l_deleted_by = '';
}


	$template->assign_vars(array(

	$mcp_post_template_data = array(

		'U_MCP_ACTION'			=> "$url&amp;i=main&amp;quickmod=1&amp;mode=post_details", // Use this for mode paramaters
'U_POST_ACTION' => "$url&amp;i=$id&amp;mode=post_details", // Use this for action parameters
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&amp;p=$post_id&amp;f={$post_info['forum_id']}"),

		'U_MCP_ACTION'			=> "$url&amp;i=main&amp;quickmod=1&amp;mode=post_details", // Use this for mode paramaters
'U_POST_ACTION' => "$url&amp;i=$id&amp;mode=post_details", // Use this for action parameters
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&amp;p=$post_id&amp;f={$post_info['forum_id']}"),

Line 249Line 268

'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? "$url&amp;i=$id&amp;mode=$mode&amp;lookup={$post_info['poster_ip']}#ip" : '',
'U_WHOIS' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;mode=$mode&amp;action=whois&amp;p=$post_id&amp;ip={$post_info['poster_ip']}") : '',


'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? "$url&amp;i=$id&amp;mode=$mode&amp;lookup={$post_info['poster_ip']}#ip" : '',
'U_WHOIS' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;mode=$mode&amp;action=whois&amp;p=$post_id&amp;ip={$post_info['poster_ip']}") : '',

	));


























	);

$s_additional_opts = false;

/**
* Event to add/modify MCP post template data
*
* @event core.mcp_post_template_data
* @var array post_info Array with the post information
* @var array mcp_post_template_data Array with the MCP post template data
* @var array attachments Array with the post attachments, if any
* @var bool s_additional_opts Must be set to true in extension if additional options are presented in MCP post panel
* @since 3.1.5-RC1
*/
$vars = array(
'post_info',
'mcp_post_template_data',
'attachments',
's_additional_opts',
);
extract($phpbb_dispatcher->trigger_event('core.mcp_post_template_data', compact($vars)));

$template->assign_vars($mcp_post_template_data);
$template->assign_var('S_MCP_POST_ADDITIONAL_OPTS', $s_additional_opts);

unset($mcp_post_template_data);


// Get User Notes
$log_data = array();


// Get User Notes
$log_data = array();

Line 314Line 358
	// Get IP
if ($auth->acl_get('m_info', $post_info['forum_id']))
{

	// Get IP
if ($auth->acl_get('m_info', $post_info['forum_id']))
{

		$rdns_ip_num = request_var('rdns', '');





		/** @var \phpbb\pagination $pagination */
$pagination = $phpbb_container->get('pagination');

$rdns_ip_num = $request->variable('rdns', '');
$start_users = $request->variable('start_users', 0);


if ($rdns_ip_num != 'all')
{
$template->assign_vars(array(
'U_LOOKUP_ALL' => "$url&amp;i=main&amp;mode=post_details&amp;rdns=all")
);


if ($rdns_ip_num != 'all')
{
$template->assign_vars(array(
'U_LOOKUP_ALL' => "$url&amp;i=main&amp;mode=post_details&amp;rdns=all")
);

 
		}

$num_users = false;
if ($start_users)
{
$num_users = phpbb_get_num_posters_for_ip($db, $post_info['poster_ip']);
$start_users = $pagination->validate_start($start_users, $config['posts_per_page'], $num_users);

		}

// Get other users who've posted under this IP
$sql = 'SELECT poster_id, COUNT(poster_id) as postings
FROM ' . POSTS_TABLE . "
WHERE poster_ip = '" . $db->sql_escape($post_info['poster_ip']) . "'

		}

// Get other users who've posted under this IP
$sql = 'SELECT poster_id, COUNT(poster_id) as postings
FROM ' . POSTS_TABLE . "
WHERE poster_ip = '" . $db->sql_escape($post_info['poster_ip']) . "'

 
				AND poster_id <> " . (int) $post_info['poster_id'] . "

			GROUP BY poster_id

			GROUP BY poster_id

			ORDER BY postings DESC";
$result = $db->sql_query($sql);

			ORDER BY postings DESC, poster_id ASC";
$result = $db->sql_query_limit($sql, $config['posts_per_page'], $start_users);





 
		$page_users = 0;

		while ($row = $db->sql_fetchrow($result))
{

		while ($row = $db->sql_fetchrow($result))
{

			// Fill the user select list with users who have posted under this IP
if ($row['poster_id'] != $post_info['poster_id'])
{

			$page_users++;



				$users_ary[$row['poster_id']] = $row;

				$users_ary[$row['poster_id']] = $row;

			}

 
		}
$db->sql_freeresult($result);

		}
$db->sql_freeresult($result);

 

if ($page_users == $config['posts_per_page'] || $start_users)
{
if ($num_users === false)
{
$num_users = phpbb_get_num_posters_for_ip($db, $post_info['poster_ip']);
}

$pagination->generate_template_pagination(
$url . '&amp;i=main&amp;mode=post_details',
'pagination',
'start_users',
$num_users,
$config['posts_per_page'],
$start_users
);
}


if (sizeof($users_ary))
{


if (sizeof($users_ary))
{

Line 374Line 445
		// A compound index on poster_id, poster_ip (posts table) would help speed up this query a lot,
// but the extra size is only valuable if there are persons having more than a thousands posts.
// This is better left to the really really big forums.

		// A compound index on poster_id, poster_ip (posts table) would help speed up this query a lot,
// but the extra size is only valuable if there are persons having more than a thousands posts.
// This is better left to the really really big forums.

 
		$start_ips = $request->variable('start_ips', 0);

$num_ips = false;
if ($start_ips)
{
$num_ips = phpbb_get_num_ips_for_poster($db, $post_info['poster_id']);
$start_ips = $pagination->validate_start($start_ips, $config['posts_per_page'], $num_ips);
}


$sql = 'SELECT poster_ip, COUNT(poster_ip) AS postings
FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $post_info['poster_id'] . "
GROUP BY poster_ip


$sql = 'SELECT poster_ip, COUNT(poster_ip) 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);

			ORDER BY postings DESC, poster_ip ASC";
$result = $db->sql_query_limit($sql, $config['posts_per_page'], $start_ips);





 
		$page_ips = 0;

		while ($row = $db->sql_fetchrow($result))
{

		while ($row = $db->sql_fetchrow($result))
{

 
			$page_ips++;

			$hostname = (($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') && $row['poster_ip']) ? @gethostbyaddr($row['poster_ip']) : '';

$template->assign_block_vars('iprow', array(

			$hostname = (($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') && $row['poster_ip']) ? @gethostbyaddr($row['poster_ip']) : '';

$template->assign_block_vars('iprow', array(

Line 397Line 478
			);
}
$db->sql_freeresult($result);

			);
}
$db->sql_freeresult($result);

 

if ($page_ips == $config['posts_per_page'] || $start_ips)
{
if ($num_ips === false)
{
$num_ips = phpbb_get_num_ips_for_poster($db, $post_info['poster_id']);
}

$pagination->generate_template_pagination(
$url . '&amp;i=main&amp;mode=post_details',
'pagination_ips',
'start_ips',
$num_ips,
$config['posts_per_page'],
$start_ips
);
}


$user_select = '';



$user_select = '';


Line 413Line 511
		$template->assign_var('S_USER_SELECT', $user_select);
}


		$template->assign_var('S_USER_SELECT', $user_select);
}


 
}

/**
* Get the number of posters for a given ip
*
* @param \phpbb\db\driver\driver_interface $db DBAL interface
* @param string $poster_ip IP
* @return int Number of posters
*/
function phpbb_get_num_posters_for_ip(\phpbb\db\driver\driver_interface $db, $poster_ip)
{
$sql = 'SELECT COUNT(DISTINCT poster_id) as num_users
FROM ' . POSTS_TABLE . "
WHERE poster_ip = '" . $db->sql_escape($poster_ip) . "'";
$result = $db->sql_query($sql);
$num_users = (int) $db->sql_fetchfield('num_users');
$db->sql_freeresult($result);

return $num_users;
}

/**
* Get the number of ips for a given poster
*
* @param \phpbb\db\driver\driver_interface $db
* @param int $poster_id Poster user ID
* @return int Number of IPs for given poster
*/
function phpbb_get_num_ips_for_poster(\phpbb\db\driver\driver_interface $db, $poster_id)
{
$sql = 'SELECT COUNT(DISTINCT poster_ip) as num_ips
FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . (int) $poster_id;
$result = $db->sql_query($sql);
$num_ips = (int) $db->sql_fetchfield('num_ips');
$db->sql_freeresult($result);

return $num_ips;

}

/**

}

/**

Line 420Line 556
*/
function change_poster(&$post_info, $userdata)
{

*/
function change_poster(&$post_info, $userdata)
{

	global $auth, $db, $config, $phpbb_root_path, $phpEx, $user;

	global $auth, $db, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;


if (empty($userdata) || $userdata['user_id'] == $post_info['user_id'])
{


if (empty($userdata) || $userdata['user_id'] == $post_info['user_id'])
{

Line 497Line 633
	{
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;

	{
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;

		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);

		$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);


if (!$error && method_exists($search, 'destroy_cache'))
{


if (!$error && method_exists($search, 'destroy_cache'))
{

Line 507Line 643

$from_username = $post_info['username'];
$to_username = $userdata['username'];


$from_username = $post_info['username'];
$to_username = $userdata['username'];

 

/**
* This event allows you to perform additional tasks after changing a post's poster
*
* @event core.mcp_change_poster_after
* @var array userdata Information on a post's new poster
* @var array post_info Information on the affected post
* @since 3.1.6-RC1
* @changed 3.1.7-RC1 Change location to prevent post_info from being set to the new post information
*/
$vars = array('userdata', 'post_info');
extract($phpbb_dispatcher->trigger_event('core.mcp_change_poster_after', compact($vars)));


// Renew post info
$post_info = phpbb_get_post_data(array($post_id), false, true);


// Renew post info
$post_info = phpbb_get_post_data(array($post_id), false, true);