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