@@ 209-242 (lines=34) @@ | ||
206 | * @param string $dir |
|
207 | * @param int $redirect |
|
208 | */ |
|
209 | public static function uploadFile( |
|
210 | $allowed_mimetypes, |
|
211 | $httppostfiles, |
|
212 | $redirecturl = 'index.php', |
|
213 | $num = 0, |
|
214 | $dir = 'uploads', |
|
215 | $redirect = 0 |
|
216 | ) { |
|
217 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
218 | $myts = MyTextSanitizer::getInstance(); |
|
219 | ||
220 | global $xoopsConfig, $xoopsModuleConfig, $_POST; |
|
221 | ||
222 | $maxfilesize = (int)$xoopsModuleConfig['maxfilesize']; |
|
223 | $maxfilewidth = (int)$xoopsModuleConfig['maximgwidth']; |
|
224 | $maxfileheight = (int)$xoopsModuleConfig['maximgheight']; |
|
225 | $uploaddir = XOOPS_ROOT_PATH . '/' . $myts->htmlSpecialChars(strip_tags($dir)) . '/'; |
|
226 | ||
227 | $uploader = new XoopsMediaUploader($uploaddir, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); |
|
228 | ||
229 | if ($uploader->fetchMedia($myts->htmlSpecialChars(strip_tags($_POST['xoops_upload_file'][$num])))) { |
|
230 | if (!$uploader->upload()) { |
|
231 | $errors = $uploader->getErrors(); |
|
232 | redirect_header($redirecturl, 1, $errors); |
|
233 | } else { |
|
234 | if ($redirect) { |
|
235 | redirect_header($redirecturl, '1', 'Image Uploaded'); |
|
236 | } |
|
237 | } |
|
238 | } else { |
|
239 | $errors = $uploader->getErrors(); |
|
240 | redirect_header($redirecturl, 1, $errors); |
|
241 | } |
|
242 | } |
|
243 | ||
244 | /* |
|
245 | public static function htmlarray($thishtmlpage, $thepath) |
@@ 94-127 (lines=34) @@ | ||
91 | * @param string $dir |
|
92 | * @param int $redirect |
|
93 | */ |
|
94 | function uploading( |
|
95 | $allowed_mimetypes, |
|
96 | $httppostfiles, |
|
97 | $redirecturl = 'index.php', |
|
98 | $num = 0, |
|
99 | $dir = 'uploads', |
|
100 | $redirect = 0 |
|
101 | ) { |
|
102 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
103 | $myts = MyTextSanitizer::getInstance(); |
|
104 | ||
105 | global $xoopsConfig, $xoopsModuleConfig, $_POST; |
|
106 | ||
107 | $maxfilesize = (int)$xoopsModuleConfig['maxfilesize']; |
|
108 | $maxfilewidth = (int)$xoopsModuleConfig['maximgwidth']; |
|
109 | $maxfileheight = (int)$xoopsModuleConfig['maximgheight']; |
|
110 | $uploaddir = XOOPS_ROOT_PATH . '/' . $myts->htmlSpecialChars(strip_tags($dir)) . '/'; |
|
111 | ||
112 | $uploader = new XoopsMediaUploader($uploaddir, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); |
|
113 | ||
114 | if ($uploader->fetchMedia($myts->htmlSpecialChars(strip_tags($_POST['xoops_upload_file'][$num])))) { |
|
115 | if (!$uploader->upload()) { |
|
116 | $errors = $uploader->getErrors(); |
|
117 | redirect_header($redirecturl, 1, $errors); |
|
118 | } else { |
|
119 | if ($redirect) { |
|
120 | redirect_header($redirecturl, '1', 'Image Uploaded'); |
|
121 | } |
|
122 | } |
|
123 | } else { |
|
124 | $errors = $uploader->getErrors(); |
|
125 | redirect_header($redirecturl, 1, $errors); |
|
126 | } |
|
127 | } |
|
128 | ||
129 | /* |
|
130 | function htmlarray($thishtmlpage, $thepath) |