Translated using Weblate (Slovenian)
[phpmyadmin.git] / import_status.php
blob64b39915fc161e2388b6ee3b5812c120b5d9ba00
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 (ini_get('session.upload_progress.enabled')) {
29 $sessionupload = array();
30 define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
32 session_start();
33 foreach ($_SESSION as $key => $value) {
34 // only copy session-prefixed data
35 if (substr($key, 0, strlen(UPLOAD_PREFIX))
36 == UPLOAD_PREFIX) {
37 $sessionupload[$key] = $value;
40 // PMA will kill all variables, so let's use a constant
41 define('SESSIONUPLOAD', serialize($sessionupload));
42 session_write_close();
44 session_name('phpMyAdmin');
45 session_id($_COOKIE['phpMyAdmin']);
49 define('PMA_MINIMUM_COMMON', 1);
51 require_once 'libraries/common.inc.php';
52 require_once 'libraries/display_import_ajax.lib.php';
53 list(
54 $SESSION_KEY,
55 $upload_id,
56 $plugins
57 ) = PMA_uploadProgressSetup();
60 if (defined('SESSIONUPLOAD')) {
61 // write sessionupload back into the loaded PMA session
63 $sessionupload = unserialize(SESSIONUPLOAD);
64 foreach ($sessionupload as $key => $value) {
65 $_SESSION[$key] = $value;
68 // remove session upload data that are not set anymore
69 foreach ($_SESSION as $key => $value) {
70 if (substr($key, 0, strlen(UPLOAD_PREFIX))
71 == UPLOAD_PREFIX
72 && ! isset($sessionupload[$key])
73 ) {
74 unset($_SESSION[$key]);
80 // $_GET["message"] is used for asking for an import message
81 if (isset($_GET["message"]) && $_GET["message"]) {
83 // AJAX requests can't be cached!
84 PMA_noCacheHeader();
86 header('Content-type: text/html');
88 // wait 0.3 sec before we check for $_SESSION variable,
89 // which is set inside import.php
90 usleep(300000);
92 $maximumTime = ini_get('max_execution_time');
93 $timestamp = time();
94 // wait until message is available
95 while ($_SESSION['Import_message']['message'] == null) {
96 // close session before sleeping
97 session_write_close();
98 // sleep
99 usleep(250000); // 0.25 sec
100 // reopen session
101 session_start();
103 if ((time() - $timestamp) > $maximumTime) {
104 $_SESSION['Import_message']['message'] = PMA\libraries\Message::error(
105 __('Could not load the progress of the import.')
106 )->getDisplay();
107 break;
111 echo $_SESSION['Import_message']['message'];
112 echo '<fieldset class="tblFooters">' , "\n";
113 echo ' [ <a href="' , $_SESSION['Import_message']['go_back_url']
114 . '">' , __('Back') , '</a> ]' , "\n";
115 echo '</fieldset>' , "\n";
117 } else {
118 PMA_importAjaxStatus($_GET["id"]);