storage_uploader.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. $sAction = bx_process_input(bx_get('a'));
  32. switch ($sAction) {
  33. case 'show_uploader_form':
  34. header('Content-type: text/html; charset=utf-8');
  35. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  36. bx_import('BxDolLanguages');
  37. echo $oUploader->getUploaderForm($isMultiple, $iContentId, $isPrivate);
  38. break;
  39. case 'restore_ghosts':
  40. header('Content-Type: application/json; charset=utf-8');
  41. $sImagesTranscoder = bx_process_input(bx_get('img_trans'));
  42. echo $oUploader->getGhostsWithOrder((int)bx_get_logged_profile_id(), $sFormat, $sImagesTranscoder, $iContentId, $isLatest);
  43. break;
  44. case 'reorder_ghosts':
  45. header('Content-Type: application/json; charset=utf-8');
  46. $aGhosts = bx_process_input(bx_get('ghosts'));
  47. echo $oUploader->reorderGhosts((int)bx_get_logged_profile_id(), $sFormat, $aGhosts, $iContentId);
  48. break;
  49. case 'delete':
  50. header('Content-type: text/html; charset=utf-8');
  51. $iFileId = bx_process_input(bx_get('id'), BX_DATA_INT);
  52. echo $oUploader->deleteGhost($iFileId, bx_get_logged_profile_id());
  53. break;
  54. case 'upload':
  55. header('Content-type: text/html; charset=utf-8');
  56. bx_import('BxDolLanguages');
  57. $oUploader->handleUploads(bx_get_logged_profile_id(), isset($_FILES['f']) ? $_FILES['f'] : null, $isMultiple, $iContentId, $isPrivate);
  58. break;
  59. }
  60. /** @} */