import_status.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Import progress bar backend
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. /* PHP 5.4 stores upload progress data only in the default session.
  9. * After calling session_name(), we won't find the progress data anymore.
  10. *
  11. * https://bugs.php.net/bug.php?id=64075
  12. *
  13. * The bug should be somewhere in
  14. * https://github.com/php/php-src/blob/master/ext/session/session.c#L2342
  15. *
  16. * Until this is fixed, we need to load the default session to load the data,
  17. * export the upload progress information from there,
  18. * and re-import after switching to our session.
  19. *
  20. * However, since https://github.com/phpmyadmin/phpmyadmin/commit/063a2d99
  21. * we have deactivated this feature, so the corresponding code is now
  22. * commented out.
  23. */
  24. /*
  25. if (version_compare(PHP_VERSION, '5.4.0', '>=')
  26. && ini_get('session.upload_progress.enabled')
  27. ) {
  28. $sessionupload = array();
  29. define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
  30. session_start();
  31. foreach ($_SESSION as $key => $value) {
  32. // only copy session-prefixed data
  33. if (substr($key, 0, strlen(UPLOAD_PREFIX)) == UPLOAD_PREFIX) {
  34. $sessionupload[$key] = $value;
  35. }
  36. }
  37. // PMA will kill all variables, so let's use a constant
  38. define('SESSIONUPLOAD', serialize($sessionupload));
  39. session_write_close();
  40. session_name('phpMyAdmin');
  41. session_id($_COOKIE['phpMyAdmin']);
  42. }
  43. */
  44. define('PMA_MINIMUM_COMMON', 1);
  45. require_once 'libraries/common.inc.php';
  46. require_once 'libraries/display_import_ajax.lib.php';
  47. /*
  48. if (defined('SESSIONUPLOAD')) {
  49. // write sessionupload back into the loaded PMA session
  50. $sessionupload = unserialize(SESSIONUPLOAD);
  51. foreach ($sessionupload as $key => $value) {
  52. $_SESSION[$key] = $value;
  53. }
  54. // remove session upload data that are not set anymore
  55. foreach ($_SESSION as $key => $value) {
  56. if (substr($key, 0, strlen(UPLOAD_PREFIX)) == UPLOAD_PREFIX
  57. && ! isset($sessionupload[$key])
  58. ) {
  59. unset($_SESSION[$key]);
  60. }
  61. }
  62. }
  63. */
  64. // AJAX requests can't be cached!
  65. PMA_noCacheHeader();
  66. // $_GET["message"] is used for asking for an import message
  67. if (isset($_GET["message"]) && $_GET["message"]) {
  68. header('Content-type: text/html');
  69. // wait 0.3 sec before we check for $_SESSION variable,
  70. // which is set inside import.php
  71. usleep(300000);
  72. // wait until message is available
  73. while ($_SESSION['Import_message']['message'] == null) {
  74. usleep(250000); // 0.25 sec
  75. }
  76. echo $_SESSION['Import_message']['message'];
  77. echo '<fieldset class="tblFooters">' . "\n";
  78. echo ' [ <a href="' . $_SESSION['Import_message']['go_back_url']
  79. . '">' . __('Back') . '</a> ]' . "\n";
  80. echo '</fieldset>' . "\n";
  81. } else {
  82. PMA_importAjaxStatus($_GET["id"]);
  83. }
  84. ?>