storage_uploader.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 = bx_process_input(bx_get('uid'));
  13. $isMultiple = bx_get('m') ? true : false;
  14. $sFormat = bx_process_input(bx_get('f'));
  15. if ($sFormat != 'html' && $sFormat != 'json')
  16. $sFormat = 'html';
  17. $iContentId = bx_get('c');
  18. if (false === $iContentId || '' === $iContentId)
  19. $iContentId = false;
  20. else
  21. $iContentId = bx_process_input($iContentId, BX_DATA_INT);
  22. if (!$sUploaderObject || !$sStorageObject || !$sUniqId)
  23. exit;
  24. $isPrivate = (int)bx_get('p') ? 1 : 0;
  25. $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $sStorageObject, $sUniqId);
  26. if (!$oUploader) {
  27. // no such uploader available
  28. exit;
  29. }
  30. $sAction = bx_process_input(bx_get('a'));
  31. switch ($sAction) {
  32. case 'show_uploader_form':
  33. header('Content-type: text/html; charset=utf-8');
  34. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  35. bx_import('BxDolLanguages');
  36. echo $oUploader->getUploaderForm($isMultiple, $iContentId, $isPrivate);
  37. break;
  38. case 'restore_ghosts':
  39. header('Content-Type: application/json; charset=utf-8');
  40. $sImagesTranscoder = bx_process_input(bx_get('img_trans'));
  41. echo $oUploader->getGhostsWithOrder((int)bx_get_logged_profile_id(), $sFormat, $sImagesTranscoder, $iContentId);
  42. break;
  43. case 'reorder_ghosts':
  44. header('Content-Type: application/json; charset=utf-8');
  45. $aGhosts = bx_process_input(bx_get('ghosts'));
  46. echo $oUploader->reorderGhosts((int)bx_get_logged_profile_id(), $sFormat, $aGhosts, $iContentId);
  47. break;
  48. case 'delete':
  49. header('Content-type: text/html; charset=utf-8');
  50. $iFileId = bx_process_input(bx_get('id'), BX_DATA_INT);
  51. echo $oUploader->deleteGhost($iFileId, bx_get_logged_profile_id());
  52. break;
  53. case 'upload':
  54. header('Content-type: text/html; charset=utf-8');
  55. bx_import('BxDolLanguages');
  56. $oUploader->handleUploads(bx_get_logged_profile_id(), isset($_FILES['f']) ? $_FILES['f'] : null, $isMultiple, $iContentId, $isPrivate);
  57. break;
  58. }
  59. /** @} */