phpBB

Code Changes

File: includes/functions_posting.php

  Unmodified   Added   Modified   Removed
Line 114Line 114
	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


	if (sizeof($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 = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path();


Line 200Line 200
		$topic_condition = '';
}


		$topic_condition = '';
}


	if (sizeof($ids) == 1)

	if (count($ids) == 1)

	{
$sql = 'SELECT MAX(p.post_id) as last_post_id
FROM ' . POSTS_TABLE . " p $topic_join

	{
$sql = 'SELECT MAX(p.post_id) as last_post_id
FROM ' . POSTS_TABLE . " p $topic_join

Line 222Line 222
	$last_post_ids = array();
while ($row = $db->sql_fetchrow($result))
{

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

		if (sizeof($ids) == 1)

		if (count($ids) == 1)

		{
$row[$type . '_id'] = $ids[0];
}

		{
$row[$type . '_id'] = $ids[0];
}

Line 256Line 256
		}
}


		}
}


	if (sizeof($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

	{
$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

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


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


	if ($return_update_sql || !sizeof($update_sql))

	if ($return_update_sql || !count($update_sql))

	{
return $update_sql;
}

	{
return $update_sql;
}

Line 310Line 310
		$template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"');
}


		$template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"');
}


	if (sizeof($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 = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;


Line 690Line 690
{
global $template;


{
global $template;


	if (sizeof($attachment_data))

	if (count($attachment_data))

	{
$s_inline_attachment_options = '';


	{
$s_inline_attachment_options = '';


Line 712Line 712
*/
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)
{

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

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


// Some default template variables
$template->assign_vars(array(
'S_SHOW_ATTACH_BOX' => $show_attach_box,


// Some default template variables
$template->assign_vars(array(
'S_SHOW_ATTACH_BOX' => $show_attach_box,

		'S_HAS_ATTACHMENTS'	=> sizeof($attachment_data),

		'S_HAS_ATTACHMENTS'	=> count($attachment_data),

		'FILESIZE'			=> $config['max_filesize'],
'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '',
));


		'FILESIZE'			=> $config['max_filesize'],
'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '',
));


	if (sizeof($attachment_data))

	if (count($attachment_data))

	{
// We display the posted attachments within the desired order.
($config['display_order']) ? krsort($attachment_data) : ksort($attachment_data);

	{
// We display the posted attachments within the desired order.
($config['display_order']) ? krsort($attachment_data) : ksort($attachment_data);

Line 730Line 730
		foreach ($attachment_data as $count => $attach_row)
{
$hidden = '';

		foreach ($attachment_data as $count => $attach_row)
{
$hidden = '';

 
			$attachrow_template_vars = array();

			$attach_row['real_filename'] = utf8_basename($attach_row['real_filename']);

foreach ($attach_row as $key => $value)

			$attach_row['real_filename'] = utf8_basename($attach_row['real_filename']);

foreach ($attach_row as $key => $value)

Line 739Line 740

$download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false);



$download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false);


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

			$attachrow_template_vars[(int) $attach_row['attach_id']] = array(

				'FILENAME'			=> utf8_basename($attach_row['real_filename']),
'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])),
'FILE_COMMENT' => $attach_row['attach_comment'],

				'FILENAME'			=> utf8_basename($attach_row['real_filename']),
'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])),
'FILE_COMMENT' => $attach_row['attach_comment'],

Line 749Line 750
				'FILESIZE'			=> get_formatted_filesize($attach_row['filesize']),

'U_VIEW_ATTACHMENT' => $download_link,

				'FILESIZE'			=> get_formatted_filesize($attach_row['filesize']),

'U_VIEW_ATTACHMENT' => $download_link,

				'S_HIDDEN'			=> $hidden)

				'S_HIDDEN'			=> $hidden,

			);
}

			);
}

 

/**
* Modify inline attachments template vars
*
* @event core.modify_inline_attachments_template_vars
* @var array attachment_data Array containing attachments data
* @var array attachrow_template_vars Array containing attachments template vars
* @since 3.2.2-RC1
*/
$vars = array('attachment_data', 'attachrow_template_vars');
extract($phpbb_dispatcher->trigger_event('core.modify_inline_attachments_template_vars', compact($vars)));

$template->assign_block_vars_array('attach_row', $attachrow_template_vars);

	}


	}


	return sizeof($attachment_data);

	return count($attachment_data);

}

//

}

//

Line 802Line 816
	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


	if (!sizeof($draft_rows))

	if (!count($draft_rows))

	{
return;
}

$topic_rows = array();

	{
return;
}

$topic_rows = array();

	if (sizeof($topic_ids))

	if (count($topic_ids))

	{
$sql = 'SELECT topic_id, forum_id, topic_title, topic_poster
FROM ' . TOPICS_TABLE . '

	{
$sql = 'SELECT topic_id, forum_id, topic_title, topic_poster
FROM ' . TOPICS_TABLE . '

Line 921Line 935

$db->sql_freeresult($result);



$db->sql_freeresult($result);


	if (!sizeof($post_list))

	if (!count($post_list))

	{
return false;
}

	{
return false;
}

Line 1016Line 1030
	);
extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_post_list', compact($vars)));


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


	for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)

	for ($i = 0, $end = count($post_list); $i < $end; ++$i)

	{
// A non-existing rowset only happens if there was no user present for the entered poster_id
// This could be a broken posts table.

	{
// A non-existing rowset only happens if there was no user present for the entered poster_id
// This could be a broken posts table.

Line 1243Line 1257

foreach ($shadow_forum_ids as $updated_forum => $topic_count)
{


foreach ($shadow_forum_ids as $updated_forum => $topic_count)
{

				// counting is fun! we only have to do sizeof($forum_ids) number of queries,

				// counting is fun! we only have to do count($forum_ids) number of queries,

				// even if the topic is moved back to where its shadow lives (we count how many times it is in a forum)
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_topics_approved = forum_topics_approved - ' . $topic_count . '

				// even if the topic is moved back to where its shadow lives (we count how many times it is in a forum)
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_topics_approved = forum_topics_approved - ' . $topic_count . '

Line 1263Line 1277
				$phpbb_content_visibility->remove_topic_from_statistic($data, $sql_data);

$update_sql = update_post_information('forum', $forum_id, true);

				$phpbb_content_visibility->remove_topic_from_statistic($data, $sql_data);

$update_sql = update_post_information('forum', $forum_id, true);

				if (sizeof($update_sql))

				if (count($update_sql))

				{
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);

				{
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);

Line 1312Line 1326
			{
// Update last post information when hard deleting. Soft delete already did that by itself.
$update_sql = update_post_information('forum', $forum_id, true);

			{
// Update last post information when hard deleting. Soft delete already did that by itself.
$update_sql = update_post_information('forum', $forum_id, true);

				if (sizeof($update_sql))

				if (count($update_sql))

				{
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . implode(', ', $update_sql[$forum_id]);
}

				{
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . implode(', ', $update_sql[$forum_id]);
}

Line 1954Line 1968

$sql_insert_ary = array();



$sql_insert_ary = array();


		for ($i = 0, $size = sizeof($poll_ary['poll_options']); $i < $size; $i++)

		for ($i = 0, $size = count($poll_ary['poll_options']); $i < $size; $i++)

		{
if (strlen(trim($poll_ary['poll_options'][$i])))
{

		{
if (strlen(trim($poll_ary['poll_options'][$i])))
{

Line 1962Line 1976
				{
// If we add options we need to put them to the end to be able to preserve votes...
$sql_insert_ary[] = array(

				{
// If we add options we need to put them to the end to be able to preserve votes...
$sql_insert_ary[] = array(

						'poll_option_id'	=> (int) sizeof($cur_poll_options) + 1 + sizeof($sql_insert_ary),

						'poll_option_id'	=> (int) count($cur_poll_options) + 1 + count($sql_insert_ary),

						'topic_id'			=> (int) $data_ary['topic_id'],
'poll_option_text' => (string) $poll_ary['poll_options'][$i]
);

						'topic_id'			=> (int) $data_ary['topic_id'],
'poll_option_text' => (string) $poll_ary['poll_options'][$i]
);

Line 1980Line 1994

$db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary);



$db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary);


		if (sizeof($poll_ary['poll_options']) < sizeof($cur_poll_options))

		if (count($poll_ary['poll_options']) < count($cur_poll_options))

		{
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . '

		{
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . '

				WHERE poll_option_id > ' . sizeof($poll_ary['poll_options']) . '

				WHERE poll_option_id > ' . count($poll_ary['poll_options']) . '

					AND topic_id = ' . $data_ary['topic_id'];
$db->sql_query($sql);
}

// If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option

					AND topic_id = ' . $data_ary['topic_id'];
$db->sql_query($sql);
}

// If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option

		if ($mode == 'edit' && sizeof($poll_ary['poll_options']) != sizeof($cur_poll_options))

		if ($mode == 'edit' && count($poll_ary['poll_options']) != count($cur_poll_options))

		{
$db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data_ary['topic_id']);
$db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data_ary['topic_id']);

		{
$db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data_ary['topic_id']);
$db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data_ary['topic_id']);

Line 2007Line 2021
			$orphan_rows[(int) $attach_row['attach_id']] = array();
}


			$orphan_rows[(int) $attach_row['attach_id']] = array();
}


		if (sizeof($orphan_rows))

		if (count($orphan_rows))

		{
$sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . '

		{
$sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . '