import_status.php 2.8 KB

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