[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\files\types; 15 16 use bantu\IniGetWrapper\IniGetWrapper; 17 use phpbb\files\factory; 18 use phpbb\files\filespec; 19 use phpbb\language\language; 20 use phpbb\plupload\plupload; 21 use phpbb\request\request_interface; 22 23 class form extends base 24 { 25 /** @var factory Files factory */ 26 protected $factory; 27 28 /** @var language */ 29 protected $language; 30 31 /** @var IniGetWrapper */ 32 protected $php_ini; 33 34 /** @var plupload */ 35 protected $plupload; 36 37 /** @var request_interface */ 38 protected $request; 39 40 /** @var \phpbb\files\upload */ 41 protected $upload; 42 43 /** 44 * Construct a form upload type 45 * 46 * @param factory $factory Files factory 47 * @param language $language Language class 48 * @param IniGetWrapper $php_ini ini_get() wrapper 49 * @param plupload $plupload Plupload 50 * @param request_interface $request Request object 51 */ 52 public function __construct(factory $factory, language $language, IniGetWrapper $php_ini, plupload $plupload, request_interface $request) 53 { 54 $this->factory = $factory; 55 $this->language = $language; 56 $this->php_ini = $php_ini; 57 $this->plupload = $plupload; 58 $this->request = $request; 59 } 60 61 /** 62 * {@inheritdoc} 63 */ 64 public function upload() 65 { 66 $args = func_get_args(); 67 return $this->form_upload($args[0]); 68 } 69 70 /** 71 * Form upload method 72 * Upload file from users harddisk 73 * 74 * @param string $form_name Form name assigned to the file input field (if it is an array, the key has to be specified) 75 * 76 * @return filespec $file Object "filespec" is returned, all further operations can be done with this object 77 * @access public 78 */ 79 protected function form_upload($form_name) 80 { 81 $upload = $this->request->file($form_name); 82 unset($upload['local_mode']); 83 84 $result = $this->plupload->handle_upload($form_name); 85 if (is_array($result)) 86 { 87 $upload = array_merge($upload, $result); 88 } 89 90 /** @var filespec $file */ 91 $file = $this->factory->get('filespec') 92 ->set_upload_ary($upload) 93 ->set_upload_namespace($this->upload); 94 95 if ($file->init_error()) 96 { 97 $file->error[] = ''; 98 return $file; 99 } 100 101 // Error array filled? 102 if (isset($upload['error'])) 103 { 104 $error = $this->upload->assign_internal_error($upload['error']); 105 106 if ($error !== false) 107 { 108 $file->error[] = $error; 109 return $file; 110 } 111 } 112 113 // Check if empty file got uploaded (not catched by is_uploaded_file) 114 if (isset($upload['size']) && $upload['size'] == 0) 115 { 116 $file->error[] = $this->language->lang($this->upload->error_prefix . 'EMPTY_FILEUPLOAD'); 117 return $file; 118 } 119 120 // PHP Upload file size check 121 $file = $this->check_upload_size($file); 122 if (count($file->error)) 123 { 124 return $file; 125 } 126 127 // Not correctly uploaded 128 if (!$file->is_uploaded()) 129 { 130 $file->error[] = $this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED'); 131 return $file; 132 } 133 134 $this->upload->common_checks($file); 135 136 return $file; 137 } 138 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |