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