@@ -33,6 +33,11 @@ class upload extends \phpbb\avatar\driver\driver
3333 */
3434 protected $ dispatcher ;
3535
36+ /**
37+ * @var \phpbb\files\factory
38+ */
39+ protected $ files_factory ;
40+
3641 /**
3742 * Construct a driver object
3843 *
@@ -43,9 +48,10 @@ class upload extends \phpbb\avatar\driver\driver
4348 * @param \phpbb\path_helper $path_helper phpBB path helper
4449 * @param \phpbb\mimetype\guesser $mimetype_guesser Mimetype guesser
4550 * @param \phpbb\event\dispatcher_interface $dispatcher phpBB Event dispatcher object
51+ * @param \phpbb\files\factory $files_factory File classes factory
4652 * @param \phpbb\cache\driver\driver_interface $cache Cache driver
4753 */
48- public function __construct (\phpbb \config \config $ config , $ phpbb_root_path , $ php_ext , \phpbb \filesystem \filesystem_interface $ filesystem , \phpbb \path_helper $ path_helper , \phpbb \mimetype \guesser $ mimetype_guesser , \phpbb \event \dispatcher_interface $ dispatcher , \phpbb \cache \driver \driver_interface $ cache = null )
54+ public function __construct (\phpbb \config \config $ config , $ phpbb_root_path , $ php_ext , \phpbb \filesystem \filesystem_interface $ filesystem , \phpbb \path_helper $ path_helper , \phpbb \mimetype \guesser $ mimetype_guesser , \phpbb \event \dispatcher_interface $ dispatcher , \phpbb \files \ factory $ files_factory , \ phpbb \ cache \driver \driver_interface $ cache = null )
4955 {
5056 $ this ->config = $ config ;
5157 $ this ->phpbb_root_path = $ phpbb_root_path ;
@@ -54,6 +60,7 @@ public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php
5460 $ this ->path_helper = $ path_helper ;
5561 $ this ->mimetype_guesser = $ mimetype_guesser ;
5662 $ this ->dispatcher = $ dispatcher ;
63+ $ this ->files_factory = $ files_factory ;
5764 $ this ->cache = $ cache ;
5865 }
5966
@@ -99,12 +106,17 @@ public function process_form($request, $template, $user, $row, &$error)
99106 return false ;
100107 }
101108
102- if (!class_exists ('fileupload ' ))
103- {
104- include ($ this ->phpbb_root_path . 'includes/functions_upload. ' . $ this ->php_ext );
105- }
106-
107- $ upload = new \fileupload ($ this ->filesystem , '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 ));
109+ /** @var \phpbb\files\upload $upload */
110+ $ upload = $ this ->files_factory ->get ('upload ' )
111+ ->set_error_prefix ('AVATAR_ ' )
112+ ->set_allowed_extensions ($ this ->allowed_extensions )
113+ ->set_max_filesize ($ this ->config ['avatar_filesize ' ])
114+ ->set_allowed_dimensions (
115+ $ this ->config ['avatar_min_width ' ],
116+ $ this ->config ['avatar_min_height ' ],
117+ $ this ->config ['avatar_max_width ' ],
118+ $ this ->config ['avatar_max_height ' ])
119+ ->set_disallowed_content ((isset ($ this ->config ['mime_triggers ' ]) ? explode ('| ' , $ this ->config ['mime_triggers ' ]) : false ));
108120
109121 $ url = $ request ->variable ('avatar_upload_url ' , '' );
110122 $ upload_file = $ request ->file ('avatar_upload_file ' );
0 commit comments