phpBB

Code Changes

File: includes/functions_posting.php

  Unmodified   Added   Modified   Removed
Line 189Line 189

if (count($smilies))
{


if (count($smilies))
{

		$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path();

		$root_path = $phpbb_path_helper->get_web_root_path();


foreach ($smilies as $row)
{


foreach ($smilies as $row)
{

Line 256Line 256
*/
function update_post_information($type, $ids, $return_update_sql = false)
{

*/
function update_post_information($type, $ids, $return_update_sql = false)
{

	global $db;

	global $db, $phpbb_dispatcher;


if (empty($ids))
{


if (empty($ids))
{

Line 340Line 340

if (count($last_post_ids))
{


if (count($last_post_ids))
{

		$sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id
AND ' . $db->sql_in_set('p.post_id', $last_post_ids);
$result = $db->sql_query($sql);





		$sql_ary = array(
'SELECT' => 'p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour',
'FROM' => array(
POSTS_TABLE => 'p',
USERS_TABLE => 'u',
),
'WHERE' => $db->sql_in_set('p.post_id', $last_post_ids) . '
AND p.poster_id = u.user_id',
);





 
		/**
* Event to modify the SQL array to get the post and user data from all last posts
*
* @event core.update_post_info_modify_posts_sql
* @var string type The table being updated (forum or topic)
* @var array sql_ary SQL array to get some of the last posts' data
* @since 3.3.5-RC1
*/
$vars = [
'type',
'sql_ary',
];
extract($phpbb_dispatcher->trigger_event('core.update_post_info_modify_posts_sql', compact($vars)));
$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));

$rowset = array();

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

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

 
			$rowset[] = $row;

			$update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id'];
$update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'";
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time'];

			$update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id'];
$update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'";
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time'];

Line 356Line 377
			$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
}
$db->sql_freeresult($result);

			$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
}
$db->sql_freeresult($result);

 

/**
* Event to modify the update_sql array to add new update data for forum or topic last posts
*
* @event core.update_post_info_modify_sql
* @var string type The table being updated (forum or topic)
* @var array rowset Array with the posts data
* @var array update_sql Array with SQL data to update the forums or topics table with
* @since 3.3.5-RC1
*/
$vars = [
'type',
'rowset',
'update_sql',
];
extract($phpbb_dispatcher->trigger_event('core.update_post_info_modify_sql', compact($vars)));
unset($rowset);

	}
unset($empty_forums, $ids, $last_post_ids);


	}
unset($empty_forums, $ids, $last_post_ids);


Line 382Line 420
*/
function posting_gen_topic_icons($mode, $icon_id)
{

*/
function posting_gen_topic_icons($mode, $icon_id)
{

	global $phpbb_root_path, $config, $template, $cache;

	global $phpbb_root_path, $phpbb_path_helper, $config, $template, $cache;


// Grab icons
$icons = $cache->obtain_icons();


// Grab icons
$icons = $cache->obtain_icons();

Line 394Line 432

if (count($icons))
{


if (count($icons))
{

		$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;

		$root_path = $phpbb_path_helper->get_web_root_path();


foreach ($icons as $id => $data)
{


foreach ($icons as $id => $data)
{

Line 541Line 579
				// WBMP
case IMAGETYPE_WBMP:
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : false;

				// WBMP
case IMAGETYPE_WBMP:
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : false;

 
				break;

// WEBP
case IMAGETYPE_WEBP:
$new_type = ($format & IMG_WEBP) ? IMG_WEBP : false;

				break;
}
}
else
{

				break;
}
}
else
{

			$new_type = array();
$go_through_types = array(IMG_GIF, IMG_JPG, IMG_PNG, IMG_WBMP);

			$new_type = [];
$go_through_types = [IMG_GIF, IMG_JPG, IMG_PNG, IMG_WBMP, IMG_WEBP];


foreach ($go_through_types as $check_type)
{


foreach ($go_through_types as $check_type)
{

Line 558Line 601
			}
}


			}
}


		return array(

		return [

			'gd'		=> ($new_type) ? true : false,
'format' => $new_type,
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1

			'gd'		=> ($new_type) ? true : false,
'format' => $new_type,
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1

		);

		];

	}


	}


	return array('gd' => false);

	return ['gd' => false];

}

/**

}

/**

Line 658Line 701

case IMG_WBMP:
$image = @imagecreatefromwbmp($source);


case IMG_WBMP:
$image = @imagecreatefromwbmp($source);

 
				break;

case IMG_WEBP:
$image = @imagecreatefromwebp($source);

				break;
}


				break;
}


Line 709Line 756

case IMG_WBMP:
imagewbmp($new_image, $destination);


case IMG_WBMP:
imagewbmp($new_image, $destination);

 
				break;

case IMG_WEBP:
imagewebp($new_image, $destination);

				break;
}


				break;
}


Line 763Line 814

/**
* Generate inline attachment entry


/**
* Generate inline attachment entry

 
 *
* @param array $attachment_data The attachment data
* @param string $filename_data The filename data (filecomment)
* @param bool $show_attach_box Whether to show the attach box
* @param mixed $forum_id The forum id to check or false if private message
* @return int

*/

*/

function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true)

function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true, $forum_id = false)

{

{

	global $template, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;



	global $template, $cache, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;

$allowed_attachments = array_keys($cache->obtain_attach_extensions($forum_id)['_allowed_']);


// Some default template variables


// Some default template variables

	$template->assign_vars(array(

	$default_vars = [

		'S_SHOW_ATTACH_BOX'				=> $show_attach_box,
'S_HAS_ATTACHMENTS' => count($attachment_data),
'FILESIZE' => $config['max_filesize'],
'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '',
'MAX_ATTACHMENT_FILESIZE' => $config['max_filesize'] > 0 ? $user->lang('MAX_ATTACHMENT_FILESIZE', get_formatted_filesize($config['max_filesize'])) : '',

		'S_SHOW_ATTACH_BOX'				=> $show_attach_box,
'S_HAS_ATTACHMENTS' => count($attachment_data),
'FILESIZE' => $config['max_filesize'],
'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '',
'MAX_ATTACHMENT_FILESIZE' => $config['max_filesize'] > 0 ? $user->lang('MAX_ATTACHMENT_FILESIZE', get_formatted_filesize($config['max_filesize'])) : '',

	));















		'ALLOWED_ATTACHMENTS'			=> !empty($allowed_attachments) ? '.' . implode(',.', $allowed_attachments) : '',
];

/**
* Modify default attachments template vars
*
* @event core.modify_default_attachments_template_vars
* @var array allowed_attachments Array containing allowed attachments data
* @var array default_vars Array containing default attachments template vars
* @since 3.3.6-RC1
*/
$vars = ['allowed_attachments', 'default_vars'];
extract($phpbb_dispatcher->trigger_event('core.modify_default_attachments_template_vars', compact($vars)));

$template->assign_vars($default_vars);


if (count($attachment_data))
{


if (count($attachment_data))
{

Line 924Line 997
			$topic_forum_id = ($topic_rows[$draft['topic_id']]['forum_id']) ? $topic_rows[$draft['topic_id']]['forum_id'] : $forum_id;

$link_topic = true;

			$topic_forum_id = ($topic_rows[$draft['topic_id']]['forum_id']) ? $topic_rows[$draft['topic_id']]['forum_id'] : $forum_id;

$link_topic = true;

			$view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_forum_id . '&t=' . $draft['topic_id']);

			$view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $draft['topic_id']);

			$title = $topic_rows[$draft['topic_id']]['topic_title'];


			$title = $topic_rows[$draft['topic_id']]['topic_title'];


			$insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $topic_forum_id . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']);

			$insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 't=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']);

		}
else if ($draft['forum_id'] && $auth->acl_get('f_read', $draft['forum_id']))
{

		}
else if ($draft['forum_id'] && $auth->acl_get('f_read', $draft['forum_id']))
{

Line 1147Line 1220
		$post_subject = censor_text($post_subject);

$post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id'];

		$post_subject = censor_text($post_subject);

$post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id'];

		$u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f=$forum_id&t=$topic_id&p={$row['post_id']}&view=show#p{$row['post_id']}");

		$u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "t=$topic_id&p={$row['post_id']}&view=show#p{$row['post_id']}");


$l_deleted_message = '';
if ($row['post_visibility'] == ITEM_DELETED)


$l_deleted_message = '';
if ($row['post_visibility'] == ITEM_DELETED)

Line 1180Line 1253
			'POST_AUTHOR'			=> get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),


			'POST_AUTHOR'			=> get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),


			'S_HAS_ATTACHMENTS'	=> (!empty($attachments[$row['post_id']])) ? true : false,
'S_FRIEND' => ($row['friend']) ? true : false,
'S_IGNORE_POST' => ($row['foe']) ? true : false,
'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"phpbb.toggleDisplay('{$post_anchor}', 1); return false;\">", '</a>') : '',
'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false,

			'S_HAS_ATTACHMENTS'	=> !empty($attachments[$row['post_id']]),
'S_FRIEND' => (bool) $row['friend'],
'S_IGNORE_POST' => (bool) $row['foe'],
'L_IGNORE_POST' => $row['foe'] ? $user->lang('POST_BY_FOE', get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"phpbb.toggleDisplay('{$post_anchor}', 1); return false;\">", '</a>') : '',
'S_POST_DELETED' => $row['post_visibility'] == ITEM_DELETED,

			'L_DELETE_POST'		=> $l_deleted_message,

'POST_SUBJECT' => $post_subject,

			'L_DELETE_POST'		=> $l_deleted_message,

'POST_SUBJECT' => $post_subject,

Line 1196Line 1269
			'POST_TIME'			=> $row['post_time'],
'USER_ID' => $row['user_id'],
'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'],

			'POST_TIME'			=> $row['post_time'],
'USER_ID' => $row['user_id'],
'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'],

			'U_MCP_DETAILS'		=> ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=post_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',

			'U_MCP_DETAILS'		=> ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=post_details&amp;p=' . $row['post_id'], true, $user->session_id) : '',

			'POSTER_QUOTE'		=> ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '',
);


			'POSTER_QUOTE'		=> ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '',
);


Line 1272Line 1345
	{
$post_mode = 'delete_first_post';
}

	{
$post_mode = 'delete_first_post';
}

	else if ($data['topic_last_post_id'] == $post_id)

	else if ($data['topic_last_post_id'] <= $post_id)

	{
$post_mode = 'delete_last_post';
}

	{
$post_mode = 'delete_last_post';
}

Line 2490Line 2563
		}
}


		}
}


	$params = $add_anchor = '';



	$params = [];
$add_anchor = '';
$url = "{$phpbb_root_path}viewtopic.$phpEx";


if ($post_visibility == ITEM_APPROVED ||
($auth->acl_get('m_softdelete', $data_ary['forum_id']) && $post_visibility == ITEM_DELETED) ||
($auth->acl_get('m_approve', $data_ary['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE))))
{


if ($post_visibility == ITEM_APPROVED ||
($auth->acl_get('m_softdelete', $data_ary['forum_id']) && $post_visibility == ITEM_DELETED) ||
($auth->acl_get('m_approve', $data_ary['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE))))
{

		$params .= '&amp;t=' . $data_ary['topic_id'];


 
		if ($mode != 'post')
{

		if ($mode != 'post')
{

			$params .= '&amp;p=' . $data_ary['post_id'];

			$params['p'] = $data_ary['post_id'];

			$add_anchor = '#p' . $data_ary['post_id'];

			$add_anchor = '#p' . $data_ary['post_id'];

 
		}
else
{
$params['t'] = $data_ary['topic_id'];

		}
}
else if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic')
{

		}
}
else if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic')
{

		$params .= '&amp;t=' . $data_ary['topic_id'];






		$params['t'] = $data_ary['topic_id'];
}
else
{
$url = "{$phpbb_root_path}viewforum.$phpEx";
$params['f'] = $data_ary['forum_id'];

	}


	}


	$url = (!$params) ? "{$phpbb_root_path}viewforum.$phpEx" : "{$phpbb_root_path}viewtopic.$phpEx";
$url = append_sid($url, 'f=' . $data_ary['forum_id'] . $params) . $add_anchor;

	$url = append_sid($url, $params) . $add_anchor;



$poll = $poll_ary;
$data = $data_ary;


$poll = $poll_ary;
$data = $data_ary;

Line 2571Line 2652
*				- 'topic_last_poster_name'
* - 'topic_last_poster_colour'
* @param int $bump_time The time at which topic was bumped, usually it is a current time as obtained via time().

*				- 'topic_last_poster_name'
* - 'topic_last_poster_colour'
* @param int $bump_time The time at which topic was bumped, usually it is a current time as obtained via time().

* @return string An URL to the bumped topic, example: ./viewtopic.php?forum_id=1&amptopic_id=2&ampp=3#p3

* @return string An URL to the bumped topic, example: ./viewtopic.php?p=3#p3

*/
function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false)
{

*/
function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false)
{

Line 2660Line 2741
		$post_data['topic_title']
));


		$post_data['topic_title']
));


	$url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}";

	$url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}";


return $url;
}


return $url;
}

Line 2791Line 2872
					$delete_reason
));


					$delete_reason
));


				$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;p=$next_post_id") . "#p$next_post_id";








				if ($next_post_id > 0)
{
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=$next_post_id") . "#p$next_post_id";
}
else
{
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id");
}

				$message = $user->lang['POST_DELETED'];

if (!$request->is_ajax())

				$message = $user->lang['POST_DELETED'];

if (!$request->is_ajax())