Some fixes in phpgacl to work with php 5.4
[openemr.git] / phpmyadmin / import_status.php
blobe46b24319b8fcfbd5d849f2368b3f0d07a89ad28
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.
21 * However, since https://github.com/phpmyadmin/phpmyadmin/commit/063a2d99
22 * we have deactivated this feature, so the corresponding code is now
23 * commented out.
27 if (version_compare(PHP_VERSION, '5.4.0', '>=')
28 && ini_get('session.upload_progress.enabled')
29 ) {
31 $sessionupload = array();
32 define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
34 session_start();
35 foreach ($_SESSION as $key => $value) {
36 // only copy session-prefixed data
37 if (mb_substr($key, 0, mb_strlen(UPLOAD_PREFIX))
38 == UPLOAD_PREFIX) {
39 $sessionupload[$key] = $value;
42 // PMA will kill all variables, so let's use a constant
43 define('SESSIONUPLOAD', serialize($sessionupload));
44 session_write_close();
46 session_name('phpMyAdmin');
47 session_id($_COOKIE['phpMyAdmin']);
51 define('PMA_MINIMUM_COMMON', 1);
53 require_once 'libraries/common.inc.php';
54 require_once 'libraries/Util.class.php';
55 require_once 'libraries/display_import_ajax.lib.php';
58 if (defined('SESSIONUPLOAD')) {
59 // write sessionupload back into the loaded PMA session
61 $sessionupload = unserialize(SESSIONUPLOAD);
62 foreach ($sessionupload as $key => $value) {
63 $_SESSION[$key] = $value;
66 // remove session upload data that are not set anymore
67 foreach ($_SESSION as $key => $value) {
68 if (mb_substr($key, 0, mb_strlen(UPLOAD_PREFIX))
69 == UPLOAD_PREFIX
70 && ! isset($sessionupload[$key])
71 ) {
72 unset($_SESSION[$key]);
78 // $_GET["message"] is used for asking for an import message
79 if (isset($_GET["message"]) && $_GET["message"]) {
81 // AJAX requests can't be cached!
82 PMA_noCacheHeader();
84 header('Content-type: text/html');
86 // wait 0.3 sec before we check for $_SESSION variable,
87 // which is set inside import.php
88 usleep(300000);
90 $maximumTime = ini_get('max_execution_time');
91 $timestamp = time();
92 // wait until message is available
93 while ($_SESSION['Import_message']['message'] == null) {
94 // close session before sleeping
95 session_write_close();
96 // sleep
97 usleep(250000); // 0.25 sec
98 // reopen session
99 session_start();
101 if ((time() - $timestamp) > $maximumTime) {
102 $_SESSION['Import_message']['message'] = PMA_Message::error(
103 __('Could not load the progress of the import.')
104 )->getDisplay();
105 break;
109 echo $_SESSION['Import_message']['message'];
110 echo '<fieldset class="tblFooters">' . "\n";
111 echo ' [ <a href="' . $_SESSION['Import_message']['go_back_url']
112 . '">' . __('Back') . '</a> ]' . "\n";
113 echo '</fieldset>' . "\n";
115 } else {
116 PMA_importAjaxStatus($_GET["id"]);