phpBB

Code Changes

File: phpbb/avatar/driver/upload.php

  Unmodified   Added   Modified   Removed
Line 19Line 19
class upload extends \phpbb\avatar\driver\driver
{
/**

class upload extends \phpbb\avatar\driver\driver
{
/**

	* @var \phpbb\mimetype\guesser

	 * @var \phpbb\filesystem\filesystem_interface

	*/

	*/

	protected $mimetype_guesser;

	protected $filesystem;


/**
* @var \phpbb\event\dispatcher_interface
*/
protected $dispatcher;


/**
* @var \phpbb\event\dispatcher_interface
*/
protected $dispatcher;

 

/**
* @var \phpbb\files\factory
*/
protected $files_factory;


/**
* Construct a driver object


/**
* Construct a driver object

Line 34Line 39
	* @param \phpbb\config\config $config phpBB configuration
* @param string $phpbb_root_path Path to the phpBB root
* @param string $php_ext PHP file extension

	* @param \phpbb\config\config $config phpBB configuration
* @param string $phpbb_root_path Path to the phpBB root
* @param string $php_ext PHP file extension

	* @param \phpbb_path_helper $path_helper phpBB path helper
* @param \phpbb\mimetype\guesser $mimetype_guesser Mimetype guesser

	* @param \phpbb\filesystem\filesystem_interface $filesystem phpBB filesystem helper
* @param \phpbb\path_helper $path_helper phpBB path helper

	* @param \phpbb\event\dispatcher_interface $dispatcher phpBB Event dispatcher object

	* @param \phpbb\event\dispatcher_interface $dispatcher phpBB Event dispatcher object

 
	* @param \phpbb\files\factory $files_factory File classes factory

	* @param \phpbb\cache\driver\driver_interface $cache Cache driver
*/

	* @param \phpbb\cache\driver\driver_interface $cache Cache driver
*/

	public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\mimetype\guesser $mimetype_guesser, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\cache\driver\driver_interface $cache = null)

	public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\filesystem\filesystem_interface $filesystem, \phpbb\path_helper $path_helper, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\files\factory $files_factory, \phpbb\cache\driver\driver_interface $cache = null)

	{
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;

	{
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;

 
		$this->filesystem = $filesystem;

		$this->path_helper = $path_helper;

		$this->path_helper = $path_helper;

		$this->mimetype_guesser = $mimetype_guesser;

 
		$this->dispatcher = $dispatcher;

		$this->dispatcher = $dispatcher;

 
		$this->files_factory = $files_factory;

		$this->cache = $cache;
}


		$this->cache = $cache;
}


Line 92Line 99
			return false;
}


			return false;
}


		if (!class_exists('fileupload'))
{
include($this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext);
}

$upload = new \fileupload('AVATAR_', $this->allowed_extensions, $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false));






		/** @var \phpbb\files\upload $upload */
$upload = $this->files_factory->get('upload')
->set_error_prefix('AVATAR_')
->set_allowed_extensions($this->allowed_extensions)
->set_max_filesize($this->config['avatar_filesize'])
->set_allowed_dimensions(
$this->config['avatar_min_width'],
$this->config['avatar_min_height'],
$this->config['avatar_max_width'],
$this->config['avatar_max_height'])
->set_disallowed_content((isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false));


$url = $request->variable('avatar_upload_url', '');
$upload_file = $request->file('avatar_upload_file');

if (!empty($upload_file['name']))
{


$url = $request->variable('avatar_upload_url', '');
$upload_file = $request->file('avatar_upload_file');

if (!empty($upload_file['name']))
{

			$file = $upload->form_upload('avatar_upload_file', $this->mimetype_guesser);

			$file = $upload->handle_upload('files.types.form', 'avatar_upload_file');

		}
else if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url))
{

		}
else if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url))
{

Line 134Line 146
				return false;
}


				return false;
}


			$file = $upload->remote_upload($url, $this->mimetype_guesser);

			$file = $upload->handle_upload('files.types.remote', $url);

		}
else
{

		}
else
{

Line 166Line 178
		{
$destination = '';
}

		{
$destination = '';
}

 

$filedata = array(
'filename' => $file->get('filename'),
'filesize' => $file->get('filesize'),
'mimetype' => $file->get('mimetype'),
'extension' => $file->get('extension'),
'physical_filename' => $file->get('realname'),
'real_filename' => $file->get('uploadname'),
);


/**
* Before moving new file in place (and eventually overwriting the existing avatar with the newly uploaded avatar)
*
* @event core.avatar_driver_upload_move_file_before


/**
* Before moving new file in place (and eventually overwriting the existing avatar with the newly uploaded avatar)
*
* @event core.avatar_driver_upload_move_file_before

 
		* @var	array	filedata			Array containing uploaded file data

		* @var	string	destination			Destination directory where the file is going to be moved
* @var string prefix Prefix for the avatar filename
* @var array row Array with avatar row data
* @var array error Array of errors, if filled in by this event file will not be moved
* @since 3.1.6-RC1

		* @var	string	destination			Destination directory where the file is going to be moved
* @var string prefix Prefix for the avatar filename
* @var array row Array with avatar row data
* @var array error Array of errors, if filled in by this event file will not be moved
* @since 3.1.6-RC1

 
		* @changed 3.1.9-RC1 Added filedata

		*/
$vars = array(

		*/
$vars = array(

 
			'filedata',

			'destination',
'prefix',
'row',
'error',
);
extract($this->dispatcher->trigger_event('core.avatar_driver_upload_move_file_before', compact($vars)));

			'destination',
'prefix',
'row',
'error',
);
extract($this->dispatcher->trigger_event('core.avatar_driver_upload_move_file_before', compact($vars)));

 

unset($filedata);


if (!sizeof($error))
{


if (!sizeof($error))
{

Line 278Line 304
	*/
protected function can_upload()
{

	*/
protected function can_upload()
{

		return (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on'));

		return (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && $this->filesystem->is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on'));

	}
}


	}
}