phpBB

Code Changes

File: includes/functions_content.php

  Unmodified   Added   Modified   Removed
Line 47Line 47
*/
function 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, $def_st = false, $def_sk = false, $def_sd = false)
{

*/
function 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, $def_st = false, $def_sk = false, $def_sd = false)
{

	global $user;

	global $user, $phpbb_dispatcher;


$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);



$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);


Line 78Line 78
	foreach ($sorts as $name => $sort_ary)
{
$key = $sort_ary['key'];

	foreach ($sorts as $name => $sort_ary)
{
$key = $sort_ary['key'];

		$selected = $$sort_ary['key'];

		$selected = ${$sort_ary['key']};


// Check if the key is selectable. If not, we reset to the default or first key found.
// This ensures the values are always valid. We also set $sort_dir/sort_key/etc. to the


// Check if the key is selectable. If not, we reset to the default or first key found.
// This ensures the values are always valid. We also set $sort_dir/sort_key/etc. to the

Line 87Line 87
		{
if ($sort_ary['default'] !== false)
{

		{
if ($sort_ary['default'] !== false)
{

				$selected = $$key = $sort_ary['default'];

				$selected = ${$key} = $sort_ary['default'];

			}
else
{
@reset($sort_ary['options']);

			}
else
{
@reset($sort_ary['options']);

				$selected = $$key = key($sort_ary['options']);

				$selected = ${$key} = key($sort_ary['options']);

			}
}


			}
}


Line 105Line 105

$u_sort_param .= ($selected !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&' : '') . "{$name}={$selected}" : '';
}


$u_sort_param .= ($selected !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&' : '') . "{$name}={$selected}" : '';
}

 

/**
* Run code before generated sort selects are returned
*
* @event core.gen_sort_selects_after
* @var int limit_days Days limit
* @var array sort_by_text Sort by text options
* @var int sort_days Sort by days flag
* @var string sort_key Sort key
* @var string sort_dir Sort dir
* @var string s_limit_days String of days limit
* @var string s_sort_key String of sort key
* @var string s_sort_dir String of sort dir
* @var string u_sort_param Sort URL params
* @var bool def_st Default sort days
* @var bool def_sk Default sort key
* @var bool def_sd Default sort dir
* @var array sorts Sorts
* @since 3.1.9-RC1
*/
$vars = array(
'limit_days',
'sort_by_text',
'sort_days',
'sort_key',
'sort_dir',
's_limit_days',
's_sort_key',
's_sort_dir',
'u_sort_param',
'def_st',
'def_sk',
'def_sd',
'sorts',
);
extract($phpbb_dispatcher->trigger_event('core.gen_sort_selects_after', compact($vars)));


return;
}


return;
}

Line 114Line 150
*/
function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list = false, $force_display = false)
{

*/
function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list = false, $force_display = false)
{

	global $config, $auth, $template, $user, $db, $phpbb_path_helper;

	global $config, $auth, $template, $user, $db, $phpbb_path_helper, $phpbb_dispatcher;


// We only return if the jumpbox is not forced to be displayed (in case it is needed for functionality)
if (!$config['load_jumpbox'] && $force_display === false)


// We only return if the jumpbox is not forced to be displayed (in case it is needed for functionality)
if (!$config['load_jumpbox'] && $force_display === false)

Line 126Line 162
		FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600);

		FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600);

 

$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
$rowset[(int) $row['forum_id']] = $row;
}
$db->sql_freeresult($result);


$right = $padding = 0;
$padding_store = array('0' => 0);
$display_jumpbox = false;
$iteration = 0;


$right = $padding = 0;
$padding_store = array('0' => 0);
$display_jumpbox = false;
$iteration = 0;

 

/**
* Modify the jumpbox forum list data
*
* @event core.make_jumpbox_modify_forum_list
* @var array rowset Array with the forums list data
* @since 3.1.10-RC1
*/
$vars = array('rowset');
extract($phpbb_dispatcher->trigger_event('core.make_jumpbox_modify_forum_list', compact($vars)));


// Sometimes it could happen that forums will be displayed here not be displayed within the index page
// This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
// If this happens, the padding could be "broken"



// Sometimes it could happen that forums will be displayed here not be displayed within the index page
// This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
// If this happens, the padding could be "broken"


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

	foreach ($rowset as $row)

	{
if ($row['left_id'] < $right)
{

	{
if ($row['left_id'] < $right)
{

Line 169Line 222
			continue;
}


			continue;
}


 
		$tpl_ary = array();

		if (!$display_jumpbox)
{

		if (!$display_jumpbox)
{

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

			$tpl_ary[] = array(

				'FORUM_ID'		=> ($select_all) ? 0 : -1,
'FORUM_NAME' => ($select_all) ? $user->lang['ALL_FORUMS'] : $user->lang['SELECT_FORUM'],
'S_FORUM_COUNT' => $iteration,
'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $forum_id)),

				'FORUM_ID'		=> ($select_all) ? 0 : -1,
'FORUM_NAME' => ($select_all) ? $user->lang['ALL_FORUMS'] : $user->lang['SELECT_FORUM'],
'S_FORUM_COUNT' => $iteration,
'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $forum_id)),

			));

			);


$iteration++;
$display_jumpbox = true;
}



$iteration++;
$display_jumpbox = true;
}


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

		$tpl_ary[] = array(

			'FORUM_ID'		=> $row['forum_id'],
'FORUM_NAME' => $row['forum_name'],
'SELECTED' => ($row['forum_id'] == $forum_id) ? ' selected="selected"' : '',

			'FORUM_ID'		=> $row['forum_id'],
'FORUM_NAME' => $row['forum_name'],
'SELECTED' => ($row['forum_id'] == $forum_id) ? ' selected="selected"' : '',

Line 191Line 245
			'S_IS_LINK'		=> ($row['forum_type'] == FORUM_LINK) ? true : false,
'S_IS_POST' => ($row['forum_type'] == FORUM_POST) ? true : false,
'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $row['forum_id'])),

			'S_IS_LINK'		=> ($row['forum_type'] == FORUM_LINK) ? true : false,
'S_IS_POST' => ($row['forum_type'] == FORUM_POST) ? true : false,
'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $row['forum_id'])),

		));



















		);

/**
* Modify the jumpbox before it is assigned to the template
*
* @event core.make_jumpbox_modify_tpl_ary
* @var array row The data of the forum
* @var array tpl_ary Template data of the forum
* @since 3.1.10-RC1
*/
$vars = array(
'row',
'tpl_ary',
);
extract($phpbb_dispatcher->trigger_event('core.make_jumpbox_modify_tpl_ary', compact($vars)));

$template->assign_block_vars_array('jumpbox_forums', $tpl_ary);

unset($tpl_ary);


for ($i = 0; $i < $padding; $i++)
{


for ($i = 0; $i < $padding; $i++)
{

Line 199Line 271
		}
$iteration++;
}

		}
$iteration++;
}

	$db->sql_freeresult($result);
unset($padding_store);

	unset($padding_store, $rowset);



$url_parts = $phpbb_path_helper->get_url_parts($action);



$url_parts = $phpbb_path_helper->get_url_parts($action);


Line 389Line 460
/**
* Decode text whereby text is coming from the db and expected to be pre-parsed content
* We are placing this outside of the message parser because we are often in need of it...

/**
* Decode text whereby text is coming from the db and expected to be pre-parsed content
* We are placing this outside of the message parser because we are often in need of it...

 
*
* NOTE: special chars are kept encoded
*
* @param string &$message Original message, passed by reference
* @param string $bbcode_uid BBCode UID
* @return null

*/
function decode_message(&$message, $bbcode_uid = '')
{

*/
function decode_message(&$message, $bbcode_uid = '')
{

	global $config;

	global $phpbb_container, $phpbb_dispatcher;





 
	/**
* Use this event to modify the message before it is decoded
*
* @event core.decode_message_before
* @var string message_text The message content
* @var string bbcode_uid The message BBCode UID
* @since 3.1.9-RC1
*/
$message_text = $message;
$vars = array('message_text', 'bbcode_uid');
extract($phpbb_dispatcher->trigger_event('core.decode_message_before', compact($vars)));
$message = $message_text;

if (preg_match('#^<[rt][ >]#', $message))
{
$message = htmlspecialchars($phpbb_container->get('text_formatter.utils')->unparse($message), ENT_COMPAT);
}
else
{

	if ($bbcode_uid)
{
$match = array('<br />', "[/*:m:$bbcode_uid]", ":u:$bbcode_uid", ":o:$bbcode_uid", ":$bbcode_uid");

	if ($bbcode_uid)
{
$match = array('<br />', "[/*:m:$bbcode_uid]", ":u:$bbcode_uid", ":o:$bbcode_uid", ":$bbcode_uid");

Line 408Line 504
	$message = str_replace($match, $replace, $message);

$match = get_preg_expression('bbcode_htm');

	$message = str_replace($match, $replace, $message);

$match = get_preg_expression('bbcode_htm');

	$replace = array('\1', '\1', '\2', '\1', '', '');

		$replace = array('\1', '\1', '\2', '\2', '\1', '', '');


$message = preg_replace($match, $replace, $message);
}

/**


$message = preg_replace($match, $replace, $message);
}

/**

* Strips all bbcode from a text and returns the plain content















	* Use this event to modify the message after it is decoded
*
* @event core.decode_message_after
* @var string message_text The message content
* @var string bbcode_uid The message BBCode UID
* @since 3.1.9-RC1
*/
$message_text = $message;
$vars = array('message_text', 'bbcode_uid');
extract($phpbb_dispatcher->trigger_event('core.decode_message_after', compact($vars)));
$message = $message_text;
}

/**
* Strips all bbcode from a text in place

*/
function strip_bbcode(&$text, $uid = '')

*/
function strip_bbcode(&$text, $uid = '')

 
{
global $phpbb_container;

if (preg_match('#^<[rt][ >]#', $text))
{
$text = $phpbb_container->get('text_formatter.utils')->clean_formatting($text);
}
else

{
if (!$uid)
{

{
if (!$uid)
{

Line 429Line 547
	$replace = array('\1', '\1', '\2', '\1', '', '');

$text = preg_replace($match, $replace, $text);

	$replace = array('\1', '\1', '\2', '\1', '', '');

$text = preg_replace($match, $replace, $text);

 
	}

}

/**

}

/**

Line 438Line 557
function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true)
{
static $bbcode;

function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true)
{
static $bbcode;

	global $phpbb_dispatcher;

	global $phpbb_dispatcher, $phpbb_container;


if ($text === '')
{


if ($text === '')
{

Line 459Line 578
	$vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text');
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars)));


	$vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text');
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars)));


 
	if (preg_match('#^<[rt][ >]#', $text))
{
$renderer = $phpbb_container->get('text_formatter.renderer');

// Temporarily switch off viewcensors if applicable
$old_censor = $renderer->get_viewcensors();
if ($old_censor !== $censor_text)
{
$renderer->set_viewcensors($censor_text);
}

$text = $renderer->render($text);

// Restore the previous value
if ($old_censor !== $censor_text)
{
$renderer->set_viewcensors($old_censor);
}
}
else
{

	if ($censor_text)
{
$text = censor_text($text);

	if ($censor_text)
{
$text = censor_text($text);

Line 487Line 627

$text = bbcode_nl2br($text);
$text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES));


$text = bbcode_nl2br($text);
$text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES));

 
	}


/**
* Use this event to modify the text after it is parsed


/**
* Use this event to modify the text after it is parsed

Line 507Line 648
/**
* For parsing custom parsed text to be stored within the database.
* This function additionally returns the uid and bitfield that needs to be stored.

/**
* For parsing custom parsed text to be stored within the database.
* This function additionally returns the uid and bitfield that needs to be stored.

* Expects $text to be the value directly from request_var() and in it's non-parsed form

* Expects $text to be the value directly from $request->variable() and in it's non-parsed form

*
* @param string $text The text to be replaced with the parsed one
* @param string $uid The BBCode uid for this parse

*
* @param string $text The text to be replaced with the parsed one
* @param string $uid The BBCode uid for this parse

Line 516Line 657
* @param bool $allow_bbcode If BBCode is allowed (i.e. if BBCode is parsed)
* @param bool $allow_urls If urls is allowed
* @param bool $allow_smilies If smilies are allowed

* @param bool $allow_bbcode If BBCode is allowed (i.e. if BBCode is parsed)
* @param bool $allow_urls If urls is allowed
* @param bool $allow_smilies If smilies are allowed

 
* @param bool $allow_img_bbcode
* @param bool $allow_flash_bbcode
* @param bool $allow_quote_bbcode
* @param bool $allow_url_bbcode
* @param string $mode Mode to parse text as, e.g. post or sig

*
* @return array An array of string with the errors that occurred while parsing
*/

*
* @return array An array of string with the errors that occurred while parsing
*/

function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false)

function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $mode = 'post')

{
global $phpbb_root_path, $phpEx, $phpbb_dispatcher;


{
global $phpbb_root_path, $phpEx, $phpbb_dispatcher;


Line 534Line 680
	* @var bool		allow_bbcode	Whether or not to parse BBCode
* @var bool allow_urls Whether or not to parse URLs
* @var bool allow_smilies Whether or not to parse Smilies

	* @var bool		allow_bbcode	Whether or not to parse BBCode
* @var bool allow_urls Whether or not to parse URLs
* @var bool allow_smilies Whether or not to parse Smilies

 
	* @var bool		allow_img_bbcode	Whether or not to parse the [img] BBCode
* @var bool allow_flash_bbcode Whether or not to parse the [flash] BBCode
* @var bool allow_quote_bbcode Whether or not to parse the [quote] BBCode
* @var bool allow_url_bbcode Whether or not to parse the [url] BBCode
* @var string mode Mode to parse text as, e.g. post or sig

	* @since 3.1.0-a1

	* @since 3.1.0-a1

 
	* @changed 3.2.0-a1

	*/
$vars = array(
'text',

	*/
$vars = array(
'text',

Line 544Line 696
		'allow_bbcode',
'allow_urls',
'allow_smilies',

		'allow_bbcode',
'allow_urls',
'allow_smilies',

 
		'allow_img_bbcode',
'allow_flash_bbcode',
'allow_quote_bbcode',
'allow_url_bbcode',
'mode',

	);
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars)));

$uid = $bitfield = '';
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);

	);
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars)));

$uid = $bitfield = '';
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);


if ($text === '')
{
return;
}

 

if (!class_exists('parse_message'))
{


if (!class_exists('parse_message'))
{

Line 561Line 713
	}

$message_parser = new parse_message($text);

	}

$message_parser = new parse_message($text);

	$message_parser->parse($allow_bbcode, $allow_urls, $allow_smilies);

	$message_parser->parse($allow_bbcode, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode, true, $mode);


$text = $message_parser->message;
$uid = $message_parser->bbcode_uid;


$text = $message_parser->message;
$uid = $message_parser->bbcode_uid;

Line 596Line 748
*/
function generate_text_for_edit($text, $uid, $flags)
{

*/
function generate_text_for_edit($text, $uid, $flags)
{

	global $phpbb_root_path, $phpEx, $phpbb_dispatcher;

	global $phpbb_dispatcher;


/**
* Use this event to modify the text before it is decoded for editing


/**
* Use this event to modify the text before it is decoded for editing

Line 712Line 864
		break;
}


		break;
}


	$short_url = (strlen($url) > 55) ? substr($url, 0, 39) . ' ... ' . substr($url, -10) : $url;

	$short_url = (utf8_strlen($url) > 55) ? utf8_substr($url, 0, 39) . ' ... ' . utf8_substr($url, -10) : $url;


switch ($type)
{


switch ($type)
{

Line 788Line 940

// relative urls for this board
$magic_url_match_args[$server_url][] = array(


// relative urls for this board
$magic_url_match_args[$server_url][] = array(

			'#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#i',

			'#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu',

			MAGIC_URL_LOCAL,
$local_class,
);

// matches a xxxx://aaaaa.bbb.cccc. ...
$magic_url_match_args[$server_url][] = array(

			MAGIC_URL_LOCAL,
$local_class,
);

// matches a xxxx://aaaaa.bbb.cccc. ...
$magic_url_match_args[$server_url][] = array(

			'#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#i',

			'#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#iu',

			MAGIC_URL_FULL,
$class,
);

// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
$magic_url_match_args[$server_url][] = array(

			MAGIC_URL_FULL,
$class,
);

// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
$magic_url_match_args[$server_url][] = array(

			'#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#i',

			'#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#iu',

			MAGIC_URL_WWW,
$class,
);

// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
$magic_url_match_args[$server_url][] = array(

			MAGIC_URL_WWW,
$class,
);

// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
$magic_url_match_args[$server_url][] = array(

			'/(^|[\n\t (>])(' . get_preg_expression('email') . ')/i',

			'/(^|[\n\t (>])(' . get_preg_expression('email') . ')/iu',

			MAGIC_URL_EMAIL,
'',
);

			MAGIC_URL_EMAIL,
'',
);

Line 883Line 1035
*/
function smiley_text($text, $force_option = false)
{

*/
function smiley_text($text, $force_option = false)
{

	global $config, $user, $phpbb_path_helper;

	global $config, $user, $phpbb_path_helper, $phpbb_dispatcher;


if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies'))
{


if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies'))
{

Line 892Line 1044
	else
{
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path();

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

 

/**
* Event to override the root_path for smilies
*
* @event core.smiley_text_root_path
* @var string root_path root_path for smilies
* @since 3.1.11-RC1
*/
$vars = array('root_path');
extract($phpbb_dispatcher->trigger_event('core.smiley_text_root_path', compact($vars)));

		return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img class="smilies" src="' . $root_path . $config['smilies_path'] . '/\2 />', $text);
}
}

		return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img class="smilies" src="' . $root_path . $config['smilies_path'] . '/\2 />', $text);
}
}

Line 902Line 1064
* @param mixed $forum_id The forum id the attachments are displayed in (false if in private message)
* @param string &$message The post/private message
* @param array &$attachments The attachments to parse for (inline) display. The attachments array will hold templated data after parsing.

* @param mixed $forum_id The forum id the attachments are displayed in (false if in private message)
* @param string &$message The post/private message
* @param array &$attachments The attachments to parse for (inline) display. The attachments array will hold templated data after parsing.

* @param array &$update_count The attachment counts to be updated - will be filled

* @param array &$update_count_ary The attachment counts to be updated - will be filled

* @param bool $preview If set to true the attachments are parsed for preview. Within preview mode the comments are fetched from the given $attachments array and not fetched from the database.
*/

* @param bool $preview If set to true the attachments are parsed for preview. Within preview mode the comments are fetched from the given $attachments array and not fetched from the database.
*/

function parse_attachments($forum_id, &$message, &$attachments, &$update_count, $preview = false)

function parse_attachments($forum_id, &$message, &$attachments, &$update_count_ary, $preview = false)

{
if (!sizeof($attachments))
{

{
if (!sizeof($attachments))
{

Line 974Line 1136
		unset($new_attachment_data);
}


		unset($new_attachment_data);
}


	// Sort correctly
if ($config['display_order'])
{
// Ascending sort
krsort($attachments);
}
else
{
// Descending sort

	// Make sure attachments are properly ordered









		ksort($attachments);

		ksort($attachments);

	}

 

foreach ($attachments as $attachment)
{


foreach ($attachments as $attachment)
{

Line 1001Line 1154
		// Some basics...
$attachment['extension'] = strtolower(trim($attachment['extension']));
$filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']);

		// Some basics...
$attachment['extension'] = strtolower(trim($attachment['extension']));
$filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']);

		$thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . utf8_basename($attachment['physical_filename']);

 

$upload_icon = '';



$upload_icon = '';


Line 1043Line 1195

if (!$denied)
{


if (!$denied)
{

			$l_downloaded_viewed = $download_link = '';

 
			$display_cat = $extensions[$attachment['extension']]['display_cat'];

if ($display_cat == ATTACHMENT_CATEGORY_IMAGE)

			$display_cat = $extensions[$attachment['extension']]['display_cat'];

if ($display_cat == ATTACHMENT_CATEGORY_IMAGE)

Line 1104Line 1255
						'U_INLINE_LINK'		=> $inline_link,
);


						'U_INLINE_LINK'		=> $inline_link,
);


					$update_count[] = $attachment['attach_id'];

					$update_count_ary[] = $attachment['attach_id'];

				break;

// Images, but display Thumbnail

				break;

// Images, but display Thumbnail

Line 1117Line 1268
						'THUMB_IMAGE'		=> $thumbnail_link,
);


						'THUMB_IMAGE'		=> $thumbnail_link,
);


					$update_count[] = $attachment['attach_id'];
break;

// Windows Media Streams
case ATTACHMENT_CATEGORY_WM:

// Giving the filename directly because within the wm object all variables are in local context making it impossible
// to validate against a valid session (all params can differ)
// $download_link = $filename;

$block_array += array(
'U_FORUM' => generate_board_url(),
'ATTACH_ID' => $attachment['attach_id'],
'S_WM_FILE' => true,
);

// Viewed/Heared File ... update the download count
$update_count[] = $attachment['attach_id'];
break;

// Real Media Streams
case ATTACHMENT_CATEGORY_RM:
case ATTACHMENT_CATEGORY_QUICKTIME:

$block_array += array(
'S_RM_FILE' => ($display_cat == ATTACHMENT_CATEGORY_RM) ? true : false,
'S_QUICKTIME_FILE' => ($display_cat == ATTACHMENT_CATEGORY_QUICKTIME) ? true : false,
'U_FORUM' => generate_board_url(),
'ATTACH_ID' => $attachment['attach_id'],
);

// Viewed/Heared File ... update the download count
$update_count[] = $attachment['attach_id'];

					$update_count_ary[] = $attachment['attach_id'];

































				break;

// Macromedia Flash Files

				break;

// Macromedia Flash Files

Line 1164Line 1283
					);

// Viewed/Heared File ... update the download count

					);

// Viewed/Heared File ... update the download count

					$update_count[] = $attachment['attach_id'];

					$update_count_ary[] = $attachment['attach_id'];

				break;

default:

				break;

default:

Line 1187Line 1306
			);
}


			);
}


 
		$update_count = $update_count_ary;

		/**
* Use this event to modify the attachment template data.
*

		/**
* Use this event to modify the attachment template data.
*

Line 1214Line 1334
			'update_count',
);
extract($phpbb_dispatcher->trigger_event('core.parse_attachments_modify_template_data', compact($vars)));

			'update_count',
);
extract($phpbb_dispatcher->trigger_event('core.parse_attachments_modify_template_data', compact($vars)));

 
		$update_count_ary = $update_count;
unset($update_count);


$template->assign_block_vars('_file', $block_array);



$template->assign_block_vars('_file', $block_array);


Line 1222Line 1344

$attachments = $compiled_attachments;
unset($compiled_attachments);


$attachments = $compiled_attachments;
unset($compiled_attachments);


$tpl_size = sizeof($attachments);

 

$unset_tpl = array();



$unset_tpl = array();


Line 1232Line 1352
	$replace = array();
foreach ($matches[0] as $num => $capture)
{

	$replace = array();
foreach ($matches[0] as $num => $capture)
{

		// Flip index if we are displaying the reverse way
$index = ($config['display_order']) ? ($tpl_size-($matches[1][$num] + 1)) : $matches[1][$num];

		$index = $matches[1][$num];



$replace['from'][] = $matches[0][$num];
$replace['to'][] = (isset($attachments[$index])) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]);


$replace['from'][] = $matches[0][$num];
$replace['to'][] = (isset($attachments[$index])) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]);

Line 1247Line 1366
	}

$unset_tpl = array_unique($unset_tpl);

	}

$unset_tpl = array_unique($unset_tpl);

 

// Sort correctly
if ($config['display_order'])
{
// Ascending sort
krsort($attachments);
}
else
{
// Descending sort
ksort($attachments);
}


// Needed to let not display the inlined attachments at the end of the post again
foreach ($unset_tpl as $index)


// Needed to let not display the inlined attachments at the end of the post again
foreach ($unset_tpl as $index)

Line 1290Line 1421
*/
function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '')
{

*/
function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '')
{

	$chars = array();


 
	$strip_reply = false;
$stripped = false;
if ($allow_reply && strpos($string, 'Re: ') === 0)

	$strip_reply = false;
$stripped = false;
if ($allow_reply && strpos($string, 'Re: ') === 0)