1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20:
21:
22: include_once __DIR__ . '/admin_header.php';
23:
24: $xoops = Xoops::getInstance();
25: $errors = array();
26:
27: if (publisher_pagewrap_upload($errors)) {
28: $xoops->redirect($_POST['backto'], 2, _AM_PUBLISHER_FILEUPLOAD_SUCCESS);
29: } else {
30: $errorstxt = implode('<br />', $errors);
31: $message = sprintf(_CO_PUBLISHER_MESSAGE_FILE_ERROR, $errorstxt);
32: $xoops->redirect($_POST['backto'], 5, $message);
33: }
34:
35: function publisher_pagewrap_upload(&$errors)
36: {
37:
38: $publisher = Publisher::getInstance();
39: $post_field = 'fileupload';
40:
41: $max_size = $publisher->getConfig('maximum_filesize');
42: $max_imgwidth = $publisher->getConfig('maximum_image_width');
43: $max_imgheight = $publisher->getConfig('maximum_image_height');
44:
45: if (!is_dir(PublisherUtils::getUploadDir(true, 'content'))) {
46: mkdir(PublisherUtils::getUploadDir(true, 'content'), 0757);
47: }
48: $allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml');
49: $uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
50: if ($uploader->fetchMedia($post_field)) {
51: $uploader->setTargetFileName($uploader->getMediaName());
52: if ($uploader->upload()) {
53: return true;
54: } else {
55: $errors = array_merge($errors, $uploader->getErrors(false));
56: return false;
57: }
58:
59: } else {
60: $errors = array_merge($errors, $uploader->getErrors(false));
61: return false;
62: }
63: }
64: