phpBB

Code Changes

File: phpbb/plupload/plupload.php

  Unmodified   Added   Modified   Removed
Line 219Line 219
	* Looks at the list of allowed extensions and generates a string
* appropriate for use in configuring plupload with
*

	* Looks at the list of allowed extensions and generates a string
* appropriate for use in configuring plupload with
*

	* @param \phpbb\cache\service $cache
* @param string $forum_id The ID of the forum

	 * @param \phpbb\cache\service	$cache		Cache service object
* @param string $forum_id The forum identifier

	*
* @return string
*/
public function generate_filter_string(\phpbb\cache\service $cache, $forum_id)
{

	*
* @return string
*/
public function generate_filter_string(\phpbb\cache\service $cache, $forum_id)
{

 
		$groups = [];
$filters = [];


		$attach_extensions = $cache->obtain_attach_extensions($forum_id);
unset($attach_extensions['_allowed_']);

		$attach_extensions = $cache->obtain_attach_extensions($forum_id);
unset($attach_extensions['_allowed_']);

		$groups = array();

 

// Re-arrange the extension array to $groups[$group_name][]
foreach ($attach_extensions as $extension => $extension_info)
{


// Re-arrange the extension array to $groups[$group_name][]
foreach ($attach_extensions as $extension => $extension_info)
{

			if (!isset($groups[$extension_info['group_name']]))
{
$groups[$extension_info['group_name']] = array();

			$groups[$extension_info['group_name']]['extensions'][] = $extension;
$groups[$extension_info['group_name']]['max_file_size'] = (int) $extension_info['max_filesize'];


			}


			}


			$groups[$extension_info['group_name']][] = $extension;
}

$filters = array();
foreach ($groups as $group => $extensions)

		foreach ($groups as $group => $group_info)





		{
$filters[] = sprintf(

		{
$filters[] = sprintf(

				"{title: '%s', extensions: '%s'}",

				"{title: '%s', extensions: '%s', max_file_size: %s}",

				addslashes(ucfirst(strtolower($group))),

				addslashes(ucfirst(strtolower($group))),

				addslashes(implode(',', $extensions))


				addslashes(implode(',', $group_info['extensions'])),
$group_info['max_file_size']

			);
}


			);
}


Line 276Line 274
	}

/**

	}

/**

	* Checks various php.ini values and the maximum file size to determine
* the maximum size chunks a file can be split up into for upload







	 * Checks various php.ini values to determine the maximum chunk
* size a file should be split into for upload.
*
* The intention is to calculate a value which reflects whatever
* the most restrictive limit is set to. And to then set the chunk
* size to half that value, to ensure any required transfer overhead
* and POST data remains well within the limit. Or, if all of the
* limits are set to unlimited, the chunk size will also be unlimited.

	*
* @return int

	*
* @return int

 
	 *
* @access public

	*/
public function get_chunk_size()
{

	*/
public function get_chunk_size()
{

		$max = min(




		$max = 0;

$limits = [
$this->php_ini->getBytes('memory_limit'),

			$this->php_ini->getBytes('upload_max_filesize'),
$this->php_ini->getBytes('post_max_size'),

			$this->php_ini->getBytes('upload_max_filesize'),
$this->php_ini->getBytes('post_max_size'),

			max(1, $this->php_ini->getBytes('memory_limit')),
$this->config['max_filesize']
);







		];

foreach ($limits as $limit_type)
{
if ($limit_type > 0)
{
$max = ($max !== 0) ? min($limit_type, $max) : $limit_type;
}
}





		// Use half of the maximum possible to leave plenty of room for other
// POST data.

 
		return floor($max / 2);
}


		return floor($max / 2);
}