2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Import progress bar backend
10 use PhpMyAdmin\Display\ImportAjax
;
12 /* PHP 5.4 stores upload progress data only in the default session.
13 * After calling session_name(), we won't find the progress data anymore.
15 * https://bugs.php.net/bug.php?id=64075
17 * The bug should be somewhere in
18 * https://github.com/php/php-src/blob/master/ext/session/session.c#L2342
20 * Until this is fixed, we need to load the default session to load the data,
21 * export the upload progress information from there,
22 * and re-import after switching to our session.
24 * However, since https://github.com/phpmyadmin/phpmyadmin/commit/063a2d99
25 * we have deactivated this feature, so the corresponding code is now
30 if (ini_get('session.upload_progress.enabled')) {
32 $sessionupload = array();
33 define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
36 foreach ($_SESSION as $key => $value) {
37 // only copy session-prefixed data
38 if (substr($key, 0, strlen(UPLOAD_PREFIX))
40 $sessionupload[$key] = $value;
43 // PMA will kill all variables, so let's use a constant
44 define('SESSIONUPLOAD', serialize($sessionupload));
45 session_write_close();
47 // The cookie name is not good anymore since PR #15273
48 session_name('phpMyAdmin');
49 session_id($_COOKIE['phpMyAdmin']);
53 define('PMA_MINIMUM_COMMON', 1);
55 require_once 'libraries/common.inc.php';
60 ) = ImportAjax
::uploadProgressSetup();
63 if (defined('SESSIONUPLOAD')) {
64 // write sessionupload back into the loaded PMA session
66 $sessionupload = unserialize(SESSIONUPLOAD);
67 foreach ($sessionupload as $key => $value) {
68 $_SESSION[$key] = $value;
71 // remove session upload data that are not set anymore
72 foreach ($_SESSION as $key => $value) {
73 if (substr($key, 0, strlen(UPLOAD_PREFIX))
75 && ! isset($sessionupload[$key])
77 unset($_SESSION[$key]);
83 // $_GET["message"] is used for asking for an import message
84 if (isset($_GET["message"]) && $_GET["message"]) {
86 // AJAX requests can't be cached!
87 Core
::noCacheHeader();
89 header('Content-type: text/html');
91 // wait 0.3 sec before we check for $_SESSION variable,
92 // which is set inside import.php
95 $maximumTime = ini_get('max_execution_time');
97 // wait until message is available
98 while ($_SESSION['Import_message']['message'] == null) {
99 // close session before sleeping
100 session_write_close();
102 usleep(250000); // 0.25 sec
106 if ((time() - $timestamp) > $maximumTime) {
107 $_SESSION['Import_message']['message'] = PhpMyAdmin\Message
::error(
108 __('Could not load the progress of the import.')
114 echo $_SESSION['Import_message']['message'];
115 echo '<fieldset class="tblFooters">' , "\n";
116 echo ' [ <a href="' , $_SESSION['Import_message']['go_back_url']
117 . '">' , __('Back') , '</a> ]' , "\n";
118 echo '</fieldset>' , "\n";
121 ImportAjax
::status($_GET["id"]);