class plupload

This class handles all server-side plupload functions

Properties

protected string $phpbb_root_path
protected config $config
protected request_interface $request
protected user $user
protected IniGetWrapper $php_ini
protected guesser $mimetype_guesser
protected string $upload_directory

Final destination for uploaded files, i.e. the "files" directory.

protected string $temporary_directory

Temporary upload directory for plupload uploads.

Methods

__construct(string $phpbb_root_path, config $config, request_interface $request, user $user, IniGetWrapper $php_ini, guesser $mimetype_guesser)

Constructor.

array|null
handle_upload(string $form_name)

Plupload allows for chunking so we must check for that and assemble the whole file first before performing any checks on it.

null
configure(service $cache, template $template, string $s_action, int $forum_id, int $max_files)

Fill in the plupload configuration options in the template

bool
is_active()

Checks whether the page request was sent by plupload or not

bool
is_multipart()

Returns whether the current HTTP request is a multipart request.

null
emit_error(int $code, string $msg)

Sends an error message back to the client via JSON response

string
generate_filter_string(service $cache, string $forum_id)

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

string
generate_resize_string()

Generates a string that is used to tell plupload to automatically resize files before uploading them.

int
get_chunk_size()

Checks various php.ini values to determine the maximum chunk size a file should be split into for upload.

temporary_filepath($file_name)

No description

null
integrate_uploaded_file(string $form_name, int $chunk, string $file_path)

Checks whether the chunk we are about to deal with was actually uploaded by PHP and actually exists, if not, it generates an error

null
prepare_temporary_directory()

Creates the temporary directory if it does not already exist.

null
set_default_directories()

Sets the default directories for uploads

null
set_upload_directories(string $upload_directory, string $temporary_directory)

Sets the upload directories to the specified paths

Details

at line 73
__construct(string $phpbb_root_path, config $config, request_interface $request, user $user, IniGetWrapper $php_ini, guesser $mimetype_guesser)

Constructor.

Parameters

string $phpbb_root_path
config $config
request_interface $request
user $user
IniGetWrapper $php_ini
guesser $mimetype_guesser

at line 95
array|null handle_upload(string $form_name)

Plupload allows for chunking so we must check for that and assemble the whole file first before performing any checks on it.

Parameters

string $form_name

The name of the file element in the upload form

Return Value

array|null

null if there are no chunks to piece together otherwise array containing the path to the pieced-together file and its size

at line 155
null configure(service $cache, template $template, string $s_action, int $forum_id, int $max_files)

Fill in the plupload configuration options in the template

Parameters

service $cache
template $template
string $s_action

The URL to submit the POST data to

int $forum_id

The ID of the forum

int $max_files

Maximum number of files allowed. 0 for unlimited.

Return Value

null

at line 180
bool is_active()

Checks whether the page request was sent by plupload or not

Return Value

bool

at line 190
bool is_multipart()

Returns whether the current HTTP request is a multipart request.

Return Value

bool

at line 205
null emit_error(int $code, string $msg)

Sends an error message back to the client via JSON response

Parameters

int $code

The error code

string $msg

The translation string of the message to be sent

Return Value

null

at line 227
string generate_filter_string(service $cache, string $forum_id)

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

Parameters

service $cache

Cache service object

string $forum_id

The forum identifier

Return Value

string

at line 261
string generate_resize_string()

Generates a string that is used to tell plupload to automatically resize files before uploading them.

Return Value

string

at line 293
int get_chunk_size()

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 Value

int

at line 314
protected temporary_filepath($file_name)

No description

Parameters

$file_name

at line 336
protected null integrate_uploaded_file(string $form_name, int $chunk, string $file_path)

Checks whether the chunk we are about to deal with was actually uploaded by PHP and actually exists, if not, it generates an error

Parameters

string $form_name

The name of the file in the form data

int $chunk

Chunk number

string $file_path

File path

Return Value

null

at line 383
protected null prepare_temporary_directory()

Creates the temporary directory if it does not already exist.

Return Value

null

at line 401
protected null set_default_directories()

Sets the default directories for uploads

Return Value

null

at line 415
null set_upload_directories(string $upload_directory, string $temporary_directory)

Sets the upload directories to the specified paths

Parameters

string $upload_directory

Upload directory

string $temporary_directory

Temporary directory

Return Value

null