2 /* vim: set expandtab sw=4 ts=4 sts=4: */
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.
11 * The bug should be somewhere in
12 * https://github.com/php/php-src/blob/master/ext/session/session.c#L2342
14 * Until this is fixed, we need to load the default session to load the data.
15 * As we cannot load the phpMyAdmin-session after that, we will try to do
16 * an internal POST request to call ourselves in a new instance.
17 * That POST request grabs the transmitted upload data and stores them.
19 * TODO: The internal HTTP request may fail if the DNS name cannot be resolved
20 * or if a firewall blocks outgoing requests on the used port.
23 if (version_compare(PHP_VERSION
, '5.4.0', '>=')
24 && ini_get('session.upload_progress.enabled')
27 $sessionupload = array();
28 define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
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;
37 // PMA will kill all variables, so let's use a constant
38 define('SESSIONUPLOAD', serialize($sessionupload));
39 session_write_close();
41 session_name('phpMyAdmin');
42 session_id($_COOKIE['phpMyAdmin']);
45 define('PMA_MINIMUM_COMMON', 1);
47 require_once 'libraries/common.inc.php';
48 require_once 'libraries/display_import_ajax.lib.php';
50 if (defined('SESSIONUPLOAD')) {
51 // write sessionupload back into the loaded PMA session
53 $sessionupload = unserialize(SESSIONUPLOAD
);
54 foreach ($sessionupload as $key => $value) {
55 $_SESSION[$key] = $value;
58 // remove session upload data that are not set anymore
59 foreach ($_SESSION as $key => $value) {
60 if (substr($key, 0, strlen(UPLOAD_PREFIX
)) == UPLOAD_PREFIX
61 && ! isset($sessionupload[$key])
63 unset($_SESSION[$key]);
69 * Sets globals from $_GET
75 foreach ($get_params as $one_get_param) {
76 if (isset($_GET[$one_get_param])) {
77 $GLOBALS[$one_get_param] = $_GET[$one_get_param];
81 // AJAX requests can't be cached!
84 // $GLOBALS["message"] is used for asking for an import message
85 if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
87 header('Content-type: text/html');
89 // wait 0.3 sec before we check for $_SESSION variable,
90 // which is set inside import.php
93 // wait until message is available
94 while ($_SESSION['Import_message']['message'] == null) {
95 usleep(250000); // 0.25 sec
98 echo $_SESSION['Import_message']['message'];
99 echo '<fieldset class="tblFooters">' . "\n";
100 echo ' [ <a href="' . $_SESSION['Import_message']['go_back_url']
101 . '">' . __('Back') . '</a> ]' . "\n";
102 echo '</fieldset>'."\n";
105 PMA_importAjaxStatus($GLOBALS["id"]);