| @@ 1139-1185 (lines=47) @@ | ||
| 1136 | * @param null $maxHeight |
|
| 1137 | * @return mixed True si l'upload s'est bien déroulé sinon le message d'erreur correspondant |
|
| 1138 | */ |
|
| 1139 | public static function uploadFile( |
|
| 1140 | $indice, |
|
| 1141 | $dstpath = XOOPS_UPLOAD_PATH, |
|
| 1142 | $mimeTypes = null, |
|
| 1143 | $uploadMaxSize = null, |
|
| 1144 | $maxWidth = null, |
|
| 1145 | $maxHeight = null) |
|
| 1146 | { |
|
| 1147 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 1148 | global $destname; |
|
| 1149 | if (isset($_POST['xoops_upload_file'])) { |
|
| 1150 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 1151 | $fldname = ''; |
|
| 1152 | $fldname = $_FILES[$_POST['xoops_upload_file'][$indice]]; |
|
| 1153 | $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; |
|
| 1154 | if (xoops_trim($fldname != '')) { |
|
| 1155 | $destname = static::createUploadName($dstpath, $fldname, true); |
|
| 1156 | if ($mimeTypes === null) { |
|
| 1157 | $permittedtypes = explode("\n", str_replace("\r", '', static::getModuleOption('mimetypes'))); |
|
| 1158 | array_walk($permittedtypes, 'trim'); |
|
| 1159 | } else { |
|
| 1160 | $permittedtypes = $mimeTypes; |
|
| 1161 | } |
|
| 1162 | if ($uploadMaxSize === null) { |
|
| 1163 | $uploadSize = static::getModuleOption('maxuploadsize'); |
|
| 1164 | } else { |
|
| 1165 | $uploadSize = $uploadMaxSize; |
|
| 1166 | } |
|
| 1167 | $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $uploadSize, $maxWidth, $maxHeight); |
|
| 1168 | //$uploader->allowUnknownTypes = true; |
|
| 1169 | $uploader->setTargetFileName($destname); |
|
| 1170 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][$indice])) { |
|
| 1171 | if ($uploader->upload()) { |
|
| 1172 | return true; |
|
| 1173 | } else { |
|
| 1174 | return _ERRORS . ' ' . htmlentities($uploader->getErrors()); |
|
| 1175 | } |
|
| 1176 | } else { |
|
| 1177 | return htmlentities($uploader->getErrors()); |
|
| 1178 | } |
|
| 1179 | } else { |
|
| 1180 | return false; |
|
| 1181 | } |
|
| 1182 | } else { |
|
| 1183 | return false; |
|
| 1184 | } |
|
| 1185 | } |
|
| 1186 | ||
| 1187 | /** |
|
| 1188 | * Resize a Picture to some given dimensions (using the wideImage library) |
|
| @@ 1282-1328 (lines=47) @@ | ||
| 1279 | * @param null $maxHeight |
|
| 1280 | * @return mixed True si l'upload s'est bien déroulé sinon le message d'erreur correspondant |
|
| 1281 | */ |
|
| 1282 | public static function uploadFile( |
|
| 1283 | $indice, |
|
| 1284 | $dstpath = XOOPS_UPLOAD_PATH, |
|
| 1285 | $mimeTypes = null, |
|
| 1286 | $uploadMaxSize = null, |
|
| 1287 | $maxWidth = null, |
|
| 1288 | $maxHeight = null) |
|
| 1289 | { |
|
| 1290 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 1291 | global $destname; |
|
| 1292 | if (isset($_POST['xoops_upload_file'])) { |
|
| 1293 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 1294 | $fldname = ''; |
|
| 1295 | $fldname = $_FILES[$_POST['xoops_upload_file'][$indice]]; |
|
| 1296 | $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; |
|
| 1297 | if (xoops_trim($fldname != '')) { |
|
| 1298 | $destname = self::createUploadName($dstpath, $fldname, true); |
|
| 1299 | if ($mimeTypes === null) { |
|
| 1300 | $permittedtypes = explode("\n", str_replace("\r", '', self::getModuleOption('mimetypes'))); |
|
| 1301 | array_walk($permittedtypes, 'trim'); |
|
| 1302 | } else { |
|
| 1303 | $permittedtypes = $mimeTypes; |
|
| 1304 | } |
|
| 1305 | if ($uploadMaxSize === null) { |
|
| 1306 | $uploadSize = self::getModuleOption('maxuploadsize'); |
|
| 1307 | } else { |
|
| 1308 | $uploadSize = $uploadMaxSize; |
|
| 1309 | } |
|
| 1310 | $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $uploadSize, $maxWidth, $maxHeight); |
|
| 1311 | //$uploader->allowUnknownTypes = true; |
|
| 1312 | $uploader->setTargetFileName($destname); |
|
| 1313 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][$indice])) { |
|
| 1314 | if ($uploader->upload()) { |
|
| 1315 | return true; |
|
| 1316 | } else { |
|
| 1317 | return _ERRORS . ' ' . htmlentities($uploader->getErrors()); |
|
| 1318 | } |
|
| 1319 | } else { |
|
| 1320 | return htmlentities($uploader->getErrors()); |
|
| 1321 | } |
|
| 1322 | } else { |
|
| 1323 | return false; |
|
| 1324 | } |
|
| 1325 | } else { |
|
| 1326 | return false; |
|
| 1327 | } |
|
| 1328 | } |
|
| 1329 | ||
| 1330 | /** |
|
| 1331 | * Resize a Picture to some given dimensions (using the wideImage library) |
|