UploadNoplugin.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Provides upload functionalities for the import plugins
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. declare(strict_types=1);
  9. namespace PhpMyAdmin\Plugins\Import\Upload;
  10. use PhpMyAdmin\Plugins\UploadInterface;
  11. /**
  12. * Implementation for no plugin
  13. *
  14. * @package PhpMyAdmin
  15. */
  16. class UploadNoplugin implements UploadInterface
  17. {
  18. /**
  19. * Gets the specific upload ID Key
  20. *
  21. * @return string ID Key
  22. */
  23. public static function getIdKey()
  24. {
  25. return 'noplugin';
  26. }
  27. /**
  28. * Returns upload status.
  29. *
  30. * This is implementation when no webserver support exists,
  31. * so it returns just zeroes.
  32. *
  33. * @param string $id upload id
  34. *
  35. * @return array|null
  36. */
  37. public static function getUploadStatus($id)
  38. {
  39. global $SESSION_KEY;
  40. if (trim($id) == "") {
  41. return null;
  42. }
  43. if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
  44. $_SESSION[$SESSION_KEY][$id] = [
  45. 'id' => $id,
  46. 'finished' => false,
  47. 'percent' => 0,
  48. 'total' => 0,
  49. 'complete' => 0,
  50. 'plugin' => UploadNoplugin::getIdKey(),
  51. ];
  52. }
  53. return $_SESSION[$SESSION_KEY][$id];
  54. }
  55. }