storage_uploader.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. require_once('./inc/header.inc.php');
  10. $sUploaderObject = bx_process_input(bx_get('uo'));
  11. $sStorageObject = bx_process_input(bx_get('so'));
  12. $sUniqId = preg_match("/^[\d\w]+$/", bx_get('uid')) ? bx_get('uid') : '';
  13. $isMultiple = bx_get('m') ? true : false;
  14. $isLatest = bx_get('l') ? true : false;
  15. $sFormat = bx_process_input(bx_get('f'));
  16. if ($sFormat != 'html' && $sFormat != 'json')
  17. $sFormat = 'html';
  18. $iContentId = bx_get('c');
  19. if (false === $iContentId || '' === $iContentId)
  20. $iContentId = false;
  21. else
  22. $iContentId = bx_process_input($iContentId, BX_DATA_INT);
  23. if (!$sUploaderObject || !$sStorageObject || !$sUniqId)
  24. exit;
  25. $isPrivate = (int)bx_get('p') ? 1 : 0;
  26. $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $sStorageObject, $sUniqId);
  27. if (!$oUploader) {
  28. // no such uploader available
  29. exit;
  30. }
  31. if(($bM = bx_get('m')) !== false)
  32. $oUploader->setMultiple((bool)$bM);
  33. $sAction = bx_process_input(bx_get('a'));
  34. switch ($sAction) {
  35. case 'show_uploader_form':
  36. header('Content-type: text/html; charset=utf-8');
  37. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  38. bx_import('BxDolLanguages');
  39. echo $oUploader->getUploaderForm($isMultiple, $iContentId, $isPrivate);
  40. break;
  41. case 'restore_ghosts':
  42. header('Content-Type: application/json; charset=utf-8');
  43. $sImagesTranscoder = bx_process_input(bx_get('img_trans'));
  44. echo $oUploader->getGhostsWithOrder((int)bx_get_logged_profile_id(), $sFormat, $sImagesTranscoder, $iContentId, $isLatest);
  45. break;
  46. case 'reorder_ghosts':
  47. header('Content-Type: application/json; charset=utf-8');
  48. $aGhosts = bx_process_input(bx_get('ghosts'));
  49. echo $oUploader->reorderGhosts((int)bx_get_logged_profile_id(), $sFormat, $aGhosts, $iContentId);
  50. break;
  51. case 'delete':
  52. header('Content-type: text/html; charset=utf-8');
  53. $iFileId = bx_process_input(bx_get('id'), BX_DATA_INT);
  54. echo $oUploader->deleteGhost($iFileId, bx_get_logged_profile_id());
  55. break;
  56. case 'upload':
  57. header('Content-type: text/html; charset=utf-8');
  58. bx_import('BxDolLanguages');
  59. $oUploader->handleUploads(bx_get_logged_profile_id(), isset($_FILES['f']) ? $_FILES['f'] : null, $isMultiple, $iContentId, $isPrivate);
  60. break;
  61. }
  62. /** @} */