UploadNoplugin.php 1.2 KB

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