phpBB

Code Changes

File: includes/functions_posting.php

  Unmodified   Added   Modified   Removed
Line 52Line 52

page_header($user->lang['SMILIES']);



page_header($user->lang['SMILIES']);


		$sql = 'SELECT COUNT(smiley_id) AS item_count
FROM ' . SMILIES_TABLE . '
GROUP BY smiley_url';
























		$sql_ary = [
'SELECT' => 'COUNT(s.smiley_id) AS item_count',
'FROM' => [
SMILIES_TABLE => 's',
],
'GROUP_BY' => 's.smiley_url',
];

/**
* Modify SQL query that fetches the total number of smilies in window mode
*
* @event core.generate_smilies_count_sql_before
* @var int forum_id Forum where smilies are generated
* @var array sql_ary Array with the SQL query
* @var string base_url URL for the "More smilies" link and its pagination
* @since 3.2.9-RC1
* @changed 3.2.10-RC1 Added base_url
*/
$vars = [
'forum_id',
'sql_ary',
'base_url',
];
extract($phpbb_dispatcher->trigger_event('core.generate_smilies_count_sql_before', compact($vars)));

$sql = $db->sql_build_query('SELECT', $sql_ary);

		$result = $db->sql_query($sql, 3600);

$smiley_count = 0;

		$result = $db->sql_query($sql, 3600);

$smiley_count = 0;

Line 89Line 112

if ($mode == 'window')
{


if ($mode == 'window')
{

		$sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height, MIN(smiley_order) AS min_smiley_order
FROM ' . SMILIES_TABLE . '
GROUP BY smiley_url, smiley_width, smiley_height
ORDER BY min_smiley_order';







































		$sql_ary = [
'SELECT' => 's.smiley_url, MIN(s.emotion) AS emotion, MIN(s.code) AS code, s.smiley_width, s.smiley_height, MIN(s.smiley_order) AS min_smiley_order',
'FROM' => [
SMILIES_TABLE => 's',
],
'GROUP_BY' => 's.smiley_url, s.smiley_width, s.smiley_height',
'ORDER_BY' => 'min_smiley_order',
];
}
else
{
$sql_ary = [
'SELECT' => 's.*',
'FROM' => [
SMILIES_TABLE => 's',
],
'WHERE' => 's.display_on_posting = 1',
'ORDER_BY' => 's.smiley_order',
];
}

/**
* Modify the SQL query that fetches the smilies
*
* @event core.generate_smilies_modify_sql
* @var string mode Smiley mode, either window or inline
* @var int forum_id Forum where smilies are generated, or 0 if composing a private message
* @var array sql_ary Array with SQL query data
* @since 3.2.10-RC1
* @since 3.3.1-RC1
*/
$vars = [
'mode',
'forum_id',
'sql_ary',
];
extract($phpbb_dispatcher->trigger_event('core.generate_smilies_modify_sql', compact($vars)));

$sql = $db->sql_build_query('SELECT', $sql_ary);

if ($mode == 'window')
{

		$result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600);
}
else
{

		$result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600);
}
else
{

		$sql = 'SELECT *
FROM ' . SMILIES_TABLE . '
WHERE display_on_posting = 1
ORDER BY smiley_order';

 
		$result = $db->sql_query($sql, 3600);
}


		$result = $db->sql_query($sql, 3600);
}


Line 113Line 170
		}
}
$db->sql_freeresult($result);

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

 

/**
* Modify smilies before they are assigned to the template
*
* @event core.generate_smilies_modify_rowset
* @var string mode Smiley mode, either window or inline
* @var int forum_id Forum where smilies are generated, or 0 if composing a private message
* @var array smilies Smiley rows fetched from the database
* @since 3.2.9-RC1
*/
$vars = [
'mode',
'forum_id',
'smilies',
];
extract($phpbb_dispatcher->trigger_event('core.generate_smilies_modify_rowset', compact($vars)));


if (count($smilies))
{


if (count($smilies))
{

Line 147Line 220
	* @var	string	mode			Mode of the smilies: window|inline
* @var int forum_id The forum ID we are currently in
* @var bool display_link Shall we display the "more smilies" link?

	* @var	string	mode			Mode of the smilies: window|inline
* @var int forum_id The forum ID we are currently in
* @var bool display_link Shall we display the "more smilies" link?

 
	* @var string	base_url		URL for the "More smilies" link and its pagination

	* @since 3.1.0-a1

	* @since 3.1.0-a1

 
	* @changed 3.2.10-RC1 Added base_url

	*/

	*/

	$vars = array('mode', 'forum_id', 'display_link');






	$vars = [
'mode',
'forum_id',
'display_link',
'base_url',
];

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

if ($mode == 'inline' && $display_link)

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

if ($mode == 'inline' && $display_link)

Line 202Line 282

if (count($ids) == 1)
{


if (count($ids) == 1)
{

		$sql = 'SELECT MAX(p.post_id) as last_post_id

		$sql = 'SELECT p.post_id as last_post_id

			FROM ' . POSTS_TABLE . " p $topic_join
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
$topic_condition

			FROM ' . POSTS_TABLE . " p $topic_join
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
$topic_condition

				AND p.post_visibility = " . ITEM_APPROVED;



				AND p.post_visibility = " . ITEM_APPROVED . "
ORDER BY p.post_id DESC";
$result = $db->sql_query_limit($sql, 1);

	}
else
{

	}
else
{

Line 216Line 298
				$topic_condition
AND p.post_visibility = " . ITEM_APPROVED . "
GROUP BY p.{$type}_id";

				$topic_condition
AND p.post_visibility = " . ITEM_APPROVED . "
GROUP BY p.{$type}_id";

	}

 
	$result = $db->sql_query($sql);

	$result = $db->sql_query($sql);

 
	}


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


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

Line 519Line 601
*/
function create_thumbnail($source, $destination, $mimetype)
{

*/
function create_thumbnail($source, $destination, $mimetype)
{

	global $config, $phpbb_filesystem;

	global $config, $phpbb_filesystem, $phpbb_dispatcher;


$min_filesize = (int) $config['img_min_thumb_filesize'];
$img_filesize = (file_exists($source)) ? @filesize($source) : false;


$min_filesize = (int) $config['img_min_thumb_filesize'];
$img_filesize = (file_exists($source)) ? @filesize($source) : false;

Line 551Line 633
		return false;
}


		return false;
}


	$used_imagick = false;

	$thumbnail_created = false;





	// Only use ImageMagick if defined and the passthru function not disabled
if ($config['img_imagick'] && function_exists('passthru'))
{
if (substr($config['img_imagick'], -1) !== '/')
{
$config['img_imagick'] .= '/';
}

@passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');

if (file_exists($destination))
{
$used_imagick = true;
}
}







	/**
* Create thumbnail event to replace GD thumbnail creation with for example ImageMagick
*
* @event core.thumbnail_create_before
* @var string source Image source path
* @var string destination Thumbnail destination path
* @var string mimetype Image mime type
* @var float new_width Calculated thumbnail width
* @var float new_height Calculated thumbnail height
* @var bool thumbnail_created Set to true to skip default GD thumbnail creation
* @since 3.2.4
*/
$vars = array(
'source',
'destination',
'mimetype',
'new_width',
'new_height',
'thumbnail_created',
);
extract($phpbb_dispatcher->trigger_event('core.thumbnail_create_before', compact($vars)));





	if (!$used_imagick)

	if (!$thumbnail_created)

	{
$type = get_supported_image_types($type);


	{
$type = get_supported_image_types($type);


Line 673Line 761

try
{


try
{

		$phpbb_filesystem->phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE);

		$phpbb_filesystem->phpbb_chmod($destination, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE);

	}
catch (\phpbb\filesystem\exception\filesystem_exception $e)
{

	}
catch (\phpbb\filesystem\exception\filesystem_exception $e)
{

Line 726Line 814
	{
// 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);

 

$attachrow_template_vars = [];


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 968Line 1057
		'WHERE'		=> $db->sql_in_set('p.post_id', $post_list) . '
AND u.user_id = p.poster_id',
);

		'WHERE'		=> $db->sql_in_set('p.post_id', $post_list) . '
AND u.user_id = p.poster_id',
);

 

/**
* Event to modify the SQL query for topic reviews
*
* @event core.topic_review_modify_sql_ary
* @var int topic_id The topic ID that is being reviewed
* @var int forum_id The topic's forum ID
* @var string mode The topic review mode
* @var int cur_post_id Post offset ID
* @var bool show_quote_button Flag indicating if the quote button should be displayed
* @var array post_list Array with the post IDs
* @var array sql_ary Array with the SQL query
* @since 3.2.8-RC1
*/
$vars = array(
'topic_id',
'forum_id',
'mode',
'cur_post_id',
'show_quote_button',
'post_list',
'sql_ary',
);
extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_sql_ary', compact($vars)));


$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);


$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);

Line 1275Line 1388
				delete_topics('topic_id', array($topic_id), false);

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

				delete_topics('topic_id', array($topic_id), false);

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

 
				$config->increment('num_posts', -1, false);


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


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

Line 2043Line 2157
			if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']]))
{
continue;

			if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']]))
{
continue;

 
			}

if (preg_match('/[\x{10000}-\x{10FFFF}]/u', $attach_row['attach_comment']))
{
trigger_error('ATTACH_COMMENT_NO_EMOJIS');

			}

if (!$attach_row['is_orphan'])

			}

if (!$attach_row['is_orphan'])

Line 2280Line 2399
		'post_time'			=> $current_time,
'post_subject' => $subject,
));

		'post_time'			=> $current_time,
'post_subject' => $subject,
));

 

/**
* This event allows you to modify the notification data upon submission
*
* @event core.modify_submit_notification_data
* @var array notification_data The notification data to be inserted in to the database
* @var array data_ary The data array with a lot of the post submission data
* @var string mode The posting mode
* @var int poster_id The poster id
* @since 3.2.4-RC1
*/
$vars = array('notification_data', 'data_ary', 'mode', 'poster_id');
extract($phpbb_dispatcher->trigger_event('core.modify_submit_notification_data', compact($vars)));


/* @var $phpbb_notifications \phpbb\notification\manager */
$phpbb_notifications = $phpbb_container->get('notification_manager');


/* @var $phpbb_notifications \phpbb\notification\manager */
$phpbb_notifications = $phpbb_container->get('notification_manager');

Line 2308Line 2440
			case 'edit_first_post':
case 'edit':
case 'edit_last_post':

			case 'edit_first_post':
case 'edit':
case 'edit_last_post':

 
				if ($user->data['user_id'] == $poster_id)
{

				$phpbb_notifications->update_notifications(array(
'notification.type.quote',

				$phpbb_notifications->update_notifications(array(
'notification.type.quote',

 
					), $notification_data);
}

$phpbb_notifications->update_notifications(array(

					'notification.type.bookmark',
'notification.type.topic',
'notification.type.post',

					'notification.type.bookmark',
'notification.type.topic',
'notification.type.post',

Line 2725Line 2863
				$s_hidden_fields['delete_permanent'] = '1';
}


				$s_hidden_fields['delete_permanent'] = '1';
}


			confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html');

			confirm_box(false, [$l_confirm, 1], build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html');

		}
}


		}
}