Translated using Weblate (Croatian)
[phpmyadmin.git] / import_status.php
blobe7375c7fd7e36a0d83a0d1d29cd4d073bc01f217
1 <?php
2 /**
3 * Import progress bar backend
5 * @package PhpMyAdmin
6 */
7 declare(strict_types=1);
9 use PhpMyAdmin\Core;
10 use PhpMyAdmin\Display\ImportAjax;
12 if (! defined('ROOT_PATH')) {
13 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
16 /* PHP 5.4 stores upload progress data only in the default session.
17 * After calling session_name(), we won't find the progress data anymore.
19 * https://bugs.php.net/bug.php?id=64075
21 * The bug should be somewhere in
22 * https://github.com/php/php-src/blob/master/ext/session/session.c#L2342
24 * Until this is fixed, we need to load the default session to load the data,
25 * export the upload progress information from there,
26 * and re-import after switching to our session.
28 * However, since https://github.com/phpmyadmin/phpmyadmin/commit/063a2d99
29 * we have deactivated this feature, so the corresponding code is now
30 * commented out.
34 if (ini_get('session.upload_progress.enabled')) {
36 $sessionupload = array();
37 define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
39 session_start();
40 foreach ($_SESSION as $key => $value) {
41 // only copy session-prefixed data
42 if (substr($key, 0, strlen(UPLOAD_PREFIX))
43 == UPLOAD_PREFIX) {
44 $sessionupload[$key] = $value;
47 // PMA will kill all variables, so let's use a constant
48 define('SESSIONUPLOAD', serialize($sessionupload));
49 session_write_close();
51 session_name('phpMyAdmin');
52 session_id($_COOKIE['phpMyAdmin']);
56 define('PMA_MINIMUM_COMMON', 1);
58 require_once ROOT_PATH . 'libraries/common.inc.php';
59 list(
60 $SESSION_KEY,
61 $upload_id,
62 $plugins
63 ) = ImportAjax::uploadProgressSetup();
66 if (defined('SESSIONUPLOAD')) {
67 // write sessionupload back into the loaded PMA session
69 $sessionupload = unserialize(SESSIONUPLOAD);
70 foreach ($sessionupload as $key => $value) {
71 $_SESSION[$key] = $value;
74 // remove session upload data that are not set anymore
75 foreach ($_SESSION as $key => $value) {
76 if (substr($key, 0, strlen(UPLOAD_PREFIX))
77 == UPLOAD_PREFIX
78 && ! isset($sessionupload[$key])
79 ) {
80 unset($_SESSION[$key]);
86 // $_GET["message"] is used for asking for an import message
87 if (isset($_GET["message"]) && $_GET["message"]) {
88 // AJAX requests can't be cached!
89 Core::noCacheHeader();
91 header('Content-type: text/html');
93 // wait 0.3 sec before we check for $_SESSION variable,
94 // which is set inside libraries/entry_points/import.php
95 usleep(300000);
97 $maximumTime = ini_get('max_execution_time');
98 $timestamp = time();
99 // wait until message is available
100 while ($_SESSION['Import_message']['message'] == null) {
101 // close session before sleeping
102 session_write_close();
103 // sleep
104 usleep(250000); // 0.25 sec
105 // reopen session
106 session_start();
108 if ((time() - $timestamp) > $maximumTime) {
109 $_SESSION['Import_message']['message'] = PhpMyAdmin\Message::error(
110 __('Could not load the progress of the import.')
111 )->getDisplay();
112 break;
116 echo $_SESSION['Import_message']['message'];
117 echo '<fieldset class="tblFooters">' , "\n";
118 echo ' [ <a href="' , $_SESSION['Import_message']['go_back_url']
119 . '">' , __('Back') , '</a> ]' , "\n";
120 echo '</fieldset>' , "\n";
121 } else {
122 ImportAjax::status($_GET["id"]);